Skip to content

Commit f8742b7

Browse files
authored
fix: create folder before writing bootstrap (#3222)
1 parent 95ea70e commit f8742b7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/clean-boats-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/storybook-addon': patch
3+
---
4+
5+
fix: create folder before writing bootstrap

packages/storybook-addon/src/utils/with-module-federation-enhanced-rsbuild.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { correctImportPath } from './correctImportPath';
88
import type { RsbuildConfig, RsbuildPlugin } from '@rsbuild/core';
99
import type { moduleFederationPlugin } from '@module-federation/sdk';
1010

11+
const tempDirPath = path.resolve(process.cwd(), `node_modules/${TEMP_DIR}`);
1112
// add bootstrap for host project
1213
const bootstrapPath = path.resolve(
1314
process.cwd(),
@@ -17,6 +18,10 @@ const generateBootstrap = (context: string, entryPath: string) => {
1718
return `import('${correctImportPath(context, entryPath)}');`;
1819
};
1920
const writeBootstrap = (context: string, entryPath: string) => {
21+
if (!fs.existsSync(tempDirPath)) {
22+
fs.mkdirSync(tempDirPath);
23+
}
24+
2025
if (fs.existsSync(bootstrapPath)) {
2126
fs.unlinkSync(bootstrapPath);
2227
}

0 commit comments

Comments
 (0)