Skip to content

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

Open
@MaLuns

Description

@MaLuns

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions