Skip to content
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

Vite do not scan the dependency when using import.meta.glob #10634

Closed
7 tasks done
candy-Tong opened this issue Oct 25, 2022 · 0 comments · Fixed by #10635
Closed
7 tasks done

Vite do not scan the dependency when using import.meta.glob #10634

candy-Tong opened this issue Oct 25, 2022 · 0 comments · Fixed by #10635
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release

Comments

@candy-Tong
Copy link
Contributor

candy-Tong commented Oct 25, 2022

Describe the bug

https://github.com/candy-Tong/tdesign-vue-next-starter-candy/blob/develop/src/router/index.ts#L5

I use import.meta.glob to get all vue-route file in Vue. Vite do not scan the dependency when using import.meta.glob.
So it can not find all the dependence in my project.

  1. the first time, it find the echart/core and build it.
  2. When i open the page and the code is executed, vite can find echart/charts and it will rebuild and reflesh the page. That is a bad experience when i first run the project.

I also find that Vite2.x do not has this problem ant Vite3.x has.
I find that in this pull request, vite delete the code that transform the import.meta.glob in scan JS/TS.
If this is not bug, why delete it?

image

Reproduction

https://github.com/candy-Tong/tdesign-vue-next-starter-candy

Steps to reproduce

  1. pnpm i
  2. npm run dev

The page will refresh when first time to run vite
image

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
    Memory: 8.53 GB / 31.89 GB
  Binaries:
    Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 106.0.5249.119
    Edge: Spartan (44.19041.1266.0), Chromium (106.0.1370.52)
    Internet Explorer: 11.0.19041.1202

Used Package Manager

pnpm

Logs

> tdesign-vue-next-starter@0.5.4 dev:linux
> cross-env DEBUG=vite:deps vite --force  

Forced re-optimization of dependencies
Port 3002 is in use, trying another one...
Port 3003 is in use, trying another one...

  VITE v3.1.8  ready in 6747 ms

  ➜  Local:   http://localhost:3004/
  ➜  Network: http://192.168.255.10:3004/
  ➜  Network: http://10.40.164.47:3004/
  vite:deps scanning for dependencies... +0ms
  vite:deps Crawling dependencies using entries:
  vite:deps   E:/app/tdesign-vue-next-starter-candy/index.html +0ms
  vite:deps Scan completed in 1202.49ms: {                                                                                                                                                         
  vue: 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/vue@3.2.41/node_modules/vue/dist/vue.runtime.esm-bundler.js',                                                                     
  'tdesign-vue-next': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/tdesign-vue-next@0.24.2_vue@3.2.41/node_modules/tdesign-vue-next/es/index.mjs',                                    
  pinia: 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/pinia@2.0.23_l7r24p6nevbtlimqmqcwa3ouhu/node_modules/pinia/dist/pinia.mjs',                                                     
  'vue-router': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/vue-router@4.1.6_vue@3.2.41/node_modules/vue-router/dist/vue-router.mjs',                                                
  nprogress: 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/nprogress@0.2.0/node_modules/nprogress/nprogress.js',                                                                       
  'pinia-plugin-persistedstate': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/pinia-plugin-persistedstate@2.3.0_pinia@2.0.23/node_modules/pinia-plugin-persistedstate/dist/index.mjs',
  'lodash/uniq': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/uniq.js',
  'lodash/keys': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/keys.js',
  'tvision-color': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/tvision-color@1.4.0/node_modules/tvision-color/dist/esm/index.js',
  'vue-clipboard3': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/vue-clipboard3@2.0.0/node_modules/vue-clipboard3/dist/esm/index.js',
  'echarts/core': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/echarts@5.1.2/node_modules/echarts/core.js',
  'qrcode.vue': 'E:/app/tdesign-vue-next-starter-candy/node_modules/.pnpm/qrcode.vue@3.3.3_vue@3.2.41/node_modules/qrcode.vue/dist/qrcode.vue.esm.js'
} +1s
  vite:deps dependencies found by scanner: echarts/core, lodash/keys, lodash/uniq, nprogress, pinia, pinia-plugin-persistedstate, qrcode.vue, tdesign-vue-next, tvision-color, vue, vue-clipboard3, vue-router
 +1s
  vite:deps deps bundled in 14863.82ms +15s
  vite:deps ✨ static imports crawl ended +133ms
  vite:deps ✨ new dependencies were found while crawling that weren't detected by the scanner +25ms
  vite:deps ✨ re-running optimizer +1ms
  vite:deps new dependencies found: echarts/core, lodash/keys, lodash/uniq, nprogress, pinia, pinia-plugin-persistedstate, qrcode.vue, tdesign-vue-next, tvision-color, vue, vue-clipboard3, vue-router, lodas
h/union, lodash/isObject +4ms
  vite:deps deps bundled in 9557.51ms +10s
  vite:deps ✨ dependencies optimized +8ms
  vite:deps new dependencies found: echarts/components, echarts/charts, echarts/renderers, tdesign-icons-vue-next +2s
  vite:deps ✨ static imports crawl ended +18s
  vite:deps deps bundled in 19993.24ms +2s
  vite:deps ✨ delaying reload as new dependencies have been found... +37ms
  vite:deps new dependencies found: echarts/components, echarts/charts, echarts/renderers, tdesign-icons-vue-next, dayjs +0ms
  vite:deps deps bundled in 19400.76ms +19s
下午10:11:37 [vite] ✨ optimized dependencies changed. reloading

Validations

candy-Tong added a commit to candy-Tong/vite that referenced this issue Oct 25, 2022
candy-Tong added a commit to candy-Tong/vite that referenced this issue Oct 25, 2022
@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release feat: deps optimizer Esbuild Dependencies Optimization labels Oct 26, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants