Closed svenbarnett closed 1 year ago
rendering chunks (90)...[vite-plugin-top-level-await] Cannot read properties of undefined (reading 'transformNeeded') error during build: TypeError: Cannot read properties of undefined (reading 'transformNeeded') at xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:158:75 at transformByType (xxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:18:16) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25) at transformByType (xxxxxx\node_modules\vite-plugin-top-level-await\dist\transform.js:15:25)
reproduce project pls
delete node_modules and npm install again, but not take effect
This happens in the scenario where CSS is being extracted into its own file. It doesn't have an AST so https://github.com/Menci/vite-plugin-top-level-await/blob/main/src/transform.ts#L243 fails.
I've made a PR with a test https://github.com/Menci/vite-plugin-top-level-await/pull/23
@steveworkman Are there any example? import "./xxxx.css"
generates __vitePreload()
for me. It doesn't generate import "./xxxx.css"
statements.
We are dynamically importing CSS from our main.ts file. Do that with vite defaults gives this error
On Sun, 5 Feb 2023, 12:54 Menci, @.***> wrote:
@steveworkman https://github.com/steveworkman Are there any example? import "./xxxx.css" generates __vitePreload() for me. It doesn't generate import "./xxxx.css" statements.
— Reply to this email directly, view it on GitHub https://github.com/Menci/vite-plugin-top-level-await/issues/18#issuecomment-1417758765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHS4WPY2SZAQUEIMRONCL3WV6PHRANCNFSM6AAAAAASZER4XY . You are receiving this because you were mentioned.Message ID: @.***>
@steveworkman I can't reproduce. Vite generates __vitePreload(() => Promise.resolve({}),true?["assets/semantic.be4f5b7e.css"]:void 0);
for me.
Could you send me a example project?
Run npm run build
on this https://github.com/steveworkman/vite-tla-bug and you get:
vite v4.1.1 building for production...
✓ 8 modules transformed.
rendering chunks (2)...[vite-plugin-top-level-await] Cannot read properties of undefined (reading 'transformNeeded')
error during build:
TypeError: Cannot read properties of undefined (reading 'transformNeeded')
at /Users/steve/code/vite-project/node_modules/vite-plugin-top-level-await/dist/transform.js:204:75
at transformByType (/Users/steve/code/vite-project/node_modules/vite-plugin-top-level-await/dist/transform.js:19:16)
Got it. There're other transforms after this plugin that removed the import()
expressions so I never noticed it.
Fixed in v1.2.4
[vite-plugin-top-level-await] Cannot read properties of undefined (reading 'transformNeeded') error during build: TypeError: Cannot read properties of undefined (reading 'transformNeeded') at ....\node_modules\vite-plugin-top-level-await\dist\transform.js:158:75
how to resolve this problem?
thanks