2025-07-16 22:29:28 +08:00
|
|
|
"use strict";
|
|
|
|
|
2019-05-21 04:53:58 +08:00
|
|
|
const path = require("path");
|
2020-02-26 18:00:47 +08:00
|
|
|
const webpack = require("../../../../");
|
2025-04-06 22:53:09 +08:00
|
|
|
const supportsAsync = require("../../../helpers/supportsAsync");
|
2025-03-12 09:56:14 +08:00
|
|
|
|
2025-04-16 22:04:11 +08:00
|
|
|
/** @type {(env: Env, options: TestOptions) => import("../../../../").Configuration[]} */
|
2020-06-02 17:55:59 +08:00
|
|
|
module.exports = (env, { testPath }) => [
|
2025-04-06 22:53:09 +08:00
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "modern-module",
|
|
|
|
filename: "modern-module.js",
|
|
|
|
library: {
|
|
|
|
type: "modern-module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2021-06-23 19:58:40 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "esm",
|
2021-06-23 19:58:40 +08:00
|
|
|
filename: "esm.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
2021-06-23 19:58:40 +08:00
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-04-17 08:54:31 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./esm-with-commonjs.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-with-commonjs",
|
|
|
|
filename: "esm-with-commonjs.js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-06-23 19:58:40 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2025-08-04 23:50:05 +08:00
|
|
|
{
|
|
|
|
entry: "./esm-with-commonjs.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-with-commonjs",
|
|
|
|
filename: "esm-with-commonjs-avoid-entry-iife.js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
avoidEntryIife: false
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2024-04-07 20:38:09 +08:00
|
|
|
{
|
|
|
|
output: {
|
2025-04-06 22:53:09 +08:00
|
|
|
uniqueName: "esm-export",
|
|
|
|
filename: "esm-export.js",
|
|
|
|
library: {
|
|
|
|
type: "module",
|
|
|
|
export: ["a"]
|
|
|
|
}
|
2024-04-07 20:38:09 +08:00
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2024-04-07 20:38:09 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2025-04-06 22:53:09 +08:00
|
|
|
...(supportsAsync()
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
entry: "./index-async.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-async",
|
|
|
|
filename: "esm-async.js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: true
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./index-async.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-async-no-concatenate-modules",
|
|
|
|
filename: "esm-async-no-concatenate-modules.js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
: []),
|
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-export-no-concatenate-modules",
|
|
|
|
filename: "esm-export-no-concatenate-modules.js",
|
|
|
|
library: {
|
|
|
|
type: "module",
|
|
|
|
export: ["a"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2021-07-08 15:13:42 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "esm-runtimeChunk",
|
2021-07-08 15:13:42 +08:00
|
|
|
filename: "esm-runtimeChunk/[name].js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
2021-07-08 15:13:42 +08:00
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-07-08 15:13:42 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2025-04-06 22:53:09 +08:00
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-runtimeChunk-concatenateModules",
|
|
|
|
filename: "esm-runtimeChunk-concatenateModules/[name].js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single",
|
|
|
|
concatenateModules: true
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-runtimeChunk-no-concatenateModules",
|
|
|
|
filename: "esm-runtimeChunk-no-concatenateModules/[name].js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single",
|
|
|
|
concatenateModules: false
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-runtimeChunk-concatenateModules-splitChunks",
|
|
|
|
filename: "esm-runtimeChunk-concatenateModules-splitChunks/[name].js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single",
|
|
|
|
concatenateModules: true,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
module: {
|
|
|
|
test: /a\.js$/,
|
|
|
|
chunks: "all",
|
|
|
|
enforce: true,
|
|
|
|
reuseExistingChunk: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2025-05-17 01:23:34 +08:00
|
|
|
{
|
|
|
|
entry: ["./foo.js", "./index.js"],
|
|
|
|
output: {
|
|
|
|
uniqueName: "esm-multiple-entry-modules",
|
|
|
|
filename: "esm-multiple-entry-modules.js",
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: "node14",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
2017-06-02 20:22:42 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs",
|
2017-06-02 20:22:42 +08:00
|
|
|
filename: "commonjs.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs-iife",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "commonjs-iife.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "amd",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "amd.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "amd"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "amd-iife",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "amd-iife.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "amd"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: true
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2017-06-02 20:22:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-04-19 19:04:04 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "amd-runtimeChunk",
|
2021-04-19 19:04:04 +08:00
|
|
|
filename: "amd-runtimeChunk/[name].js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "amd"
|
|
|
|
},
|
2021-04-22 15:46:30 +08:00
|
|
|
globalObject: "global",
|
2021-04-19 19:04:04 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
target: "web",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-04-19 19:04:04 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "amd-iife-runtimeChunk",
|
2021-04-19 19:04:04 +08:00
|
|
|
filename: "amd-iife-runtimeChunk/[name].js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "amd"
|
|
|
|
},
|
2021-04-22 15:46:30 +08:00
|
|
|
globalObject: "global",
|
2021-04-19 19:04:04 +08:00
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
target: "web",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-04-19 19:04:04 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
2017-06-02 20:22:42 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "umd",
|
2017-06-02 20:22:42 +08:00
|
|
|
filename: "umd.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "umd"
|
|
|
|
}
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2017-06-02 20:22:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-11-20 23:35:15 +08:00
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "true-iife-umd",
|
|
|
|
filename: "true-iife-umd.js",
|
|
|
|
library: {
|
|
|
|
type: "umd"
|
|
|
|
},
|
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2024-11-20 23:35:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-11-03 22:54:46 +08:00
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "false-iife-umd",
|
|
|
|
filename: "false-iife-umd.js",
|
|
|
|
library: {
|
|
|
|
type: "umd"
|
|
|
|
},
|
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2024-11-03 22:54:46 +08:00
|
|
|
}
|
|
|
|
},
|
2025-07-17 00:13:14 +08:00
|
|
|
ignoreWarnings: [(error) => error.name === "FalseIIFEUmdWarning"]
|
2024-11-03 22:54:46 +08:00
|
|
|
},
|
2024-11-07 12:22:02 +08:00
|
|
|
{
|
|
|
|
output: {
|
2024-11-20 23:35:15 +08:00
|
|
|
uniqueName: "false-iife-umd2",
|
|
|
|
filename: "false-iife-umd2.js",
|
2024-11-07 12:22:02 +08:00
|
|
|
library: {
|
2024-11-20 23:35:15 +08:00
|
|
|
type: "umd2"
|
2024-11-07 12:22:02 +08:00
|
|
|
},
|
2024-11-20 23:35:15 +08:00
|
|
|
iife: false
|
2024-11-07 12:22:02 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2024-11-07 12:22:02 +08:00
|
|
|
}
|
2024-11-20 23:35:15 +08:00
|
|
|
},
|
2025-07-17 00:13:14 +08:00
|
|
|
ignoreWarnings: [(error) => error.name === "FalseIIFEUmdWarning"]
|
2024-11-07 12:22:02 +08:00
|
|
|
},
|
2017-06-02 20:52:41 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "umd-default",
|
2017-06-02 20:52:41 +08:00
|
|
|
filename: "umd-default.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "umd",
|
|
|
|
export: "default"
|
|
|
|
}
|
2017-06-02 20:52:41 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2017-06-02 20:52:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-06-02 20:22:42 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "this",
|
2017-06-02 20:22:42 +08:00
|
|
|
filename: "this.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "this"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "this-iife",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "this-iife.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "this"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: true
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2017-06-02 20:22:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "var",
|
2020-02-26 18:00:47 +08:00
|
|
|
filename: "var.js",
|
2021-02-11 02:14:50 +08:00
|
|
|
library: ["globalName", "x", "y"],
|
|
|
|
iife: false
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2017-06-02 20:22:42 +08:00
|
|
|
}
|
2020-02-26 18:00:47 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.BannerPlugin({
|
|
|
|
raw: true,
|
|
|
|
banner: "module.exports = () => globalName;\n"
|
|
|
|
})
|
|
|
|
]
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "var-iife",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "var-iife.js",
|
|
|
|
library: ["globalName", "x", "y"],
|
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.BannerPlugin({
|
|
|
|
raw: true,
|
|
|
|
banner: "module.exports = () => globalName;\n"
|
|
|
|
})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./nested.js",
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs-nested",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "commonjs-nested.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs",
|
|
|
|
export: "NS"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./nested.js",
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs-nested-iife",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "commonjs-nested-iife.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs",
|
|
|
|
export: "NS"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-11 02:14:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-06-02 20:22:42 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-external",
|
2017-06-02 20:22:42 +08:00
|
|
|
filename: "commonjs2-external.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2021-02-11 02:14:50 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-external-no-concat",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "commonjs2-external-no-concat.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: false
|
|
|
|
},
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2021-02-11 02:14:50 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-iife-external",
|
2021-02-11 02:14:50 +08:00
|
|
|
filename: "commonjs2-iife-external.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
},
|
2021-02-11 02:14:50 +08:00
|
|
|
iife: true
|
2017-06-02 20:22:42 +08:00
|
|
|
},
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2019-05-21 04:53:58 +08:00
|
|
|
},
|
2021-01-04 22:30:11 +08:00
|
|
|
{
|
|
|
|
mode: "development",
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-external-eval",
|
2021-01-04 22:30:11 +08:00
|
|
|
filename: "commonjs2-external-eval.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
}
|
2021-01-04 22:30:11 +08:00
|
|
|
},
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2021-01-04 22:30:11 +08:00
|
|
|
},
|
2021-01-04 22:36:30 +08:00
|
|
|
{
|
|
|
|
mode: "development",
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-external-eval-source-map",
|
2021-01-04 22:36:30 +08:00
|
|
|
filename: "commonjs2-external-eval-source-map.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
}
|
2021-01-04 22:36:30 +08:00
|
|
|
},
|
|
|
|
devtool: "eval-source-map",
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2021-01-04 22:36:30 +08:00
|
|
|
},
|
2022-01-10 21:33:34 +08:00
|
|
|
{
|
|
|
|
output: {
|
|
|
|
uniqueName: "commonjs-static-external",
|
|
|
|
filename: "commonjs-static-external.js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs-static"
|
|
|
|
},
|
2022-01-10 21:33:34 +08:00
|
|
|
iife: false
|
|
|
|
},
|
2025-03-11 14:18:11 +08:00
|
|
|
externals: ["external", "external-named"]
|
2022-01-10 21:33:34 +08:00
|
|
|
},
|
2019-05-21 04:53:58 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "index",
|
2019-05-21 04:53:58 +08:00
|
|
|
filename: "index.js",
|
2020-06-02 17:55:59 +08:00
|
|
|
path: path.resolve(testPath, "commonjs2-split-chunks"),
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
}
|
2019-05-21 04:53:58 +08:00
|
|
|
},
|
|
|
|
target: "node",
|
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
test: {
|
|
|
|
enforce: true,
|
|
|
|
chunks: "all",
|
|
|
|
test: /a\.js$/,
|
|
|
|
filename: "part.js"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2019-05-21 04:53:58 +08:00
|
|
|
}
|
|
|
|
}
|
2020-02-26 19:34:57 +08:00
|
|
|
},
|
2021-02-18 22:49:43 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-runtimeChunk",
|
2021-02-18 22:49:43 +08:00
|
|
|
filename: "commonjs2-runtimeChunk/[name].js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
},
|
2021-02-18 22:49:43 +08:00
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-18 22:49:43 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs2-iife-runtimeChunk",
|
2021-02-18 22:49:43 +08:00
|
|
|
filename: "commonjs2-iife-runtimeChunk/[name].js",
|
2025-04-06 22:53:09 +08:00
|
|
|
library: {
|
|
|
|
type: "commonjs2"
|
|
|
|
},
|
2021-02-18 22:49:43 +08:00
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-02-18 22:49:43 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
2021-03-09 03:18:49 +08:00
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "global-runtimeChunk",
|
2021-03-09 03:18:49 +08:00
|
|
|
filename: "global-runtimeChunk/[name].js",
|
|
|
|
library: ["globalName", "x", "y"],
|
|
|
|
libraryTarget: "global",
|
|
|
|
iife: false
|
|
|
|
},
|
|
|
|
target: "web",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-03-09 03:18:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
output: {
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "global-iife-runtimeChunk",
|
2021-03-09 03:18:49 +08:00
|
|
|
filename: "global-iife-runtimeChunk/[name].js",
|
|
|
|
library: ["globalName", "x", "y"],
|
|
|
|
libraryTarget: "global",
|
|
|
|
iife: true
|
|
|
|
},
|
|
|
|
target: "web",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2021-03-09 03:18:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: "single"
|
|
|
|
}
|
|
|
|
},
|
2020-02-26 19:34:57 +08:00
|
|
|
{
|
|
|
|
entry: {
|
|
|
|
entryA: {
|
|
|
|
import: "./index"
|
|
|
|
},
|
|
|
|
entryB: {
|
|
|
|
import: "./index",
|
|
|
|
library: {
|
|
|
|
type: "umd",
|
|
|
|
name: "umd"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
entryC: {
|
|
|
|
import: "./index",
|
|
|
|
library: {
|
|
|
|
type: "amd"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
library: {
|
|
|
|
type: "commonjs-module"
|
|
|
|
},
|
2021-08-16 15:43:50 +08:00
|
|
|
uniqueName: "commonjs-module",
|
2020-02-26 19:34:57 +08:00
|
|
|
filename: "[name].js"
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2025-03-11 14:18:11 +08:00
|
|
|
external: "./non-external",
|
|
|
|
"external-named": "./non-external-named"
|
2020-02-26 19:34:57 +08:00
|
|
|
}
|
|
|
|
}
|
2025-08-11 19:55:26 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./class-commonjs",
|
|
|
|
output: {
|
2025-08-13 03:14:02 +08:00
|
|
|
uniqueName: "class-commonjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-1.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./exports-shortcut-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "exports-shortcut-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-2.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./overrides-exports-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "overrides-exports-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-3.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./self-reference-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "self-reference-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-4.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./adding-exports-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "adding-exports-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-5.mjs",
|
2025-08-11 19:55:26 +08:00
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
2025-09-01 20:25:54 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./define-module-property-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "define-module-property-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-6.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./reexport-define-module-property-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "reexport-define-module-property-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-7.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
2025-09-02 01:16:34 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./define-this-exports-cjs",
|
|
|
|
output: {
|
|
|
|
uniqueName: "define-this-exports-cjs",
|
|
|
|
filename: "commonjs-bundle-to-esm-8.mjs",
|
|
|
|
module: true,
|
|
|
|
library: {
|
|
|
|
type: "module"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
experiments: {
|
|
|
|
outputModule: true
|
|
|
|
}
|
2025-10-07 04:44:25 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./esm.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "system-esm",
|
|
|
|
filename: "system-esm.js",
|
|
|
|
library: {
|
|
|
|
type: "system"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: "./commonjs.js",
|
|
|
|
output: {
|
|
|
|
uniqueName: "system-commonjs",
|
|
|
|
filename: "system-commonjs.js",
|
|
|
|
library: {
|
|
|
|
type: "system"
|
|
|
|
}
|
|
|
|
}
|
2016-09-09 04:26:28 +08:00
|
|
|
}
|
2017-06-02 20:22:42 +08:00
|
|
|
];
|