mirror of https://github.com/webpack/webpack.git
Compare commits
9 Commits
a6e339ff23
...
68c4ea8115
Author | SHA1 | Date |
---|---|---|
|
68c4ea8115 | |
|
b6c781a0f1 | |
|
3c08fd105c | |
|
f508e8b705 | |
|
5c11f27b6b | |
|
14c813a0b3 | |
|
761b153060 | |
|
8c0fa9e9dc | |
|
faaa69dac1 |
|
@ -0,0 +1,20 @@
|
|||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
github-releases-to-discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: GitHub Releases to Discord
|
||||
uses: SethCohen/github-releases-to-discord@v1
|
||||
with:
|
||||
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
||||
color: "2105893"
|
||||
username: "webpack Release Changelog"
|
||||
avatar_url: "https://github.com/webpack/media/blob/90b54d02fa1cfc8aa864a8322202f74ac000f5d2/logo/icon.png"
|
||||
content: "||@everyone||"
|
||||
footer_title: "Changelog"
|
||||
reduce_headings: true
|
|
@ -214,7 +214,7 @@ jobs:
|
|||
|
||||
# Install old `jest` version and deps for legacy node versions
|
||||
- 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
|
||||
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x'
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ export type Rules = Rule[] | Rule;
|
|||
/**
|
||||
* Filtering rule as regex or string.
|
||||
*/
|
||||
export type Rule = RegExp | string;
|
||||
export type Rule = RegExp | string | ((str: string) => boolean);
|
||||
|
||||
export interface BannerPluginOptions {
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ export type Rules = Rule[] | Rule;
|
|||
/**
|
||||
* Include source maps for modules based on their extension (defaults to .js and .css).
|
||||
*/
|
||||
export type Rule = RegExp | string;
|
||||
export type Rule = RegExp | string | ((str: string) => boolean);
|
||||
|
||||
export interface SourceMapDevToolPluginOptions {
|
||||
/**
|
||||
|
|
|
@ -38,15 +38,7 @@ class LoaderOptionsPlugin {
|
|||
// If no options are set then generate empty options object
|
||||
if (typeof options !== "object") options = {};
|
||||
if (!options.test) {
|
||||
/** @type {Partial<RegExp>} */
|
||||
const defaultTrueMockRegExp = {
|
||||
test: () => true
|
||||
};
|
||||
|
||||
/** @type {RegExp} */
|
||||
options.test =
|
||||
/** @type {RegExp} */
|
||||
(defaultTrueMockRegExp);
|
||||
options.test = () => true;
|
||||
}
|
||||
this.options = options;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const memoize = require("./util/memoize");
|
|||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
|
||||
/** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
|
||||
/** @typedef {string | RegExp | ((str: string) => boolean) | (string | RegExp | ((str: string) => boolean))[]} Matcher */
|
||||
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
||||
|
||||
const ModuleFilenameHelpers = module.exports;
|
||||
|
@ -334,13 +334,15 @@ ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => {
|
|||
*/
|
||||
const matchPart = (str, test) => {
|
||||
if (!test) return true;
|
||||
if (Array.isArray(test)) {
|
||||
return test.some((test) => matchPart(str, test));
|
||||
}
|
||||
if (typeof test === "string") {
|
||||
if (test instanceof RegExp) {
|
||||
return test.test(str);
|
||||
} else if (typeof test === "string") {
|
||||
return str.startsWith(test);
|
||||
} else if (typeof test === "function") {
|
||||
return test(str);
|
||||
}
|
||||
return test.test(str);
|
||||
|
||||
return test.some((test) => matchPart(str, test));
|
||||
};
|
||||
|
||||
ModuleFilenameHelpers.matchPart = matchPart;
|
||||
|
|
|
@ -15,59 +15,46 @@ const browserslist = require("browserslist");
|
|||
// [[C:]/path/to/config][:env]
|
||||
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} context the context directory
|
||||
* @returns {string[] | undefined} selected browsers
|
||||
*/
|
||||
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
|
||||
// if a path to a config is specified then load it, else
|
||||
// find a nearest config
|
||||
const config =
|
||||
query ||
|
||||
(configPath
|
||||
? browserslist.loadConfig({
|
||||
config: configPath,
|
||||
env
|
||||
})
|
||||
: browserslist.loadConfig({ path: context, env }));
|
||||
const config = browserslist.loadConfig({
|
||||
config: configPath,
|
||||
env
|
||||
});
|
||||
|
||||
if (!config) return;
|
||||
return browserslist(config);
|
||||
return browserslist(config, { env });
|
||||
}
|
||||
|
||||
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";
|
||||
throw new Error(
|
||||
"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
|
||||
}`
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ const getBrowserslistTargetHandler = memoize(() =>
|
|||
* @returns {string} default target
|
||||
*/
|
||||
const getDefaultTarget = (context) => {
|
||||
const browsers = getBrowserslistTargetHandler().load(null, context);
|
||||
const browsers = getBrowserslistTargetHandler().load(undefined, context);
|
||||
return browsers ? "browserslist" : "web";
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ const {
|
|||
const { getTrimmedIdsAndRange } = require("../util/chainedImports");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const propertyAccess = require("../util/propertyAccess");
|
||||
const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
|
||||
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
|
@ -194,10 +195,16 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|||
*/
|
||||
_getReferencedExportsInDestructuring(ids) {
|
||||
if (this.referencedPropertiesInDestructuring) {
|
||||
/** @type {RawReferencedExports} */
|
||||
const refsInDestructuring = [];
|
||||
traverseDestructuringAssignmentProperties(
|
||||
this.referencedPropertiesInDestructuring,
|
||||
(stack) => refsInDestructuring.push(stack.map((p) => p.id))
|
||||
);
|
||||
/** @type {RawReferencedExports} */
|
||||
const refs = [];
|
||||
for (const { id } of this.referencedPropertiesInDestructuring) {
|
||||
refs.push(ids ? [...ids, id] : [id]);
|
||||
for (const idsInDestructuring of refsInDestructuring) {
|
||||
refs.push(ids ? [...ids, ...idsInDestructuring] : idsInDestructuring);
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
@ -374,13 +381,23 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|||
}
|
||||
}
|
||||
|
||||
for (const {
|
||||
id,
|
||||
shorthand,
|
||||
range
|
||||
} of dep.referencedPropertiesInDestructuring) {
|
||||
/** @type {{ ids: Ids, range: Range, shorthand: boolean | string }[]} */
|
||||
const replacementsInDestructuring = [];
|
||||
traverseDestructuringAssignmentProperties(
|
||||
dep.referencedPropertiesInDestructuring,
|
||||
undefined,
|
||||
(stack) => {
|
||||
const property = stack[stack.length - 1];
|
||||
replacementsInDestructuring.push({
|
||||
ids: stack.map((p) => p.id),
|
||||
range: property.range,
|
||||
shorthand: property.shorthand
|
||||
});
|
||||
}
|
||||
);
|
||||
for (const { ids, shorthand, range } of replacementsInDestructuring) {
|
||||
/** @type {Ids} */
|
||||
const concatedIds = [...prefixedIds, id];
|
||||
const concatedIds = [...prefixedIds, ...ids];
|
||||
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
||||
const used = moduleGraph
|
||||
.getExportsInfo(module)
|
||||
|
@ -393,10 +410,8 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|||
const comment = `${Template.toNormalComment(name)} `;
|
||||
const key = comment + JSON.stringify(newName);
|
||||
source.replace(
|
||||
/** @type {Range} */
|
||||
(range)[0],
|
||||
/** @type {Range} */
|
||||
(range)[1] - 1,
|
||||
range[0],
|
||||
range[1] - 1,
|
||||
shorthand ? `${key}: ${name}` : `${key}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class ImportMetaPlugin {
|
|||
new ModuleDependencyWarning(
|
||||
parser.state.module,
|
||||
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)
|
||||
)
|
||||
|
|
|
@ -12,6 +12,7 @@ const {
|
|||
VariableInfo,
|
||||
getImportAttributes
|
||||
} = require("../javascript/JavascriptParser");
|
||||
const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
|
||||
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
|
||||
const ImportContextDependency = require("./ImportContextDependency");
|
||||
const ImportDependency = require("./ImportDependency");
|
||||
|
@ -126,9 +127,13 @@ function walkImportThenFulfilledCallback(
|
|||
const references = /** @type {RawReferencedExports} */ (
|
||||
state.get(importCall)
|
||||
);
|
||||
for (const ids of exportsFromEnumerable(
|
||||
[...referencedPropertiesInDestructuring].map(({ id }) => id)
|
||||
)) {
|
||||
/** @type {RawReferencedExports} */
|
||||
const refsInDestructuring = [];
|
||||
traverseDestructuringAssignmentProperties(
|
||||
referencedPropertiesInDestructuring,
|
||||
(stack) => refsInDestructuring.push(stack.map((p) => p.id))
|
||||
);
|
||||
for (const ids of refsInDestructuring) {
|
||||
references.push(ids);
|
||||
}
|
||||
}
|
||||
|
@ -214,9 +219,13 @@ class ImportParserPlugin {
|
|||
const referencedPropertiesInDestructuring =
|
||||
parser.destructuringAssignmentPropertiesFor(expr);
|
||||
if (referencedPropertiesInDestructuring) {
|
||||
for (const ids of exportsFromEnumerable(
|
||||
[...referencedPropertiesInDestructuring].map(({ id }) => id)
|
||||
)) {
|
||||
/** @type {RawReferencedExports} */
|
||||
const refsInDestructuring = [];
|
||||
traverseDestructuringAssignmentProperties(
|
||||
referencedPropertiesInDestructuring,
|
||||
(stack) => refsInDestructuring.push(stack.map((p) => p.id))
|
||||
);
|
||||
for (const ids of refsInDestructuring) {
|
||||
settings.references.push(ids);
|
||||
}
|
||||
} else {
|
||||
|
@ -497,9 +506,14 @@ class ImportParserPlugin {
|
|||
}
|
||||
|
||||
if (referencedPropertiesInDestructuring) {
|
||||
exports = exportsFromEnumerable(
|
||||
[...referencedPropertiesInDestructuring].map(({ id }) => id)
|
||||
/** @type {RawReferencedExports} */
|
||||
const refsInDestructuring = [];
|
||||
traverseDestructuringAssignmentProperties(
|
||||
referencedPropertiesInDestructuring,
|
||||
(stack) => refsInDestructuring.push(stack.map((p) => p.id))
|
||||
);
|
||||
|
||||
exports = refsInDestructuring;
|
||||
} else if (referencedPropertiesInMember) {
|
||||
exports = referencedPropertiesInMember;
|
||||
} else {
|
||||
|
|
|
@ -342,7 +342,8 @@ const SCOPE_INFO_TERMINATED_THROW = 2;
|
|||
/**
|
||||
* @typedef {object} DestructuringAssignmentProperty
|
||||
* @property {string} id
|
||||
* @property {Range | undefined=} range
|
||||
* @property {Range} range
|
||||
* @property {Set<DestructuringAssignmentProperty> | undefined=} pattern
|
||||
* @property {boolean | string} shorthand
|
||||
*/
|
||||
|
||||
|
@ -2993,18 +2994,32 @@ class JavascriptParser extends Parser {
|
|||
}
|
||||
const key = property.key;
|
||||
if (key.type === "Identifier" && !property.computed) {
|
||||
const pattern =
|
||||
property.value.type === "ObjectPattern"
|
||||
? this._preWalkObjectPattern(property.value)
|
||||
: property.value.type === "ArrayPattern"
|
||||
? this._preWalkArrayPattern(property.value)
|
||||
: undefined;
|
||||
props.add({
|
||||
id: key.name,
|
||||
range: key.range,
|
||||
range: /** @type {Range} */ (key.range),
|
||||
pattern,
|
||||
shorthand: this.scope.inShorthand
|
||||
});
|
||||
} else {
|
||||
const id = this.evaluateExpression(key);
|
||||
const str = id.asString();
|
||||
if (str) {
|
||||
const pattern =
|
||||
property.value.type === "ObjectPattern"
|
||||
? this._preWalkObjectPattern(property.value)
|
||||
: property.value.type === "ArrayPattern"
|
||||
? this._preWalkArrayPattern(property.value)
|
||||
: undefined;
|
||||
props.add({
|
||||
id: str,
|
||||
range: key.range,
|
||||
range: /** @type {Range} */ (key.range),
|
||||
pattern,
|
||||
shorthand: this.scope.inShorthand
|
||||
});
|
||||
} else {
|
||||
|
@ -3018,6 +3033,35 @@ class JavascriptParser extends Parser {
|
|||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayPattern} arrayPattern array pattern
|
||||
* @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
|
||||
*/
|
||||
_preWalkArrayPattern(arrayPattern) {
|
||||
/** @type {Set<DestructuringAssignmentProperty>} */
|
||||
const props = new Set();
|
||||
const elements = arrayPattern.elements;
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
const element = elements[i];
|
||||
if (!element) continue;
|
||||
if (element.type === "RestElement") return;
|
||||
const pattern =
|
||||
element.type === "ObjectPattern"
|
||||
? this._preWalkObjectPattern(element)
|
||||
: element.type === "ArrayPattern"
|
||||
? this._preWalkArrayPattern(element)
|
||||
: undefined;
|
||||
props.add({
|
||||
id: `${i}`,
|
||||
range: /** @type {Range} */ (element.range),
|
||||
pattern,
|
||||
shorthand: false
|
||||
});
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {VariableDeclarator} declarator variable declarator
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
|
||||
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
||||
|
||||
/**
|
||||
* Deep first traverse the properties of a destructuring assignment.
|
||||
* @param {DestructuringAssignmentProperties} properties destructuring assignment properties
|
||||
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} onLeftNode on left node callback
|
||||
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} enterNode enter node callback
|
||||
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} exitNode exit node callback
|
||||
* @param {DestructuringAssignmentProperty[] | undefined=} stack stack of the walking nodes
|
||||
*/
|
||||
function traverseDestructuringAssignmentProperties(
|
||||
properties,
|
||||
onLeftNode,
|
||||
enterNode,
|
||||
exitNode,
|
||||
stack = []
|
||||
) {
|
||||
for (const property of properties) {
|
||||
stack.push(property);
|
||||
if (enterNode) enterNode(stack);
|
||||
if (property.pattern) {
|
||||
traverseDestructuringAssignmentProperties(
|
||||
property.pattern,
|
||||
onLeftNode,
|
||||
enterNode,
|
||||
exitNode,
|
||||
stack
|
||||
);
|
||||
} else if (onLeftNode) {
|
||||
onLeftNode(stack);
|
||||
}
|
||||
if (exitNode) exitNode(stack);
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = traverseDestructuringAssignmentProperties;
|
28
package.json
28
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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.",
|
||||
"homepage": "https://github.com/webpack/webpack",
|
||||
"bugs": "https://github.com/webpack/webpack/issues",
|
||||
|
@ -89,7 +89,7 @@
|
|||
"@webassemblyjs/wasm-parser": "^1.14.1",
|
||||
"acorn": "^8.15.0",
|
||||
"acorn-import-phases": "^1.0.3",
|
||||
"browserslist": "^4.24.5",
|
||||
"browserslist": "^4.26.3",
|
||||
"chrome-trace-event": "^1.0.2",
|
||||
"enhanced-resolve": "^5.17.3",
|
||||
"es-module-lexer": "^1.2.1",
|
||||
|
@ -111,16 +111,16 @@
|
|||
"@babel/core": "^7.27.1",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@codspeed/core": "^4.0.1",
|
||||
"@eslint/js": "^9.29.0",
|
||||
"@eslint/markdown": "^7.1.0",
|
||||
"@stylistic/eslint-plugin": "^5.2.2",
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@eslint/markdown": "^7.3.0",
|
||||
"@stylistic/eslint-plugin": "^5.4.0",
|
||||
"@types/glob-to-regexp": "^0.4.4",
|
||||
"@types/graceful-fs": "^4.1.9",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^24.1.0",
|
||||
"@types/node": "^24.5.2",
|
||||
"@types/xxhashjs": "^0.2.4",
|
||||
"assemblyscript": "^0.28.5",
|
||||
"assemblyscript": "^0.28.8",
|
||||
"babel-loader": "^10.0.0",
|
||||
"bundle-loader": "^0.5.6",
|
||||
"coffee-loader": "^5.0.0",
|
||||
|
@ -131,13 +131,13 @@
|
|||
"date-fns": "^4.0.0",
|
||||
"es5-ext": "^0.10.53",
|
||||
"es6-promise-polyfill": "^1.2.0",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-config-prettier": "^10.1.1",
|
||||
"eslint-config-webpack": "^4.5.1",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"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-unicorn": "^61.0.1",
|
||||
"file-loader": "^6.0.0",
|
||||
|
@ -146,11 +146,11 @@
|
|||
"hash-wasm": "^4.9.0",
|
||||
"husky": "^9.0.11",
|
||||
"istanbul": "^0.4.5",
|
||||
"jest": "^30.1.2",
|
||||
"jest-circus": "^30.1.2",
|
||||
"jest-cli": "^30.1.2",
|
||||
"jest-diff": "^30.1.2",
|
||||
"jest-environment-node": "^30.1.2",
|
||||
"jest": "^30.2.0",
|
||||
"jest-circus": "^30.2.0",
|
||||
"jest-cli": "^30.2.0",
|
||||
"jest-diff": "^30.2.0",
|
||||
"jest-environment-node": "^30.2.0",
|
||||
"jest-junit": "^16.0.0",
|
||||
"json-loader": "^0.5.7",
|
||||
"json5": "^2.1.3",
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
* DO NOT MODIFY BY HAND.
|
||||
* Run `yarn fix:special` to update
|
||||
*/
|
||||
"use strict";function n(t,{instancePath:e="",parentData:s,parentDataProperty:l,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let e=0;e<n;e++){let n=t[e];const s=o,l=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(s!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,e=o;let s=!1;const l=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=l===o;if(s=s||h,!s){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,s=s||h}if(s)o=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(e,{instancePath:s="",parentData:l,parentDataProperty:a,rootData:r=e}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof e){if(e.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(e&&"object"==typeof e&&!Array.isArray(e)){let t;if(void 0===e.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in e)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"stage"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==e.banner){let n=e.banner;const t=u,s=u;let l=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(l=l||h,!l){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,l=l||h}if(l)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==e.entryOnly){const n=u;if("boolean"!=typeof e.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.exclude){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.exclude,{instancePath:s+"/exclude",parentData:e,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.footer){const n=u;if("boolean"!=typeof e.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.include){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.include,{instancePath:s+"/include",parentData:e,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.raw){const n=u;if("boolean"!=typeof e.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.stage){const n=u;if("number"!=typeof e.stage){const n={params:{type:"number"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==e.test){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.test,{instancePath:s+"/test",parentData:e,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0}}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(e instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;
|
||||
"use strict";function n(t,{instancePath:s="",parentData:e,parentDataProperty:l,rootData:a=t}={}){let o=null,r=0;const u=r;let i=!1;const p=r;if(r===p)if(Array.isArray(t)){const n=t.length;for(let s=0;s<n;s++){let n=t[s];const e=r,l=r;let a=!1,u=null;const i=r,p=r;let f=!1;const h=r;if(!(n instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),r++}var c=h===r;if(f=f||c,!f){const t=r;if(r===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===o?o=[n]:o.push(n),r++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),r++}if(c=t===r,f=f||c,!f){const t=r;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),r++}c=t===r,f=f||c}}if(f)r=p,null!==o&&(p?o.length=p:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),r++}if(i===r&&(a=!0,u=0),a)r=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:u}};null===o?o=[n]:o.push(n),r++}if(e!==r)break}}else{const n={params:{type:"array"}};null===o?o=[n]:o.push(n),r++}var f=p===r;if(i=i||f,!i){const n=r,s=r;let e=!1;const l=r;if(!(t instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),r++}var h=l===r;if(e=e||h,!e){const n=r;if(r===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===o?o=[n]:o.push(n),r++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),r++}if(h=n===r,e=e||h,!e){const n=r;if(!(t instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),r++}h=n===r,e=e||h}}if(e)r=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),r++}f=n===r,i=i||f}if(!i){const t={params:{}};return null===o?o=[t]:o.push(t),r++,n.errors=o,!1}return r=u,null!==o&&(u?o.length=u:o=null),n.errors=o,0===r}function t(s,{instancePath:e="",parentData:l,parentDataProperty:a,rootData:o=s}={}){let r=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof s){if(s.length<1){const n={params:{}};null===r?r=[n]:r.push(n),u++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(s&&"object"==typeof s&&!Array.isArray(s)){let t;if(void 0===s.banner&&(t="banner")){const n={params:{missingProperty:t}};null===r?r=[n]:r.push(n),u++}else{const t=u;for(const n in s)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"stage"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===r?r=[t]:r.push(t),u++;break}if(t===u){if(void 0!==s.banner){let n=s.banner;const t=u,e=u;let l=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===r?r=[n]:r.push(n),u++}var h=a===u;if(l=l||h,!l){const t=u;if(!(n instanceof Function)){const n={params:{}};null===r?r=[n]:r.push(n),u++}h=t===u,l=l||h}if(l)u=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==s.entryOnly){const n=u;if("boolean"!=typeof s.entryOnly){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.exclude){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.exclude,{instancePath:e+"/exclude",parentData:s,parentDataProperty:"exclude",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==s.footer){const n=u;if("boolean"!=typeof s.footer){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.include){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.include,{instancePath:e+"/include",parentData:s,parentDataProperty:"include",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==s.raw){const n=u;if("boolean"!=typeof s.raw){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.stage){const n=u;if("number"!=typeof s.stage){const n={params:{type:"number"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==s.test){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.test,{instancePath:e+"/test",parentData:s,parentDataProperty:"test",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0}}}}}}}}}else{const n={params:{type:"object"}};null===r?r=[n]:r.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(s instanceof Function)){const n={params:{}};null===r?r=[n]:r.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===r?r=[n]:r.push(n),u++,t.errors=r,!1}return u=i,null!==r&&(i?r.length=i:r=null),t.errors=r,0===u}module.exports=t,module.exports.default=t;
|
|
@ -15,6 +15,10 @@
|
|||
{
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((str: string) => boolean)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,6 +10,10 @@
|
|||
{
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((str: string) => boolean)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -41,3 +41,11 @@ it("should static analyze dynamic import variable destructuring assignment", asy
|
|||
expect(def).toBe(3);
|
||||
expect(usedExports).toEqual(["default", "usedExports"]);
|
||||
});
|
||||
|
||||
it("expect support of \"deep\" tree-shaking for destructuring assignment dynamic import", async () => {
|
||||
const { a: { aaa, usedExports: usedExportsA }, b: { bbb, usedExports: usedExportsB } } = await import("./lib");
|
||||
expect(aaa).toBe(1);
|
||||
expect(bbb).toBe(2);
|
||||
expect(usedExportsA).toEqual(["aaa", "usedExports"]);
|
||||
expect(usedExportsB).toEqual(["bbb", "usedExports"]);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export const aaa = 1;
|
||||
export const bbb = 2;
|
||||
export const usedExports = __webpack_exports_info__.usedExports;
|
|
@ -0,0 +1,3 @@
|
|||
export const aaa = 1;
|
||||
export const bbb = 2;
|
||||
export const usedExports = __webpack_exports_info__.usedExports;
|
|
@ -0,0 +1,2 @@
|
|||
export * as a from "./a";
|
||||
export * as b from "./b";
|
|
@ -70,3 +70,19 @@ it("should static analyze dynamic import variable destructuring assignment", asy
|
|||
expect(usedExports).toEqual(["default", "usedExports"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("expect support of \"deep\" tree-shaking for destructuring assignment dynamic import", async () => {
|
||||
await import("../statical-dynamic-import-destructuring/lib").then(({ a: { aaa, usedExports: usedExportsA }, b: { bbb, usedExports: usedExportsB } }) => {
|
||||
expect(aaa).toBe(1);
|
||||
expect(bbb).toBe(2);
|
||||
expect(usedExportsA).toEqual(["aaa", "usedExports"]);
|
||||
expect(usedExportsB).toEqual(["bbb", "usedExports"]);
|
||||
});
|
||||
await import("../statical-dynamic-import-destructuring/lib?2").then(m => {
|
||||
const { a: { aaa, usedExports: usedExportsA }, b: { bbb, usedExports: usedExportsB } } = m;
|
||||
expect(aaa).toBe(1);
|
||||
expect(bbb).toBe(2);
|
||||
expect(usedExportsA).toEqual(["aaa", "usedExports"]);
|
||||
expect(usedExportsB).toEqual(["bbb", "usedExports"]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
"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\./
|
||||
]
|
||||
];
|
||||
|
|
|
@ -47,9 +47,9 @@ it("expect tree-shake bailout when rest element is used", () => {
|
|||
expect(rest.exportsInfo.counter).toBe(true);
|
||||
});
|
||||
|
||||
it("expect no support of \"deep\" tree-shaking", () => {
|
||||
it("expect support of \"deep\" tree-shaking", () => {
|
||||
const { counter2: { d } } = C;
|
||||
expect(d).toBe(1);
|
||||
expect(exportsInfo2.d).toBe(true);
|
||||
expect(exportsInfo2.counter).toBe(true);
|
||||
expect(exportsInfo2.counter).toBe(false);
|
||||
});
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
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,
|
||||
}
|
||||
`);
|
||||
});
|
||||
}
|
||||
]
|
||||
};
|
|
@ -68,10 +68,10 @@ it("should mangle when destructuring json", async () => {
|
|||
const generatedJson = __non_webpack_require__(path.resolve(__dirname, "data.json.js"));
|
||||
expect(generatedJson).toEqual({
|
||||
"W": {
|
||||
"arr": [
|
||||
{ "prop1": 1, "prop2": 2 },
|
||||
{ "prop3": 3, "prop4": 4 },
|
||||
{ "prop5": 5, "prop6": 6 }
|
||||
"Q": [
|
||||
{ "X": 1 },
|
||||
0,
|
||||
0,
|
||||
]
|
||||
},
|
||||
"p": "foo"
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
it("bundle1 should include eval sourcemapped test1.js and test2.js as is", function() {
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var bundle1 = fs.readFileSync(path.join(__dirname, "bundle1.js"), "utf-8");
|
||||
expect(bundle1).toMatch("eval(\"{var test1marker");
|
||||
expect(bundle1).toMatch("var test2marker");
|
||||
expect(bundle1).not.toMatch("eval(\"{var test2marker");
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
var test1marker = {};
|
||||
|
||||
module.exports = test1marker;
|
|
@ -0,0 +1,3 @@
|
|||
var test2marker = {};
|
||||
|
||||
module.exports = test2marker;
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
const webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
},
|
||||
entry: {
|
||||
bundle0: ["./index.js"],
|
||||
bundle1: ["./test1.js", "./test2.js"]
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js"
|
||||
},
|
||||
plugins: [
|
||||
new webpack.EvalSourceMapDevToolPlugin({
|
||||
test: (str) => {
|
||||
if (str.endsWith(".js")) return true;
|
||||
return false;
|
||||
},
|
||||
exclude: /test2\.js/,
|
||||
module: true,
|
||||
columns: false
|
||||
})
|
||||
]
|
||||
};
|
|
@ -516,7 +516,7 @@ declare interface BannerPluginOptions {
|
|||
/**
|
||||
* Exclude all modules matching any of these conditions.
|
||||
*/
|
||||
exclude?: string | RegExp | Rule[];
|
||||
exclude?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
|
||||
/**
|
||||
* If true, banner will be placed at the end of the output.
|
||||
|
@ -526,7 +526,7 @@ declare interface BannerPluginOptions {
|
|||
/**
|
||||
* Include all modules matching any of these conditions.
|
||||
*/
|
||||
include?: string | RegExp | Rule[];
|
||||
include?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
|
||||
/**
|
||||
* If true, banner will not be wrapped in a comment.
|
||||
|
@ -541,7 +541,7 @@ declare interface BannerPluginOptions {
|
|||
/**
|
||||
* Include all modules that pass test assertion.
|
||||
*/
|
||||
test?: string | RegExp | Rule[];
|
||||
test?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
}
|
||||
declare interface BaseResolveRequest {
|
||||
/**
|
||||
|
@ -4001,7 +4001,8 @@ declare abstract class DependencyTemplates {
|
|||
*/
|
||||
declare interface DestructuringAssignmentProperty {
|
||||
id: string;
|
||||
range?: [number, number];
|
||||
range: [number, number];
|
||||
pattern?: Set<DestructuringAssignmentProperty>;
|
||||
shorthand: string | boolean;
|
||||
}
|
||||
declare class DeterministicChunkIdsPlugin {
|
||||
|
@ -9800,11 +9801,27 @@ declare interface MapOptions {
|
|||
module?: boolean;
|
||||
}
|
||||
declare interface MatchObject {
|
||||
test?: string | RegExp | (string | RegExp)[];
|
||||
include?: string | RegExp | (string | RegExp)[];
|
||||
exclude?: string | RegExp | (string | RegExp)[];
|
||||
test?:
|
||||
| string
|
||||
| RegExp
|
||||
| ((str: string) => boolean)
|
||||
| (string | RegExp | ((str: string) => boolean))[];
|
||||
include?:
|
||||
| string
|
||||
| RegExp
|
||||
| ((str: string) => boolean)
|
||||
| (string | RegExp | ((str: string) => boolean))[];
|
||||
exclude?:
|
||||
| string
|
||||
| RegExp
|
||||
| ((str: string) => boolean)
|
||||
| (string | RegExp | ((str: string) => boolean))[];
|
||||
}
|
||||
type Matcher = string | RegExp | (string | RegExp)[];
|
||||
type Matcher =
|
||||
| string
|
||||
| RegExp
|
||||
| ((str: string) => boolean)
|
||||
| (string | RegExp | ((str: string) => boolean))[];
|
||||
declare interface MaybeMergeableInitFragment<GenerateContext> {
|
||||
key?: string;
|
||||
stage: number;
|
||||
|
@ -15061,7 +15078,7 @@ declare interface Rmdir {
|
|||
callback: (err: null | NodeJS.ErrnoException) => void
|
||||
): void;
|
||||
}
|
||||
type Rule = string | RegExp;
|
||||
type Rule = string | RegExp | ((str: string) => boolean);
|
||||
declare interface RuleSet {
|
||||
/**
|
||||
* map of references in the rule set (may grow over time)
|
||||
|
@ -16477,7 +16494,7 @@ declare interface SourceMapDevToolPluginOptions {
|
|||
/**
|
||||
* Exclude modules that match the given value from source map generation.
|
||||
*/
|
||||
exclude?: string | RegExp | Rule[];
|
||||
exclude?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
|
||||
/**
|
||||
* Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict.
|
||||
|
@ -16499,7 +16516,7 @@ declare interface SourceMapDevToolPluginOptions {
|
|||
/**
|
||||
* Include source maps for module paths that match the given value.
|
||||
*/
|
||||
include?: string | RegExp | Rule[];
|
||||
include?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
|
||||
/**
|
||||
* Indicates whether SourceMaps from loaders should be used (defaults to true).
|
||||
|
@ -16536,7 +16553,7 @@ declare interface SourceMapDevToolPluginOptions {
|
|||
/**
|
||||
* Include source maps for modules based on their extension (defaults to .js and .css).
|
||||
*/
|
||||
test?: string | RegExp | Rule[];
|
||||
test?: string | RegExp | Rule[] | ((str: string) => boolean);
|
||||
}
|
||||
declare class SourceMapSource extends Source {
|
||||
constructor(
|
||||
|
|
Loading…
Reference in New Issue