Merge pull request #14117 from webpack/feature/import-module

add importModule to loader context by default
This commit is contained in:
Tobias Koppers 2021-09-02 17:23:53 +02:00 committed by GitHub
commit 41e3136c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 637 additions and 680 deletions

View File

@ -1106,10 +1106,6 @@ export interface Experiments {
* Build http(s): urls using a lockfile and resource content cache.
*/
buildHttp?: boolean | HttpUriOptions;
/**
* Enable build-time execution of modules from the module graph for plugins and loaders.
*/
executeModule?: boolean;
/**
* Enable module and chunk layers.
*/

View File

@ -305,9 +305,7 @@ class WebpackOptionsApply extends OptionsApply {
new RequireJsStuffPlugin().apply(compiler);
}
new CommonJsPlugin().apply(compiler);
new LoaderPlugin({
enableExecuteModule: options.experiments.executeModule
}).apply(compiler);
new LoaderPlugin({}).apply(compiler);
if (options.node !== false) {
const NodeStuffPlugin = require("./NodeStuffPlugin");
new NodeStuffPlugin(options.node).apply(compiler);

View File

@ -259,7 +259,6 @@ const applyExperimentsDefaults = (experiments, { production, development }) => {
D(experiments, "asyncWebAssembly", false);
D(experiments, "outputModule", false);
D(experiments, "asset", false);
D(experiments, "executeModule", false);
D(experiments, "layers", false);
D(experiments, "lazyCompilation", false);
D(experiments, "buildHttp", false);

View File

@ -37,11 +37,9 @@ const LoaderImportDependency = require("./LoaderImportDependency");
class LoaderPlugin {
/**
* @param {Object} options options
* @param {boolean=} options.enableExecuteModule execute module enabled
*/
constructor(options = {}) {
this._enableExecuteModule = !!options.enableExecuteModule;
}
constructor(options = {}) {}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
@ -155,7 +153,6 @@ class LoaderPlugin {
);
};
if (this._enableExecuteModule) {
/**
* @param {string} request the request string to load the module from
* @param {ImportModuleOptions=} options options
@ -255,7 +252,6 @@ class LoaderPlugin {
return importModule(request, options || {}, callback);
};
}
}
);
});
}

File diff suppressed because one or more lines are too long

View File

@ -699,10 +699,6 @@
}
]
},
"executeModule": {
"description": "Enable build-time execution of modules from the module graph for plugins and loaders.",
"type": "boolean"
},
"layers": {
"description": "Enable module and chunk layers.",
"type": "boolean"

View File

@ -75,7 +75,7 @@ describe("Defaults", () => {
it("should have the correct base config", () => {
expect(baseConfig).toMatchInlineSnapshot(`
Object {
Object {
"amd": undefined,
"bail": undefined,
"cache": false,
@ -94,7 +94,6 @@ describe("Defaults", () => {
"asset": false,
"asyncWebAssembly": false,
"buildHttp": false,
"executeModule": false,
"layers": false,
"lazyCompilation": false,
"outputModule": false,
@ -614,8 +613,8 @@ describe("Defaults", () => {
"target": "web",
"watch": false,
"watchOptions": Object {},
}
`);
}
`);
});
const test = (name, options, fn, before, after) => {

View File

@ -524,19 +524,6 @@ Object {
"multiple": false,
"simpleType": "boolean",
},
"experiments-execute-module": Object {
"configs": Array [
Object {
"description": "Enable build-time execution of modules from the module graph for plugins and loaders.",
"multiple": false,
"path": "experiments.executeModule",
"type": "boolean",
},
],
"description": "Enable build-time execution of modules from the module graph for plugins and loaders.",
"multiple": false,
"simpleType": "boolean",
},
"experiments-layers": Object {
"configs": Array [
Object {

View File

@ -41,9 +41,6 @@ module.exports = {
}
]
},
experiments: {
executeModule: true
},
plugins: [
compiler =>
compiler.hooks.done.tap("test case", stats => {

View File

@ -14,9 +14,6 @@ module.exports = {
}
]
},
experiments: {
executeModule: true
},
plugins: [
compiler =>
compiler.hooks.done.tap("test case", stats => {

View File

@ -8,8 +8,5 @@ module.exports = {
type: "json"
}
]
},
experiments: {
executeModule: true
}
};

5
types.d.ts vendored
View File

@ -3282,11 +3282,6 @@ declare interface Experiments {
*/
buildHttp?: boolean | HttpUriOptions;
/**
* Enable build-time execution of modules from the module graph for plugins and loaders.
*/
executeModule?: boolean;
/**
* Enable module and chunk layers.
*/