-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Bug report
What is the current behavior?
Storybook has started failing immediately after upgrading to webpack:5.84.0.
We do not have control over which version of webpack the end-user is using, this is a pressing issue for us.
Here's what I know:
-
storybook has e2e sandboxes for all sorts of integration-points, such as CRA, NextJS, AngularJS, some of those use webpack.
-
Every single one using webpack has started failing immediately after upgrading them to the latest version of webpack (something we do automatically every 24h) commit ci
-
storybook uses the
externalsfeature of webpack your docs, I mention this because I believe this to be highly related to the problem/error -
storybook also uses resolve.aliasses, again I think this is related
The way storybook fails, seems to be in a few ways...
-
see the error for yourself here
Error: page.evaluate: ReferenceError: Preview$1 is not defined at ./node_modules/@storybook/blocks/dist/index.mjs (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/4156.087e1d00.iframe.bundle.js:56:2713) at __webpack_require__ (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/runtime~main.a02828eb.iframe.bundle.js:1:381) at ./src/stories/Introduction.mdx (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/stories-Introduction-mdx.6e4fdf47.iframe.bundle.js:2:2747) at __webpack_require__ (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/runtime~main.a02828eb.iframe.bundle.js:1:381) at https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/main.3e8a31a1.iframe.bundle.js:1:569535 at _ZoneDelegate.invoke (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/6187.8c80c92e.iframe.bundle.js:421:668315) at Zone.run (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/6187.8c80c92e.iframe.bundle.js:421:660708) at https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/6187.8c80c92e.iframe.bundle.js:421:687992 at _ZoneDelegate.invokeTask (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/6187.8c80c92e.iframe.bundle.js:421:669250) at Zone.runTask (https://6377871ac35b4b579c6b8bfc-ffecdbzauy.capture.chromatic.com/6187.8c80c92e.iframe.bundle.js:421:661791) → Failed to publish buildThis error occurs according to webpack in
@storybook/blocks/dist/index.mjs, I check the webpack output:

What's interesting to note is that Preview$1 is imported as a named import (but renamed) from a module, we later externalize:
import { filterArgTypes, composeConfigs, Preview as Preview$1, DocsContext as DocsContext$1 } from '@storybook/preview-api';- see the error for yourself here
I have no leads on what's happening here.
error: Unhandled Promise rejection:, Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization, ; Zone:, <root>, ; Task:, Promise.then, ; Value:, {}, ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization at Module.default (http:/localhost:8001/stories-mdx-basic-stories-mdx.f299e8c2.iframe.bundle.js:2:5935) at processCSFFile (http:/localhost:8001/sb-preview/runtime.js:34:77) at StoryStore.memoizerific [as processCSFFileWithCache] (http:/localhost:8001/sb-preview/runtime.js:1:4768) at http:/localhost:8001/sb-preview/runtime.js:40:8542 at _ZoneDelegate.invoke (http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:668315) at Zone.run (http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:660708) at http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:687992 at _ZoneDelegate.invokeTask (http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:669250) at Zone.runTask (http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:661791) at drainMicroTaskQueue (http:/localhost:8001/6187.8c80c92e.iframe.bundle.js:421:672963)
If the current behavior is a bug, please provide the steps to reproduce.
- create a storybook sandbox with webpack:
npx storybook sandbox - choose a sandbox that has webpack, the first option: "Create React App (Javascript)" will work
- choose any location you wish
- cd into the directory you choose
- run
yarn install - run
yarn build-storybook - run
npx http-server ./storybook-static - open your browser and navigate to http://127.0.0.1:8080/?path=/docs/example-introduction--docs
- open dev-tools
- refresh the page
What is the expected behavior?
Webpack should ensure the outputted code is valid, and does not have runtime errors when executing, there must be something in this changeset:
v5.83.1...v5.84.0
... that is causing the above problem.
Other relevant information:
webpack version: 5.84.0
Node.js version: 16
Operating System: macOS
Additional tools: storybook
