Skip to content

Commit a3821c3

Browse files
fix: (dirty) workaround for autodocs in for WDS & Rollup build
1 parent ad8f583 commit a3821c3

File tree

4 files changed

+153
-2
lines changed

4 files changed

+153
-2
lines changed

package-lock.json

Lines changed: 104 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/storybook-builder/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
],
4949
"dependencies": {
5050
"@chialab/esbuild-plugin-commonjs": "^0.17.2",
51+
"@rollup/plugin-alias": "^5.0.1",
52+
"@rollup/plugin-commonjs": "^25.0.7",
53+
"@rollup/plugin-json": "^6.0.1",
5154
"@rollup/plugin-node-resolve": "^15.1.0",
5255
"@rollup/pluginutils": "^5.0.2",
5356
"@storybook/core-common": "^7.0.0",
@@ -67,6 +70,7 @@
6770
"path-browserify": "^1.0.1",
6871
"rollup": "^3.25.1",
6972
"rollup-plugin-external-globals": "^0.7.3",
73+
"rollup-plugin-inject-process-env": "^1.3.1",
7074
"slash": "^5.1.0"
7175
},
7276
"devDependencies": {

packages/storybook-builder/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {
2020
rollupPluginPrebundleModules,
2121
} from './rollup-plugin-prebundle-modules';
2222
import { rollupPluginStorybookBuilder } from './rollup-plugin-storybook-builder';
23+
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
24+
import rollupPluginInjectProcessEnv from 'rollup-plugin-inject-process-env';
25+
import rollupPluginJson from '@rollup/plugin-json';
26+
import alias from '@rollup/plugin-alias';
2327

2428
const wdsPluginExternalGlobals = fromRollup(rollupPluginExternalGlobals);
2529
const wdsPluginPrebundleModules = fromRollup(rollupPluginPrebundleModules);
@@ -144,7 +148,14 @@ export const build: WdsBuilder['build'] = async ({ startTime, options }) => {
144148
extractAssets: false,
145149
}),
146150
rollupPluginNodeResolve(),
147-
rollupPluginPrebundleModules(env),
151+
alias({
152+
entries: [
153+
{ find: 'assert', replacement: 'browser-assert' },
154+
]
155+
}),
156+
rollupPluginJson(),
157+
rollupPluginCommonjs(),
158+
rollupPluginInjectProcessEnv(env),
148159
rollupPluginStorybookBuilder(options),
149160
rollupPluginExternalGlobals(globals),
150161
],

packages/storybook-builder/src/rollup-plugin-prebundle-modules.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,37 @@ export const CANDIDATES = [
8585

8686
// ESM, but uses `process.env.NODE_ENV`
8787
'tiny-invariant',
88+
/**
89+
* dependency of '@storybook/react-dom-shim' (https://cdn.jsdelivr.net/npm/@storybook/react-dom-shim@7.5.1/dist/react-16.mjs)
90+
* exports rely on commonjs: https://cdn.jsdelivr.net/npm/react-dom@18.2.0/index.js
91+
*/
92+
'react-dom',
93+
/**
94+
* dependency of '@storybook/theming' (https://cdn.jsdelivr.net/npm/@storybook/theming@7.5.1/dist/index.mjs)
95+
* `import * as React from 'react';
96+
* import { forwardRef, useContext } from 'react';`
97+
* exports rely on commonjs: https://cdn.jsdelivr.net/npm/react@18.2.0/index.js
98+
*/
99+
'react',
100+
/**
101+
* dependency of '@storybook/theming' (https://cdn.jsdelivr.net/npm/@storybook/theming@7.5.1/dist/index.mjs)
102+
* `import memoize2 from 'memoizerific';`
103+
* exports rely on commonjs: https://cdn.jsdelivr.net/npm/memoizerific@1.11.3/src/memoizerific.js
104+
*/
105+
'memoizerific',
106+
/**
107+
* dependencies of '@storybook/blocks' (https://cdn.jsdelivr.net/npm/@storybook/blocks@7.5.1/dist/index.mjs)
108+
* they all rely on commonjs (https://cdn.jsdelivr.net/npm/lodash@4.17.21/uniq.js for instance)
109+
*/
110+
'lodash/uniq.js',
111+
'lodash/pickBy.js',
112+
'lodash/cloneDeep.js',
113+
'lodash/throttle.js',
114+
/**
115+
* dependency of '@storybook/dist/Color-[hash].msj' (https://cdn.jsdelivr.net/npm/@storybook/blocks@7.5.1/dist/Color-6VNJS4EI.mjs)
116+
* exports rely on commonjs: https://cdn.jsdelivr.net/npm/color-convert@2.0.1/index.js
117+
*/
118+
'color-convert',
119+
'tocbot',
120+
'@storybook/blocks',
88121
];

0 commit comments

Comments
 (0)