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.webpackContext #15446
import.meta.webpackContext #15446
Conversation
For maintainers only:
|
0fd43e0
to
2764e91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best see lib/dependencies/ImportParserPlugin.js how all these options need to be handled.
705967f
to
e6f9968
Compare
e6f9968
to
b89f397
Compare
"webpack/lib/dependencies/ImportMetaContextDependency" | ||
); | ||
|
||
ImportMetaContextDependency.Template = ModuleDependencyTemplateAsRequireId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also is this correct one?
|
||
const handler = (parser, parserOptions) => { | ||
if ( | ||
parserOptions.importMetaContext !== undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option need to be added to the schema
I've created an issue to document this in webpack/webpack.js.org. |
There seems to be a bug when using it with a package const locales = import.meta.webpackContext('@/locales', {
recursive: false,
regExp: /(en|hu)\.json$/i,
});
const vuetify = import.meta.webpackContext('vuetify/lib/locale', {
recursive: false,
regExp: /(en|hu)\.js$/i,
}); First one works perfect, second one throws warning during compilation
It seems to be using the context twice |
@Tofandel Looks like yes, please open an issue, thanks |
Managed to get a minimal repro (funny enough only seems to happen with vue-cli, didn't happen with webpack-cli only) so something funny with the config is going on, so will open one |
Got it to reproduce without vue-cli Just adding this in the webpack config const path = require('path')
module.exports = {
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, './node_modules'),
]
},
} |
Also, not really a bug, but just exploring this without a doc I found that the default mode is
|
yeah, need to add a warning if not |
What kind of change does this PR introduce?
feature
closes #15372
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
import.meta.webpackContext("directory", { recursive: boolean, regExp: RegExp, mode })
returns same asrequire.context
but only forjavascript/auto
,javascript/esm