vite icon indicating copy to clipboard operation
vite copied to clipboard

fix: align dynamic import detection

Open sapphi-red opened this issue 6 months ago • 5 comments

Description

According to #2519 and https://github.com/vitejs/vite/commit/e6f7fbad75c1b406b9a95060c5d2a42d3a8994a8#diff-c21c6724d412c50eabaaaf67a8fa37cea7ab889f0c23e628713893f7dd34770a, it seems the isInNodeModules(importer) && condition was to skip import.meta.glob processing in deps. But now that import.meta.glob processing is done in a separate plugin, this condition no longer made sense.

The current condition is skipping edge case dynamic imports only for deps (example cases of them - es-module-lexer repl).

I think the current code is difficult to understand the intent and also the behavior is strange. I think no one would write these in the source code, so I guess we can just remove this condition. If we should support these, we can update the dynamicImportPrefixRE regex to /import\s*[(/]/.

sapphi-red avatar May 27 '25 05:05 sapphi-red

/ecosystem-ci run

patak-dev avatar May 27 '25 07:05 patak-dev

Open in StackBlitz

npm i https://pkg.pr.new/vite@20115

commit: 15d2a3f

pkg-pr-new[bot] avatar May 27 '25 07:05 pkg-pr-new[bot]

📝 Ran ecosystem CI on 75521eb: Open

suite result latest scheduled
histoire :x: failure :white_check_mark: success
analogjs :x: failure :x: failure
previewjs :x: failure :white_check_mark: success
qwik :x: failure :white_check_mark: success
laravel :x: failure :x: failure
nuxt :white_check_mark: success :x: failure
waku :x: failure :white_check_mark: success
vike :x: failure :white_check_mark: success
vitest :x: failure :x: failure

:white_check_mark: ladle, marko, quasar, rakkas, astro, react-router, vite-plugin-react, vuepress, vite-environment-examples, vite-plugin-pwa, vitepress, unocss, storybook, vite-setup-catalogue, vite-plugin-cloudflare, sveltekit, vite-plugin-vue, vite-plugin-svelte

vite-ecosystem-ci[bot] avatar May 27 '25 07:05 vite-ecosystem-ci[bot]

It seems that https://github.com/vitejs/vite/pull/19936 will cause some regressions in the ecosystem. For code like this one https://github.com/wakujs/waku/blob/16f21c7ce460071392e995a634acc058a7c5ed53/packages/waku/src/lib/plugins/patch-react-refresh.ts#L14 that calls transformIndexHtml manually. Maybe we need to accept these issues. I don't know if there is a way to avoid them.

patak-dev avatar May 27 '25 07:05 patak-dev

Maybe we need to accept these issues. I don't know if there is a way to avoid them.

Yeah, I think we cannot avoid these.

sapphi-red avatar May 27 '25 12:05 sapphi-red

/ecosystem-ci run

sapphi-red avatar Jun 06 '25 07:06 sapphi-red

📝 Ran ecosystem CI on 15d2a3f: Open

suite result latest scheduled
analogjs :x: failure :x: failure
astro :x: failure :x: failure
histoire :x: failure :x: failure
previewjs :x: failure :x: failure
sveltekit :x: failure :x: failure
vike :x: failure :x: failure
vite-plugin-cloudflare :x: failure :x: failure

:white_check_mark: ladle, laravel, qwik, nuxt, rakkas, react-router, quasar, marko, vitepress, vite-plugin-svelte, vite-setup-catalogue, vite-plugin-vue, vitest, vite-plugin-react, unocss, storybook, waku, vite-plugin-pwa, vuepress, vite-environment-examples

vite-ecosystem-ci[bot] avatar Jun 06 '25 08:06 vite-ecosystem-ci[bot]

vike is failing with a different error but the reason is same with https://github.com/vitejs/vite/pull/20080#issuecomment-2899825610 and not caused by this PR.

sapphi-red avatar Jun 06 '25 08:06 sapphi-red