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

Support for glob imports (import.meta.glob) #4986

Closed
chenjiahan opened this issue Dec 12, 2023 · 4 comments
Closed

Support for glob imports (import.meta.glob) #4986

chenjiahan opened this issue Dec 12, 2023 · 4 comments
Labels
feat New feature or request need documentation Create a tracking issue in rspack-website pending triage The issue/PR is currently untouched. team The issue/pr is created by the member of Rspack.

Comments

@chenjiahan
Copy link
Member

What problem does this feature solve?

Vite supports importing multiple modules from the file system via the special import.meta.glob function:

const modules = import.meta.glob('./dir/*.js')

Rspack supports dynamic import with dynamic paths, but glob imports can import a subset of matching modules more explicitly. So it would be nice if Rspack can support glob imports too.

What does the proposed API of configuration look like?

Same API as Vite provides: https://vitejs.dev/guide/features.html#glob-import

@chenjiahan chenjiahan added feat New feature or request pending triage The issue/PR is currently untouched. labels Dec 12, 2023
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Dec 12, 2023
@chenjiahan
Copy link
Member Author

@hardfist do you think it's time to beyond webpack?

@chenjiahan
Copy link
Member Author

A related issue: webpack/webpack#15833

@hardfist
Copy link
Contributor

hardfist commented Dec 12, 2023

webpack supports require.context for sync glob import

@chenjiahan
Copy link
Member Author

import.meta is part of the ECMAScript standard but require.context is a webpack-only API.

I just found webpack has supported import.meta.webpackContext and Rspack also supports it: #4466

We should document this and recommend users to use import.meta.webpackContext instead of require.context.

@hardfist hardfist added the need documentation Create a tracking issue in rspack-website label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request need documentation Create a tracking issue in rspack-website pending triage The issue/PR is currently untouched. team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

2 participants