mirror of https://github.com/webpack/webpack.git
Reuse VM context across webpack magic comments
This commit is contained in:
parent
b9fb99c63c
commit
fbf92fe522
|
|
@ -435,6 +435,10 @@ class JavascriptParser extends Parser {
|
|||
/** @type {WeakMap<Expression, Set<string>> | undefined} */
|
||||
this.destructuringAssignmentProperties = undefined;
|
||||
this.currentTagData = undefined;
|
||||
this.magicCommentContext = vm.createContext(undefined, {
|
||||
name: "Webpack Magic Comment Parser",
|
||||
codeGeneration: { strings: false, wasm: false }
|
||||
});
|
||||
this._initializeEvaluating();
|
||||
}
|
||||
|
||||
|
|
@ -4465,7 +4469,10 @@ class JavascriptParser extends Parser {
|
|||
// try compile only if webpack options comment is present
|
||||
try {
|
||||
for (let [key, val] of Object.entries(
|
||||
vm.runInNewContext(`(function(){return {${value}};})()`)
|
||||
vm.runInContext(
|
||||
`(function(){return {${value}};})()`,
|
||||
this.magicCommentContext
|
||||
)
|
||||
)) {
|
||||
if (typeof val === "object" && val !== null) {
|
||||
if (val.constructor.name === "RegExp") val = new RegExp(val);
|
||||
|
|
|
|||
Loading…
Reference in New Issue