-
-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2657 from modernweb-dev/fix/storybook-builder-add…
…on-docs Multiple fixes for @storybook/addon-docs
- Loading branch information
Showing
5 changed files
with
86 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@web/storybook-builder': patch | ||
--- | ||
|
||
fix tocbot exports for addon-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@web/storybook-builder': patch | ||
--- | ||
|
||
prebundle required CommonJS modules for addon-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@web/storybook-builder': patch | ||
--- | ||
|
||
resolve @storybook/react-dom-shim for addon-docs |
29 changes: 29 additions & 0 deletions
29
packages/storybook-builder/src/esbuild-plugin-commonjs-named-exports.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Plugin } from 'esbuild'; | ||
|
||
export function esbuildPluginCommonjsNamedExports(module: string, namedExports: string[]): Plugin { | ||
return { | ||
name: 'commonjs-named-exports', | ||
setup(build) { | ||
build.onResolve({ filter: new RegExp(`^${module}$`) }, args => { | ||
return { | ||
path: args.path, | ||
namespace: `commonjs-named-exports-${module}`, | ||
pluginData: { | ||
resolveDir: args.resolveDir, | ||
}, | ||
}; | ||
}); | ||
build.onLoad({ filter: /.*/, namespace: `commonjs-named-exports-${module}` }, async args => { | ||
return { | ||
resolveDir: args.pluginData.resolveDir, | ||
contents: ` | ||
import { default as commonjsExports } from '${module}?force-original'; | ||
${namedExports | ||
.map(name => `export const ${name} = commonjsExports.${name};`) | ||
.join('\n')} | ||
`, | ||
}; | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters