2025-07-16 22:29:28 +08:00
|
|
|
"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) {
|
2025-07-17 00:13:14 +08:00
|
|
|
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
|
|
|
|
},
|
2025-07-17 00:13:14 +08:00
|
|
|
(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
|
|
|
|
}
|
|
|
|
};
|