-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read properties of undefined (reading 'importedBy') #33
Comments
Im also getting the same error |
Seeing this when trying to build with storybook but not when building vite on its own.
Any ideas on why one would throw and error and the other wouldn't? |
I'm seeing the same error in my project. I migrated a storybook project from webpack to vite, and in webpack I had this config: webpackFinal: async (config) => {
((config.resolve ??= {}).plugins ??= []).push(
new TsconfigPathsPlugin({ extensions: config.resolve.extensions }),
);
config.experiments = { ...config.experiments, topLevelAwait: true };
return config;
}, So I was looking for an alternative to that At first, I tried both of these two options, but if I understand correctly, those are just telling the build to not transpile most things, so my build was failing. So I arrived to this plugin, tried it both with no options and with the options provided in the example (which I noticed are just the defaults), but then it gives me the same error as in the reports above. rendering chunks (346)...[vite-plugin-top-level-await] Cannot read properties of undefined (reading 'importedBy')
✓ built in 35.33s
TypeError: Cannot read properties of undefined (reading 'importedBy')
at ./node_modules/vite-plugin-top-level-await/dist/bundle-info.js:64:44
at Array.forEach (<anonymous>)
at parseBundleInfo (./node_modules/vite-plugin-top-level-await/dist/bundle-info.js:63:29)
at Object.generateBundle (./node_modules/vite-plugin-top-level-await/dist/index.js:87:72)
at async Bundle.generate (file:https://./node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17848:9)
at async file:https://./node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:26694:27
at async catchUnfinishedHookActions (file:https://./node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:25827:16)
at async Module.build (file:https://./node_modules/vite/dist/node/chunks/dep-df561101.js:48011:22)
at async build (./node_modules/@storybook/builder-vite/dist/index.js:159:11024)
at async Promise.all (index 0)
at async Module.build2 (./node_modules/@storybook/builder-vite/dist/index.js:159:13356)
at async Promise.all (index 0)
at async buildStaticStandalone (./node_modules/@storybook/core-server/dist/index.js:97:4608)
at async withTelemetry (./node_modules/@storybook/core-server/dist/index.js:101:4155)
at async build (./node_modules/@storybook/cli/dist/generate.js:473:1059)
at async Command.<anonymous> (./node_modules/@storybook/cli/dist/generate.js:476:125) Any idea on why this happens or what else could I try? I looked into the code of this plugin but didn't find more options I could try. I could try offering an example reproduction repo, but I've seen other's provide one in issue #32 and apparently that didn't work out. Thanks in advance! |
I ran into the same error but couldn't find a fix. A workaround I have is to skip adding this plugin when building for Storybook:
Run script with This will at least move you past the error until a good fix is found. |
@spencerchubb Even without this plugin, your project builds an import to a non-existing file... I have no idea of how it could happen... I'll workaround it in my plugin by ignoring non-existing files when processing. But I'm not sure whether it could lead to other issues... |
I don't know why this bug is happening, but I do know that it's related to importing the css and ts. If you comment out any of the imports in page1.html or page2.html, then it builds without error.
Minimal reproduction: https://github.com/spencerchubb/top-level-await-bug
This may be a related issue: #32
The bug:
The text was updated successfully, but these errors were encountered: