hipstersmoothie / storybook-dark-mode

A storybook addon that lets your users toggle between dark and light mode.
MIT License
429 stars 56 forks source link

build from storybook v7 + vite failed #221

Closed himself65 closed 1 year ago

himself65 commented 1 year ago

Upstream: https://github.com/toeverything/AFFiNE/pull/1016

/Users/himself65/.nvm/versions/node/v16.19.0/bin/pnpm run build-storybook

> @affine/component@0.3.1 build-storybook /Users/himself65/Code/AFFiNE/packages/component
> storybook build

@storybook/cli v7.0.0-beta.50

info => Cleaning outputDir: /storybook-static
info => Loading presets
info => Building manager..
info => Manager built (42 ms)
info => Copying static files: /Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+manager@7.0.0-beta.50/node_modules/@storybook/manager/static at /Users/himself65/Code/AFFiNE/packages/component/storybook-static/sb-common-assets
info => Copying static files: /Users/himself65/Code/AFFiNE/apps/web/public at /Users/himself65/Code/AFFiNE/packages/component/storybook-static/
vite v4.1.2 building for production...

./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 756 modules transformed.
[commonjs--resolver] Unexpected token
file: /Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+components@6.5.16_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/components/dist/esm/index.js:7:33
5: import '@storybook/csf';
6: import 'qs';
7: import '@storybook/client-logger';
                                    ^
transforming (1217) ../../node_modules/.pnpm/@mui+private-theming@5.11.7_3stiutgnnbnfnf3uowm5cip22i/node_modules/@mui/pERR! RollupError: Unexpected token
ERR!     at error (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:2091:30)
ERR!     at Module.error (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13125:16)
ERR!     at Module.tryParse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13799:25)
ERR!     at Module.setSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13409:39)
ERR!     at ModuleLoader.addModuleSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:23117:20)
ERR!  Error [RollupError]: Unexpected token
ERR!     at error (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:2091:30)
ERR!     at Module.error (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13125:16)
ERR!     at Module.tryParse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13799:25)
ERR!     at Module.setSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13409:39)
ERR!     at ModuleLoader.addModuleSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:23117:20) {
ERR!   cause: SyntaxError: Unexpected token (7:40)
ERR!       at Object.pp$4.raise (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:20525:13)
ERR!       at Object.pp$9.unexpected (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:17826:8)
ERR!       at Object.pp$8.parseVar (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:18371:12)
ERR!       at Object.pp$8.parseVarStatement (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:18233:8)
ERR!       at Object.pp$8.parseStatement (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:17981:17)
ERR!       at Object.pp$8.parseTopLevel (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:17883:21)
ERR!       at Object.parse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:17655:15)
ERR!       at Function.parse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:17705:35)
ERR!       at Graph.contextParse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:24101:38)
ERR!       at Module.tryParse (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13796:31)
ERR!       at Module.setSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:13409:39)
ERR!       at ModuleLoader.addModuleSource (file:///Users/himself65/Code/AFFiNE/node_modules/.pnpm/rollup@3.14.0/node_modules/rollup/dist/es/shared/rollup.js:23117:20) {
ERR!     pos: 1805,
ERR!     loc: Position { line: 7, column: 40 },
ERR!     raisedAt: 1806
ERR!   },
ERR!   code: 'PLUGIN_ERROR',
ERR!   id: '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+components@6.5.16_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/components/dist/esm/index.js',
ERR!   pos: 1805,
ERR!   loc: {
ERR!     column: 33,
ERR!     file: '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+components@6.5.16_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/components/dist/esm/index.js',
ERR!     line: 7
ERR!   },
ERR!   frame: "5: import '@storybook/csf';\n" +
ERR!     "6: import 'qs';\n" +
ERR!     "7: import '@storybook/client-logger';\n" +
ERR!     '                                    ^',
ERR!   pluginCode: 'PARSE_ERROR',
ERR!   plugin: 'commonjs--resolver',
ERR!   hook: 'resolveId',
ERR!   watchFiles: [
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/iframe.html',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/package.json',
ERR!     '/virtual:/@storybook/builder-vite/vite-app.js',
ERR!     '\x00vite/modulepreload-polyfill',
ERR!     '/virtual:/@storybook/builder-vite/setup-addons.js',
ERR!     '/virtual:/@storybook/builder-vite/storybook-stories.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+react@7.0.0-beta.50_ygqkwb4gg3aean7xjfdauovyqq/node_modules/@storybook/react/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+addon-links@7.0.0-beta.50_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/addon-links/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+react@7.0.0-beta.50_ygqkwb4gg3aean7xjfdauovyqq/node_modules/@storybook/react/dist/config.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+addon-links@7.0.0-beta.50_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/addon-links/dist/preview.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/.storybook/preview.tsx',
ERR!     '\x00vite/preload-helper',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/src/stories/BlockSuiteEditor.stories.tsx',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/src/stories/BlockSuiteErrorBoundary.stories.tsx',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/src/stories/Breadcrumbs.stories.tsx',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/src/stories/Button.stories.tsx',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+docs-tools@7.0.0-beta.50/node_modules/@storybook/docs-tools/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/html-tags@3.2.0/node_modules/html-tags/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/escodegen@2.0.0/node_modules/escodegen/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn@7.4.1/node_modules/acorn/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-jsx@5.3.2_acorn@7.4.1/node_modules/acorn-jsx/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-walk@7.2.0/node_modules/acorn-walk/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-element-to-jsx-string@15.0.0_biqbaboplfbrettd7655fr4n2y/node_modules/react-element-to-jsx-string/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react@18.2.0/node_modules/react/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/html-tags@3.2.0/node_modules/html-tags/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/escodegen@2.0.0/node_modules/escodegen/escodegen.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/esm/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-jsx@5.3.2_acorn@7.4.1/node_modules/acorn-jsx/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isPlainObject.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isFunction.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isString.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-element-to-jsx-string@15.0.0_biqbaboplfbrettd7655fr4n2y/node_modules/react-element-to-jsx-string/dist/esm/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+react@7.0.0-beta.50_ygqkwb4gg3aean7xjfdauovyqq/node_modules/@storybook/react/dist/chunk-RE33ZCRP.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+docs-tools@7.0.0-beta.50/node_modules/@storybook/docs-tools/dist/index.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn@7.4.1/node_modules/acorn/dist/acorn.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-walk@7.2.0/node_modules/acorn-walk/dist/walk.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+addon-links@7.0.0-beta.50_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/addon-links/dist/chunk-HG45ZTEM.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+addon-links@7.0.0-beta.50_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/addon-links/dist/chunk-YFKH3BW3.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+addon-links@7.0.0-beta.50_biqbaboplfbrettd7655fr4n2y/node_modules/@storybook/addon-links/dist/chunk-JT3VIYBO.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getPrototype.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObjectLike.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/html-tags@3.2.0/node_modules/html-tags/html-tags.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-jsx@5.3.2_acorn@7.4.1/node_modules/acorn-jsx/xhtml.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/estraverse@5.3.0/node_modules/estraverse/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/esutils@2.0.3/node_modules/esutils/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/estraverse@5.3.0/node_modules/estraverse/estraverse.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/esutils@2.0.3/node_modules/esutils/lib/utils.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArray.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.production.min.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@base2+pretty-print-object@1.0.1/node_modules/@base2/pretty-print-object/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-is@18.1.0/node_modules/react-is/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@base2+pretty-print-object@1.0.1/node_modules/@base2/pretty-print-object/dist/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-is@18.1.0/node_modules/react-is/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/doctrine@3.0.0/node_modules/doctrine/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/mapValues.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/doctrine@3.0.0/node_modules/doctrine/lib/doctrine.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+global@5.0.0/node_modules/@storybook/global/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/index.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/client.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+global@5.0.0/node_modules/@storybook/global/dist/index.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/storybook-dark-mode@2.0.6_biqbaboplfbrettd7655fr4n2y/node_modules/storybook-dark-mode/package.json',
ERR!     '\x00react/jsx-runtime',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/storybook-dark-mode@2.0.6_biqbaboplfbrettd7655fr4n2y/node_modules/storybook-dark-mode/src/index.tsx',
ERR!     '/Users/himself65/Code/AFFiNE/packages/component/src/index.ts',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+csf@0.0.2-next.10/node_modules/@storybook/csf/package.json',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/@storybook+csf@0.0.2-next.10/node_modules/@storybook/csf/dist/index.mjs',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getRawTag.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_objectToString.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_overArg.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js',
ERR!     '\x00commonjsHelpers.js',
ERR!     '\x00/Users/himself65/Code/AFFiNE/node_modules/.pnpm/html-tags@3.2.0/node_modules/html-tags/index.js?commonjs-module',
ERR!     '\x00/Users/himself65/Code/AFFiNE/node_modules/.pnpm/html-tags@3.2.0/node_modules/html-tags/html-tags.json?commonjs-proxy',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/esutils@2.0.3/node_modules/esutils/lib/ast.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/esutils@2.0.3/node_modules/esutils/lib/code.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/esutils@2.0.3/node_modules/esutils/lib/keyword.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-generator.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js',
ERR!     '\x00/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-jsx@5.3.2_acorn@7.4.1/node_modules/acorn-jsx/index.js?commonjs-module',
ERR!     '\x00/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn-jsx@5.3.2_acorn@7.4.1/node_modules/acorn-jsx/xhtml.js?commonjs-proxy',
ERR!     '\x00/Users/himself65/Code/AFFiNE/node_modules/.pnpm/acorn@7.4.1/node_modules/acorn/dist/acorn.mjs?commonjs-proxy',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/react-is@18.1.0/node_modules/react-is/cjs/react-is.production.min.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js',
ERR!     '/Users/himself65/Code/AFFiNE/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseForOwn.js',
ERR!     ... 1238 more items
ERR!   ]
ERR! }
 ELIFECYCLE  Command failed with exit code 1.

Process finished with exit code 1
Pettor commented 1 year ago

Yes, having the same issue with latest Storybook 7 beta 53 and Vite 4.1.1.

hipstersmoothie commented 1 year ago

PRs welcome

himself65 commented 1 year ago

I publish a package storybook-dark-mode-v7 that based on https://github.com/hipstersmoothie/storybook-dark-mode/pull/224

filiptammergard commented 1 year ago

I publish a package storybook-dark-mode-v7 that based on #224

Using this in the meantime – thanks!