webpack/test/configCases/web/prefetch-preload-module-onl.../webpack.config.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
2024-10-04 02:15:31 +08:00
const RuntimeGlobals = require("../../../../lib/RuntimeGlobals");
2024-10-04 02:19:37 +08:00
/** @type {import("../../../../").Configuration} */
2024-10-04 02:09:20 +08:00
module.exports = {
entry: "./index.mjs",
experiments: {
outputModule: true,
css: true
},
name: "esm",
target: "web",
output: {
publicPath: "",
module: true,
filename: "bundle0.mjs",
chunkFilename: "[name].mjs",
2024-10-04 02:15:31 +08:00
chunkFormat: "module",
crossOriginLoading: "anonymous"
2024-10-04 02:09:20 +08:00
},
plugins: [
{
apply(compiler) {
compiler.hooks.compilation.tap("Test", (compilation) => {
2024-10-04 02:09:20 +08:00
compilation.hooks.processAssets.tap(
{
name: "Test",
stage:
compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
},
(assets) => {
2024-10-04 02:09:20 +08:00
if (
assets["bundle0.mjs"]
.source()
2024-10-04 02:15:31 +08:00
.includes(`${RuntimeGlobals.preloadChunkHandlers}.s`)
2024-10-04 02:09:20 +08:00
) {
throw new Error(
"Unexpected appearance of the 'modulepreload' preload runtime."
);
}
if (
assets["bundle0.mjs"]
.source()
2024-10-04 02:15:31 +08:00
.includes(`${RuntimeGlobals.prefetchChunkHandlers}.s`)
2024-10-04 02:09:20 +08:00
) {
throw new Error(
"Unexpected appearance of the 'script' prefetch runtime."
);
}
}
);
});
}
}
],
performance: {
hints: false
},
optimization: {
minimize: false
}
};