Skip to content

Commit

Permalink
fix: ensure directory when running in generating types in esbuild (#2940
Browse files Browse the repository at this point in the history
)
  • Loading branch information
barak007 authored and idoros committed Feb 12, 2024
1 parent 198c90a commit 8582abd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/cli/src/build-single-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export function buildDTS({
relative,
dirname,
isAbsolute,
mkdirSync,
}: {
res: StylableResults;
targetFilePath: string;
Expand All @@ -279,13 +280,17 @@ export function buildDTS({
relative: (from: string, to: string) => string;
dirname: (p: string) => string;
isAbsolute: (p: string) => boolean;
mkdirSync?: (path: string, { recursive }: { recursive: boolean }) => void;
}) {
const dtsContent = generateDTSContent(res);
const dtsPath = targetFilePath + '.d.ts';

generated.add(dtsPath);
outputLogs.push('output .d.ts');

tryRun(
() => mkdirSync?.(dirname(dtsPath), { recursive: true }),
`Ensure directory: ${dirname(dtsPath)}`
);
tryRun(() => writeFileSync(dtsPath, dtsContent), `Write File Error: ${dtsPath}`);

// .d.ts.map
Expand Down
1 change: 1 addition & 0 deletions packages/esbuild/src/stylable-esbuild-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ export const stylablePlugin = (initialPluginOptions: ESBuildOptions = {}): Plugi
relative,
dirname,
isAbsolute,
mkdirSync: fs.mkdirSync,
});
}
}
Expand Down

0 comments on commit 8582abd

Please sign in to comment.