mirror of https://github.com/webpack/webpack.git
fix(css): no extra runtime for node target
This commit is contained in:
parent
644d8170a0
commit
e66f14fa1f
|
@ -509,16 +509,41 @@ class CssModulesPlugin {
|
|||
.tap(PLUGIN_NAME, handler);
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.ensureChunkHandlers)
|
||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
||||
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
m =>
|
||||
m.type === CSS_MODULE_TYPE ||
|
||||
m.type === CSS_MODULE_TYPE_GLOBAL ||
|
||||
m.type === CSS_MODULE_TYPE_MODULE ||
|
||||
m.type === CSS_MODULE_TYPE_AUTO
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
set.add(RuntimeGlobals.hasOwnProperty);
|
||||
set.add(RuntimeGlobals.publicPath);
|
||||
set.add(RuntimeGlobals.getChunkCssFilename);
|
||||
});
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
||||
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
m =>
|
||||
m.type === CSS_MODULE_TYPE ||
|
||||
m.type === CSS_MODULE_TYPE_GLOBAL ||
|
||||
m.type === CSS_MODULE_TYPE_MODULE ||
|
||||
m.type === CSS_MODULE_TYPE_AUTO
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
set.add(RuntimeGlobals.publicPath);
|
||||
set.add(RuntimeGlobals.getChunkCssFilename);
|
||||
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
||||
|
|
|
@ -90,9 +90,10 @@ class ReadFileCompileAsyncWasmPlugin {
|
|||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.instantiateWasm)
|
||||
.tap("ReadFileCompileAsyncWasmPlugin", (chunk, set) => {
|
||||
.tap(
|
||||
"ReadFileCompileAsyncWasmPlugin",
|
||||
(chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
|
@ -109,7 +110,8 @@ class ReadFileCompileAsyncWasmPlugin {
|
|||
supportsStreaming: false
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -81,9 +81,8 @@ class ReadFileCompileWasmPlugin {
|
|||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.ensureChunkHandlers)
|
||||
.tap("ReadFileCompileWasmPlugin", (chunk, set) => {
|
||||
.tap("ReadFileCompileWasmPlugin", (chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
|
|
|
@ -44,9 +44,8 @@ class FetchCompileAsyncWasmPlugin {
|
|||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.instantiateWasm)
|
||||
.tap("FetchCompileAsyncWasmPlugin", (chunk, set) => {
|
||||
.tap("FetchCompileAsyncWasmPlugin", (chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
|
|
|
@ -58,9 +58,8 @@ class FetchCompileWasmPlugin {
|
|||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.ensureChunkHandlers)
|
||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
||||
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
||||
if (!isEnabledForChunk(chunk)) return;
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
if (
|
||||
!chunkGraph.hasModuleInGraph(
|
||||
chunk,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
it("should allow to dynamic import a css module", done => {
|
||||
import("../exports/style.module.css").then(x => {
|
||||
try {
|
||||
expect(x).toEqual(
|
||||
nsObj({
|
||||
a: "a",
|
||||
abc: "a b c",
|
||||
comments: "abc def",
|
||||
"white space": "abc\n\tdef",
|
||||
default: "default"
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
it("should allow to dynamic import a pure css", done => {
|
||||
import("./style.css").then(x => {
|
||||
expect(Object.keys(x).length).toBe(0)
|
||||
done();
|
||||
}, done);
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
.class {
|
||||
color: red;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
target: "node",
|
||||
mode: "development",
|
||||
experiments: {
|
||||
css: true
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue