mirror of https://github.com/webpack/webpack.git
Compare commits
6 Commits
6a6d66f120
...
b8b334c3eb
| Author | SHA1 | Date |
|---|---|---|
|
|
b8b334c3eb | |
|
|
b6c781a0f1 | |
|
|
3c08fd105c | |
|
|
f508e8b705 | |
|
|
5c11f27b6b | |
|
|
14c813a0b3 |
|
|
@ -214,7 +214,7 @@ jobs:
|
||||||
|
|
||||||
# Install old `jest` version and deps for legacy node versions
|
# Install old `jest` version and deps for legacy node versions
|
||||||
- run: |
|
- run: |
|
||||||
yarn upgrade jest@^27.5.0 jest-circus@^27.5.0 jest-cli@^27.5.0 jest-diff@^27.5.0 jest-environment-node@^27.5.0 jest-junit@^13.0.0 @types/jest@^27.4.0 pretty-format@^27.0.2 husky@^8.0.3 lint-staged@^13.2.1 cspell@^6.31.1 open-cli@^7.2.0 coffee-loader@^1.0.0 babel-loader@^8.1.0 style-loader@^2.0.0 css-loader@^5.0.1 less-loader@^8.1.1 mini-css-extract-plugin@^1.6.1 nyc@^15.1.0 --ignore-engines
|
yarn upgrade jest@^27.5.0 jest-circus@^27.5.0 jest-cli@^27.5.0 jest-diff@^27.5.0 jest-environment-node@^27.5.0 jest-junit@^13.0.0 @types/jest@^27.4.0 pretty-format@^27.0.2 husky@^8.0.3 lint-staged@^13.2.1 cspell@^6.31.1 open-cli@^7.2.0 coffee-loader@^1.0.0 babel-loader@^8.1.0 style-loader@^2.0.0 css-loader@^5.0.1 less-loader@^8.1.1 mini-css-extract-plugin@^1.6.1 nyc@^15.1.0 memfs@4.14.0 --ignore-engines
|
||||||
yarn --frozen-lockfile --ignore-engines
|
yarn --frozen-lockfile --ignore-engines
|
||||||
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x'
|
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,59 +15,46 @@ const browserslist = require("browserslist");
|
||||||
// [[C:]/path/to/config][:env]
|
// [[C:]/path/to/config][:env]
|
||||||
const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} BrowserslistHandlerConfig
|
|
||||||
* @property {string=} configPath
|
|
||||||
* @property {string=} env
|
|
||||||
* @property {string=} query
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string | null | undefined} input input string
|
|
||||||
* @param {string} context the context directory
|
|
||||||
* @returns {BrowserslistHandlerConfig} config
|
|
||||||
*/
|
|
||||||
const parse = (input, context) => {
|
|
||||||
if (!input) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.isAbsolute(input)) {
|
|
||||||
const [, configPath, env] = inputRx.exec(input) || [];
|
|
||||||
return { configPath, env };
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = browserslist.findConfig(context);
|
|
||||||
|
|
||||||
if (config && Object.keys(config).includes(input)) {
|
|
||||||
return { env: input };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { query: input };
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string | null | undefined} input input string
|
* @param {string | null | undefined} input input string
|
||||||
* @param {string} context the context directory
|
* @param {string} context the context directory
|
||||||
* @returns {string[] | undefined} selected browsers
|
* @returns {string[] | undefined} selected browsers
|
||||||
*/
|
*/
|
||||||
const load = (input, context) => {
|
const load = (input, context) => {
|
||||||
const { configPath, env, query } = parse(input, context);
|
// browserslist:path-to-config
|
||||||
|
// browserslist:path-to-config:env
|
||||||
|
if (input && path.isAbsolute(input)) {
|
||||||
|
const [, configPath, env] = inputRx.exec(input) || [];
|
||||||
|
|
||||||
// if a query is specified, then use it, else
|
const config = browserslist.loadConfig({
|
||||||
// if a path to a config is specified then load it, else
|
config: configPath,
|
||||||
// find a nearest config
|
env
|
||||||
const config =
|
});
|
||||||
query ||
|
|
||||||
(configPath
|
|
||||||
? browserslist.loadConfig({
|
|
||||||
config: configPath,
|
|
||||||
env
|
|
||||||
})
|
|
||||||
: browserslist.loadConfig({ path: context, env }));
|
|
||||||
|
|
||||||
if (!config) return;
|
return browserslist(config, { env });
|
||||||
return browserslist(config);
|
}
|
||||||
|
|
||||||
|
const env = input || undefined;
|
||||||
|
|
||||||
|
const config = browserslist.loadConfig({
|
||||||
|
path: context,
|
||||||
|
env
|
||||||
|
});
|
||||||
|
|
||||||
|
// browserslist
|
||||||
|
// browserslist:env
|
||||||
|
if (config) {
|
||||||
|
try {
|
||||||
|
return browserslist(config, { env, throwOnMissing: true });
|
||||||
|
} catch (_err) {
|
||||||
|
// Nothing, no `env` was found in browserslist, maybe input is `queries`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// browserslist:query
|
||||||
|
if (env) {
|
||||||
|
return browserslist(env);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1326,8 +1326,13 @@ const applyOutputDefaults = (
|
||||||
if (tp.importScripts) return "array-push";
|
if (tp.importScripts) return "array-push";
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"For the selected environment is no default script chunk format available:\n" +
|
"For the selected environment is no default script chunk format available:\n" +
|
||||||
"JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
|
`${
|
||||||
`CommonJs exports can be chosen when 'require' or node builtins are available.\n${
|
tp.module
|
||||||
|
? "Module ('module') can be chosen when ES modules are available (please set 'experiments.outputModule' and 'output.module' to `true`)"
|
||||||
|
: ""
|
||||||
|
}\n` +
|
||||||
|
"JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
|
||||||
|
`CommonJs exports ('commonjs') can be chosen when 'require' or node builtins are available.\n${
|
||||||
helpMessage
|
helpMessage
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const getBrowserslistTargetHandler = memoize(() =>
|
||||||
* @returns {string} default target
|
* @returns {string} default target
|
||||||
*/
|
*/
|
||||||
const getDefaultTarget = (context) => {
|
const getDefaultTarget = (context) => {
|
||||||
const browsers = getBrowserslistTargetHandler().load(null, context);
|
const browsers = getBrowserslistTargetHandler().load(undefined, context);
|
||||||
return browsers ? "browserslist" : "web";
|
return browsers ? "browserslist" : "web";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ class ImportMetaPlugin {
|
||||||
new ModuleDependencyWarning(
|
new ModuleDependencyWarning(
|
||||||
parser.state.module,
|
parser.state.module,
|
||||||
new CriticalDependencyWarning(
|
new CriticalDependencyWarning(
|
||||||
"Accessing import.meta directly is unsupported (only property access or destructuring is supported)"
|
"'import.meta' cannot be used as a standalone expression. For static analysis, its properties must be accessed directly (e.g., 'import.meta.url') or through destructuring."
|
||||||
),
|
),
|
||||||
/** @type {DependencyLocation} */ (metaProperty.loc)
|
/** @type {DependencyLocation} */ (metaProperty.loc)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
28
package.json
28
package.json
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "webpack",
|
"name": "webpack",
|
||||||
"version": "5.101.3",
|
"version": "5.102.0",
|
||||||
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
||||||
"homepage": "https://github.com/webpack/webpack",
|
"homepage": "https://github.com/webpack/webpack",
|
||||||
"bugs": "https://github.com/webpack/webpack/issues",
|
"bugs": "https://github.com/webpack/webpack/issues",
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
"@webassemblyjs/wasm-parser": "^1.14.1",
|
"@webassemblyjs/wasm-parser": "^1.14.1",
|
||||||
"acorn": "^8.15.0",
|
"acorn": "^8.15.0",
|
||||||
"acorn-import-phases": "^1.0.3",
|
"acorn-import-phases": "^1.0.3",
|
||||||
"browserslist": "^4.24.5",
|
"browserslist": "^4.26.3",
|
||||||
"chrome-trace-event": "^1.0.2",
|
"chrome-trace-event": "^1.0.2",
|
||||||
"enhanced-resolve": "^5.17.3",
|
"enhanced-resolve": "^5.17.3",
|
||||||
"es-module-lexer": "^1.2.1",
|
"es-module-lexer": "^1.2.1",
|
||||||
|
|
@ -111,16 +111,16 @@
|
||||||
"@babel/core": "^7.27.1",
|
"@babel/core": "^7.27.1",
|
||||||
"@babel/preset-react": "^7.27.1",
|
"@babel/preset-react": "^7.27.1",
|
||||||
"@codspeed/core": "^4.0.1",
|
"@codspeed/core": "^4.0.1",
|
||||||
"@eslint/js": "^9.29.0",
|
"@eslint/js": "^9.36.0",
|
||||||
"@eslint/markdown": "^7.1.0",
|
"@eslint/markdown": "^7.3.0",
|
||||||
"@stylistic/eslint-plugin": "^5.2.2",
|
"@stylistic/eslint-plugin": "^5.4.0",
|
||||||
"@types/glob-to-regexp": "^0.4.4",
|
"@types/glob-to-regexp": "^0.4.4",
|
||||||
"@types/graceful-fs": "^4.1.9",
|
"@types/graceful-fs": "^4.1.9",
|
||||||
"@types/jest": "^30.0.0",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/mime-types": "^2.1.4",
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/node": "^24.1.0",
|
"@types/node": "^24.5.2",
|
||||||
"@types/xxhashjs": "^0.2.4",
|
"@types/xxhashjs": "^0.2.4",
|
||||||
"assemblyscript": "^0.28.5",
|
"assemblyscript": "^0.28.8",
|
||||||
"babel-loader": "^10.0.0",
|
"babel-loader": "^10.0.0",
|
||||||
"bundle-loader": "^0.5.6",
|
"bundle-loader": "^0.5.6",
|
||||||
"coffee-loader": "^5.0.0",
|
"coffee-loader": "^5.0.0",
|
||||||
|
|
@ -131,13 +131,13 @@
|
||||||
"date-fns": "^4.0.0",
|
"date-fns": "^4.0.0",
|
||||||
"es5-ext": "^0.10.53",
|
"es5-ext": "^0.10.53",
|
||||||
"es6-promise-polyfill": "^1.2.0",
|
"es6-promise-polyfill": "^1.2.0",
|
||||||
"eslint": "^9.29.0",
|
"eslint": "^9.36.0",
|
||||||
"eslint-config-prettier": "^10.1.1",
|
"eslint-config-prettier": "^10.1.1",
|
||||||
"eslint-config-webpack": "^4.5.1",
|
"eslint-config-webpack": "^4.5.1",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"eslint-plugin-jsdoc": "^51.2.3",
|
"eslint-plugin-jsdoc": "^51.2.3",
|
||||||
"eslint-plugin-n": "^17.21.0",
|
"eslint-plugin-n": "^17.23.1",
|
||||||
"eslint-plugin-prettier": "^5.5.0",
|
"eslint-plugin-prettier": "^5.5.0",
|
||||||
"eslint-plugin-unicorn": "^61.0.1",
|
"eslint-plugin-unicorn": "^61.0.1",
|
||||||
"file-loader": "^6.0.0",
|
"file-loader": "^6.0.0",
|
||||||
|
|
@ -146,11 +146,11 @@
|
||||||
"hash-wasm": "^4.9.0",
|
"hash-wasm": "^4.9.0",
|
||||||
"husky": "^9.0.11",
|
"husky": "^9.0.11",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"jest": "^30.1.2",
|
"jest": "^30.2.0",
|
||||||
"jest-circus": "^30.1.2",
|
"jest-circus": "^30.2.0",
|
||||||
"jest-cli": "^30.1.2",
|
"jest-cli": "^30.2.0",
|
||||||
"jest-diff": "^30.1.2",
|
"jest-diff": "^30.2.0",
|
||||||
"jest-environment-node": "^30.1.2",
|
"jest-environment-node": "^30.2.0",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"json-loader": "^0.5.7",
|
"json-loader": "^0.5.7",
|
||||||
"json5": "^2.1.3",
|
"json5": "^2.1.3",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
module.exports = [[/Critical dependency: Accessing import\.meta/]];
|
module.exports = [
|
||||||
|
[
|
||||||
|
/Critical dependency: 'import\.meta' cannot be used as a standalone expression\. For static analysis, its properties must be accessed directly \(e\.g\., 'import\.meta\.url'\) or through destructuring\./
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
[
|
[
|
||||||
/Accessing import.meta directly is unsupported \(only property access or destructuring is supported\)/
|
/'import\.meta' cannot be used as a standalone expression\. For static analysis, its properties must be accessed directly \(e\.g\., 'import\.meta\.url'\) or through destructuring\./
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
extends browserslist-config-mycompany
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
it("should compile and run the test", function() {});
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const rootPath = path.resolve(__dirname, "../../../../");
|
||||||
|
const rootNodeModules = path.resolve(rootPath, "./node_modules");
|
||||||
|
const browserslistPackage = path.resolve(
|
||||||
|
rootNodeModules,
|
||||||
|
"browserslist-config-mycompany"
|
||||||
|
);
|
||||||
|
const content = `
|
||||||
|
module.exports = {
|
||||||
|
development: [
|
||||||
|
'last 1 version'
|
||||||
|
],
|
||||||
|
production: [
|
||||||
|
'ie 9',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const browserslistFile = path.resolve(browserslistPackage, "./index.js");
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(browserslistPackage);
|
||||||
|
} catch (_err) {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(browserslistFile, content);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
afterExecute() {
|
||||||
|
fs.unlinkSync(browserslistFile);
|
||||||
|
fs.rmdirSync(browserslistPackage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
target: `browserslist:${path.join(__dirname, ".browserslistrc")}:production`,
|
||||||
|
plugins: [
|
||||||
|
(compiler) => {
|
||||||
|
compiler.hooks.compilation.tap("Test", (compilation) => {
|
||||||
|
expect(compilation.outputOptions.environment).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"arrowFunction": false,
|
||||||
|
"asyncFunction": false,
|
||||||
|
"bigIntLiteral": false,
|
||||||
|
"const": false,
|
||||||
|
"destructuring": false,
|
||||||
|
"document": true,
|
||||||
|
"dynamicImport": false,
|
||||||
|
"dynamicImportInWorker": false,
|
||||||
|
"forOf": false,
|
||||||
|
"globalThis": false,
|
||||||
|
"module": false,
|
||||||
|
"nodePrefixForCoreModules": false,
|
||||||
|
"optionalChaining": false,
|
||||||
|
"templateLiteral": false,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(compilation.options.externalsPresets).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"electron": false,
|
||||||
|
"electronMain": false,
|
||||||
|
"electronPreload": false,
|
||||||
|
"electronRenderer": false,
|
||||||
|
"node": false,
|
||||||
|
"nwjs": false,
|
||||||
|
"web": true,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
extends browserslist-config-mycompany1
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
it("should compile and run the test", function() {});
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const rootPath = path.resolve(__dirname, "../../../../");
|
||||||
|
const rootNodeModules = path.resolve(rootPath, "./node_modules");
|
||||||
|
const browserslistPackage = path.resolve(
|
||||||
|
rootNodeModules,
|
||||||
|
"browserslist-config-mycompany1"
|
||||||
|
);
|
||||||
|
const content = `
|
||||||
|
module.exports = {
|
||||||
|
development: [
|
||||||
|
'last 1 version'
|
||||||
|
],
|
||||||
|
// We are in tests, so 'process.env.NODE_ENV' has the 'test' value (browserslist respects the 'process.env.NODE_ENV' value)
|
||||||
|
test: [
|
||||||
|
'ie 9',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const browserslistFile = path.resolve(browserslistPackage, "./index.js");
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(browserslistPackage);
|
||||||
|
} catch (_err) {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(browserslistFile, content);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
afterExecute() {
|
||||||
|
fs.unlinkSync(browserslistFile);
|
||||||
|
fs.rmdirSync(browserslistPackage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
target: `browserslist:${path.join(__dirname, ".browserslistrc")}`,
|
||||||
|
plugins: [
|
||||||
|
(compiler) => {
|
||||||
|
compiler.hooks.compilation.tap("Test", (compilation) => {
|
||||||
|
expect(compilation.outputOptions.environment).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"arrowFunction": false,
|
||||||
|
"asyncFunction": false,
|
||||||
|
"bigIntLiteral": false,
|
||||||
|
"const": false,
|
||||||
|
"destructuring": false,
|
||||||
|
"document": true,
|
||||||
|
"dynamicImport": false,
|
||||||
|
"dynamicImportInWorker": false,
|
||||||
|
"forOf": false,
|
||||||
|
"globalThis": false,
|
||||||
|
"module": false,
|
||||||
|
"nodePrefixForCoreModules": false,
|
||||||
|
"optionalChaining": false,
|
||||||
|
"templateLiteral": false,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(compilation.options.externalsPresets).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"electron": false,
|
||||||
|
"electronMain": false,
|
||||||
|
"electronPreload": false,
|
||||||
|
"electronRenderer": false,
|
||||||
|
"node": false,
|
||||||
|
"nwjs": false,
|
||||||
|
"web": true,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
it("should compile and run the test", function() {});
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"browserslist": {
|
||||||
|
"development": [
|
||||||
|
"last 1 version"
|
||||||
|
],
|
||||||
|
"production": [
|
||||||
|
"ie 9"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
target: "browserslist:production",
|
||||||
|
plugins: [
|
||||||
|
(compiler) => {
|
||||||
|
compiler.hooks.compilation.tap("Test", (compilation) => {
|
||||||
|
expect(compilation.outputOptions.environment).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"arrowFunction": false,
|
||||||
|
"asyncFunction": false,
|
||||||
|
"bigIntLiteral": false,
|
||||||
|
"const": false,
|
||||||
|
"destructuring": false,
|
||||||
|
"document": true,
|
||||||
|
"dynamicImport": false,
|
||||||
|
"dynamicImportInWorker": false,
|
||||||
|
"forOf": false,
|
||||||
|
"globalThis": false,
|
||||||
|
"module": false,
|
||||||
|
"nodePrefixForCoreModules": false,
|
||||||
|
"optionalChaining": false,
|
||||||
|
"templateLiteral": false,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(compilation.options.externalsPresets).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"electron": false,
|
||||||
|
"electronMain": false,
|
||||||
|
"electronPreload": false,
|
||||||
|
"electronRenderer": false,
|
||||||
|
"node": false,
|
||||||
|
"nwjs": false,
|
||||||
|
"web": true,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
it("should compile and run the test", function() {});
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"browserslist": [
|
||||||
|
"extends browserslist-config-mycompany2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const rootPath = path.resolve(__dirname, "../../../../");
|
||||||
|
const rootNodeModules = path.resolve(rootPath, "./node_modules");
|
||||||
|
const browserslistPackage = path.resolve(
|
||||||
|
rootNodeModules,
|
||||||
|
"browserslist-config-mycompany2"
|
||||||
|
);
|
||||||
|
const content = `
|
||||||
|
module.exports = {
|
||||||
|
development: [
|
||||||
|
'last 1 version'
|
||||||
|
],
|
||||||
|
// We are in tests, so 'process.env.NODE_ENV' has the 'test' value (browserslist respects the 'process.env.NODE_ENV' value)
|
||||||
|
test: [
|
||||||
|
'ie 9',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const browserslistFile = path.resolve(browserslistPackage, "./index.js");
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(browserslistPackage);
|
||||||
|
} catch (_err) {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(browserslistFile, content);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
afterExecute() {
|
||||||
|
fs.unlinkSync(browserslistFile);
|
||||||
|
fs.rmdirSync(browserslistPackage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
target: "browserslist",
|
||||||
|
plugins: [
|
||||||
|
(compiler) => {
|
||||||
|
compiler.hooks.compilation.tap("Test", (compilation) => {
|
||||||
|
expect(compilation.outputOptions.environment).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"arrowFunction": false,
|
||||||
|
"asyncFunction": false,
|
||||||
|
"bigIntLiteral": false,
|
||||||
|
"const": false,
|
||||||
|
"destructuring": false,
|
||||||
|
"document": true,
|
||||||
|
"dynamicImport": false,
|
||||||
|
"dynamicImportInWorker": false,
|
||||||
|
"forOf": false,
|
||||||
|
"globalThis": false,
|
||||||
|
"module": false,
|
||||||
|
"nodePrefixForCoreModules": false,
|
||||||
|
"optionalChaining": false,
|
||||||
|
"templateLiteral": false,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(compilation.options.externalsPresets).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"electron": false,
|
||||||
|
"electronMain": false,
|
||||||
|
"electronPreload": false,
|
||||||
|
"electronRenderer": false,
|
||||||
|
"node": false,
|
||||||
|
"nwjs": false,
|
||||||
|
"web": true,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
it("should compile and run the test", function() {});
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"browserslist": {
|
||||||
|
"development": [
|
||||||
|
"last 1 version"
|
||||||
|
],
|
||||||
|
"production": [
|
||||||
|
"ie 9"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
target: "browserslist:maintained node versions",
|
||||||
|
plugins: [
|
||||||
|
(compiler) => {
|
||||||
|
compiler.hooks.compilation.tap("Test", (compilation) => {
|
||||||
|
expect(compilation.outputOptions.environment).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"arrowFunction": true,
|
||||||
|
"asyncFunction": true,
|
||||||
|
"bigIntLiteral": true,
|
||||||
|
"const": true,
|
||||||
|
"destructuring": true,
|
||||||
|
"document": false,
|
||||||
|
"dynamicImport": true,
|
||||||
|
"dynamicImportInWorker": false,
|
||||||
|
"forOf": true,
|
||||||
|
"globalThis": true,
|
||||||
|
"module": true,
|
||||||
|
"nodePrefixForCoreModules": true,
|
||||||
|
"optionalChaining": true,
|
||||||
|
"templateLiteral": true,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(compilation.options.externalsPresets).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"electron": false,
|
||||||
|
"electronMain": false,
|
||||||
|
"electronPreload": false,
|
||||||
|
"electronRenderer": false,
|
||||||
|
"node": true,
|
||||||
|
"nwjs": false,
|
||||||
|
"web": false,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue