@makcbrain/storybook-builder-esbuild 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,8 +28,9 @@ export const generateAppEntryCode = async (options) => {
28
28
  .map((story) => {
29
29
  const relative = path.relative(process.cwd(), story);
30
30
  const key = story.startsWith('./') ? relative : `./${relative}`;
31
- // Get CSS file path by replacing story extension with .css
31
+ // Get CSS and JS output paths by replacing the story extension
32
32
  const cssPath = key.replace(/\.([jt]sx?|mdx)$/, '.css');
33
+ const jsOutputPath = key.replace(/\.([jt]sx?|mdx)$/, '.js');
33
34
  return `'${key}': () => {
34
35
  const cssUrl = new URL('${cssPath}', import.meta.url);
35
36
 
@@ -41,7 +42,10 @@ export const generateAppEntryCode = async (options) => {
41
42
  document.head.appendChild(link);
42
43
  }
43
44
 
44
- return import('${story}');
45
+ // Use a variable so esbuild can't statically resolve this import.
46
+ // This prevents story CSS from being pulled into virtualApp.css.
47
+ const storyOutputPath = '${jsOutputPath}';
48
+ return import(storyOutputPath);
45
49
  }`;
46
50
  })
47
51
  .join(',\n ');
@@ -18,6 +18,7 @@ export const generateIframeHtml = async (options, esbuildServerUrl) => {
18
18
  window.module = undefined;
19
19
  window.global = window;
20
20
  </script>
21
+ <link rel="stylesheet" href="${esbuildServerUrl}/virtualApp.css" onerror="this.remove()">
21
22
  ${headHtmlSnippet || ''}
22
23
  </head>
23
24
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makcbrain/storybook-builder-esbuild",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "author": "Maksim Kadochnikov <makс.brain@gmail.com>",
5
5
  "description": "Builder for Storybook with supporting esbuild",
6
6
  "license": "MIT",
@@ -53,6 +53,6 @@
53
53
  "slash": "5.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "esbuild": "^0.10.0"
56
+ "esbuild": ">=0.10.0"
57
57
  }
58
58
  }