vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.06k stars 2.11k forks source link

import.meta.glob evelopment pattern is not work #4342

Open MaLuns opened 9 hours ago

MaLuns commented 9 hours ago

Describe the bug

I pass import.meta.glob('./components/global/*.vue', {import: 'default', eager: true}), Import global components in batches for registration. After I publish the theme package to npm, then install the theme package through npm installation. The temporary file generated in dev mode is stored in .vitepress/cache/deps. However, the glob path is still ./components/global/*.vue, resulting in failure to install the expected load to the file, can it be automatically converted to like ... /.. /.. /node_modules/vitepress-theme-async/components/global/*.vue path.

image image

At present, I am using the 'import.meta.env.dev' judgment, temporary processing, but vitepress working directory is variable, can not determine the user working directory level, is there a more reasonable way to handle this?

image

Reproduction

https://stackblitz.com/edit/vite-fw9cs4?file=docs%2Fposts%2Fdemo.md

Expected behavior

import.meta.glob in dev mode, the path can be correctly converted

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700F
    Memory: 25.12 GB / 31.82 GB
  Binaries:
    Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (130.0.2849.52)
    Internet Explorer: 11.0.19041.3636

Additional context

No response

Validations

MaLuns commented 9 hours ago

The build is fine. The problem only happens in dev.