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

import.meta.glob() not processed if living in node_modules/ #2390

Closed
3 tasks done
brillout opened this issue Mar 5, 2021 · 3 comments · Fixed by #2519
Closed
3 tasks done

import.meta.glob() not processed if living in node_modules/ #2390

brillout opened this issue Mar 5, 2021 · 3 comments · Fixed by #2519
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@brillout
Copy link
Contributor

brillout commented Mar 5, 2021

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

In the context of vite-plugin-ssr (or any SSR framework such as Nuxt), import.meta.glob() is called by SSR framework source code instead of being called by user-land source code. Consequently the file calling import.meta.glob() lives inside node_modules/.

Because of the following, import.meta.glob() is not processed.

// vite/src/node/plugins/importAnalysisBuild.ts

    async transform(source, importer) {
      if (importer.includes('node_modules')) {
        // The `import.meta.glob()` living inside the SSR framework source code is not processed
        return
      }

      // `import.meta.glob` gets transformed here
    }

Reproduction

npm init vite-plugin-ssr
cd vite-ssr-project/
npm run build

The generated bundles at dist/ will miss all the import.meta.glob() imports.

If vite-plugin-ssr is ln -s'd then everything works as expect because node_modules is not contained in the path anymore.

I can provide a minimal repro if needed.

System Info

  • vite version: 2.0.5
  • Operating System: N/A
  • Node version: N/A
  • Package manager (npm/yarn/pnpm) and version: N/A

Logs (Optional if provided reproduction)

N/A

@ygj6
Copy link
Member

ygj6 commented Mar 8, 2021

https://vitejs.dev/guide/features.html#glob-import

Globbing from dependencies is not supported.

It seems that the globbing from node_modules import is not supported in document.

@brillout
Copy link
Contributor Author

brillout commented Mar 8, 2021

@ygj6 I guess it's a feature request then :-).

This is a necessary feature to be able to build a framework like Nuxt on top of Vite.

brillout added a commit to brillout/vite that referenced this issue Mar 15, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to vikejs/vike that referenced this issue Mar 15, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 17, 2021
@brillout
Copy link
Contributor Author

brillout commented Mar 18, 2021

https://github.com/brillout/vite-fix-2390 if you need the fix before #2519 is merged & published. I'm using it for vite-plugin-ssr.

@Shinigami92 Shinigami92 added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) and removed pending triage labels Mar 22, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 27, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 27, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 27, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 27, 2021
brillout added a commit to brillout/vite that referenced this issue Mar 28, 2021
brillout added a commit to brillout/vite that referenced this issue Apr 11, 2021
brillout added a commit to brillout/vite that referenced this issue Apr 11, 2021
brillout added a commit to brillout/vite that referenced this issue Apr 11, 2021
brillout added a commit to brillout/vite that referenced this issue Apr 11, 2021
brillout added a commit to brillout/vite that referenced this issue Apr 23, 2021
brillout added a commit to brillout/vite that referenced this issue May 4, 2021
brillout added a commit to brillout/vite that referenced this issue May 19, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants