refactor: use `eslint-config-webpack` (#19645)
Github Actions / lint (push) Waiting to run Details
Github Actions / validate-legacy-node (push) Waiting to run Details
Github Actions / benchmark (1/4) (push) Waiting to run Details
Github Actions / benchmark (2/4) (push) Waiting to run Details
Github Actions / benchmark (3/4) (push) Waiting to run Details
Github Actions / benchmark (4/4) (push) Waiting to run Details
Github Actions / basic (push) Waiting to run Details
Github Actions / unit (push) Waiting to run Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions Details

This commit is contained in:
Alexander Akait 2025-07-02 15:10:54 +03:00 committed by GitHub
parent cf1dc2f131
commit 02a1d22db8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
460 changed files with 3856 additions and 1511 deletions

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
printWidth: 80,
useTabs: true,

View File

@ -1,5 +1,7 @@
#!/usr/bin/env node
"use strict";
/**
* @param {string} command process to run
* @param {string[]} args command line arguments
@ -7,6 +9,7 @@
*/
const runCommand = (command, args) => {
const cp = require("child_process");
return new Promise((resolve, reject) => {
const executedCommand = cp.spawn(command, args, {
stdio: "inherit",
@ -75,7 +78,9 @@ const isInstalled = packageName => {
*/
const runCli = cli => {
const path = require("path");
const pkgPath = require.resolve(`${cli.package}/package.json`);
const pkg = require(pkgPath);
if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {

View File

@ -1,15 +1,7 @@
import { defineConfig, globalIgnores } from "eslint/config";
import js from "@eslint/js";
import prettier from "eslint-plugin-prettier";
import nodePlugin from "eslint-plugin-n";
import jest from "eslint-plugin-jest";
import jsdoc from "eslint-plugin-jsdoc";
import prettierConfig from "eslint-config-prettier";
import config from "eslint-config-webpack";
import configs from "eslint-config-webpack/configs.js";
import globals from "globals";
import stylistic from "@stylistic/eslint-plugin";
import unicorn from "eslint-plugin-unicorn";
const jsdocConfig = jsdoc.configs["flat/recommended-typescript-flavor-error"];
export default defineConfig([
globalIgnores([
@ -31,6 +23,10 @@ export default defineConfig([
"!test/_helpers/**/*.mjs",
"test/js/**/*.*",
// TODO fix me
// This is not exactly typescript
"assembly/**/*.ts",
// Ignore some folders
"benchmark",
"coverage",
@ -48,64 +44,35 @@ export default defineConfig([
"lib/util/semver.js",
// Ignore some examples files
"examples/**/*.js",
"examples/**/*.mjs",
"examples/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,md}",
"!examples/*/webpack.config.js"
]),
{
files: ["**/*.mjs"],
languageOptions: {
sourceType: "module"
}
},
{
files: ["**/*.{js,cjs}"],
languageOptions: {
ecmaVersion: 2018,
sourceType: "commonjs",
globals: {
...globals.node,
...globals.es2018,
WebAssembly: true
}
}
},
...nodePlugin.configs["flat/mixed-esm-and-cjs"],
{
plugins: {
n: nodePlugin
},
ignores: ["lib/**/*.runtime.js", "hot/*.js"],
extends: [config],
rules: {
"n/no-missing-require": ["error", { allowModules: ["webpack"] }],
"n/no-unsupported-features/node-builtins": [
// Revisit it in future
"id-length": "off",
// Revisit it in future
"no-use-before-define": "off",
// We have helpers for the default configuration
"new-cap": [
"error",
{
ignores: [
"zlib.createBrotliCompress",
"zlib.createBrotliDecompress",
"EventSource"
]
newIsCapExceptions: [],
capIsNewExceptions: ["A", "F", "D", "MODULES_GROUPERS"]
}
],
"n/exports-style": "error"
}
},
{
...js.configs.recommended,
linterOptions: {
reportUnusedDisableDirectives: true
},
rules: {
...js.configs.recommended.rules,
"no-template-curly-in-string": "error",
"no-caller": "error",
"no-control-regex": "off",
yoda: "error",
eqeqeq: "error",
"eol-last": "error",
"no-extra-bind": "warn",
"no-process-exit": "warn",
"no-use-before-define": "off",
// TODO enable me in future
"prefer-destructuring": "off",
// TODO enable me in future, we need to ignore Object.define
"func-names": "off",
// TODO enable me in future
"unicorn/prefer-spread": "off",
// TODO need patch in tooling, now we are doing weird order for destructuring in cjs import
"import/order": "off",
// TODO We need allow to have `_arg` in tooling and use `after-used` value for `args`
"no-unused-vars": [
"error",
{
@ -115,357 +82,28 @@ export default defineConfig([
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true
destructuredArrayIgnorePattern: "^_",
ignoreRestSiblings: true,
ignoreClassWithStaticInitBlock: false,
reportUsedIgnorePattern: false
}
],
"no-inner-declarations": "error",
"prefer-const": [
"error",
{
destructuring: "all",
ignoreReadBeforeAssign: true
}
],
"object-shorthand": "error",
"no-else-return": "error",
"no-lonely-if": "error",
"no-undef-init": "error",
// Disallow ts-ignore directive. Use ts-expect-error instead
"no-warning-comments": ["error", { terms: ["@ts-ignore"] }],
"no-constructor-return": "error",
"symbol-description": "error",
"array-callback-return": [
"error",
{
allowImplicit: true
}
],
"no-promise-executor-return": "error",
"no-undef": "error",
"guard-for-in": "error",
"no-constant-condition": "error",
camelcase: [
"error",
{
allow: [
"__webpack_require__",
"__webpack_public_path__",
"__webpack_base_uri__",
"__webpack_modules__",
"__webpack_chunk_load__",
"__non_webpack_require__",
"__webpack_nonce__",
"__webpack_hash__",
"__webpack_chunkname__",
"__webpack_get_script_filename__",
"__webpack_runtime_id__",
"__system_context__",
"__webpack_share_scopes__",
"__webpack_init_sharing__",
"__webpack_require_module__",
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_writable",
"string_decoder"
]
}
],
"prefer-exponentiation-operator": "error",
"no-useless-return": "error",
"no-return-assign": "error",
"default-case-last": "error",
"default-param-last": "error",
"dot-notation": "error",
"grouped-accessor-pairs": "error",
"id-match": [
"error",
"^[$a-zA-Z_][$a-zA-Z0-9_]*$",
{
properties: true
}
],
"no-console": "error",
"no-extra-label": "error",
"no-label-var": "error",
"no-lone-blocks": "error",
"no-multi-str": "error",
"no-new-func": "error",
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
"no-useless-call": "error",
"no-useless-concat": "error",
"prefer-object-spread": "error",
"prefer-regex-literals": "error",
"prefer-rest-params": "error",
"no-var": "error",
"one-var": ["error", "never"],
"prefer-template": "error",
"no-implicit-coercion": [
"error",
{
boolean: true,
number: true,
string: true
}
],
"arrow-body-style": ["error", "as-needed"],
"new-cap": [
"error",
{
newIsCapExceptions: [],
capIsNewExceptions: ["A", "F", "D", "MODULES_GROUPERS"]
}
],
"func-style": [
"error",
"declaration",
{
allowArrowFunctions: true
}
],
"no-loop-func": "error",
"no-unreachable-loop": "error",
"no-unmodified-loop-condition": "error",
"prefer-spread": "error",
"no-sequences": "error",
// TODO Enable
"id-length": "off",
"prefer-destructuring": "off"
}
},
{
plugins: {
unicorn
},
rules: {
"unicorn/catch-error-name": [
"error",
{ name: "err", ignore: [/(^_|[0-9]+$)/i] }
],
"unicorn/prefer-includes": "error",
"unicorn/no-zero-fractions": "error",
"unicorn/prefer-string-starts-ends-with": "error",
"unicorn/prefer-default-parameters": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/prefer-ternary": ["error", "only-single-line"],
"unicorn/prefer-array-find": "error",
"unicorn/no-lonely-if": "error",
"unicorn/no-hex-escape": "error",
"unicorn/escape-case": "error",
"unicorn/no-array-for-each": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-native-coercion-functions": "error",
// TODO Enable
"unicorn/prefer-spread": "off"
}
},
{
plugins: {
"@stylistic": stylistic
},
rules: {
"@stylistic/lines-between-class-members": "error",
"@stylistic/quotes": [
"error",
"double",
{ avoidEscape: true, allowTemplateLiterals: false }
],
"@stylistic/spaced-comment": [
"error",
"always",
{
line: {
markers: ["=", "!"], // Space here to support sprockets directives
exceptions: ["-", "+"]
},
block: {
markers: ["=", "!"], // Space here to support sprockets directives
exceptions: ["-", "+"],
balanced: true
}
}
]
}
},
{
...jsdocConfig,
settings: {
jsdoc: {
mode: "typescript",
// supported tags https://github.com/microsoft/TypeScript-wiki/blob/master/JSDoc-support-in-JavaScript.md
tagNamePreference: {
...["memberof", "yields", "member"].reduce((acc, tag) => {
acc[tag] = {
message: `@${tag} currently not supported in TypeScript`
};
return acc;
}, {}),
extends: "extends",
return: "returns",
constructor: "constructor",
prop: "property",
arg: "param",
augments: "extends",
description: false,
desc: false,
inheritdoc: false,
class: "constructor"
},
overrideReplacesDocs: false
}
},
rules: {
...jsdocConfig.rules,
// Override recommended
//
// Doesn't support function overloading/tuples/`readonly`/module keyword/etc
// Also `typescript` reports this itself
"jsdoc/valid-types": "off",
// A lot of false positive with loops/`switch`/`if`/etc
"jsdoc/require-returns-check": "off",
// TODO fix and enable in future
// Too noise
"jsdoc/require-property-description": "off",
// More rules
"jsdoc/check-indentation": "error",
"jsdoc/check-line-alignment": ["error", "never"],
"jsdoc/require-asterisk-prefix": "error",
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
"jsdoc/require-template": "error",
"jsdoc/no-bad-blocks": "error",
"jsdoc/no-blank-block-descriptions": "error",
"jsdoc/no-blank-blocks": "error",
"jsdoc/no-restricted-syntax": [
"error",
{
contexts: [
// Prefer TypeScript syntax for functions
{
comment: "JsdocBlock:has(JsdocTypeFunction[arrow=false])",
message:
"Please use TypeScript syntax - `(a: string, b: boolean) => number`"
},
// Prefer `{string=}` over `{string} [arg]`
{
comment:
"JsdocBlock:has(JsdocTag[tag=/^(property|param)$/][name=/[\\[\\]]/])",
message:
"Please use `@property {string=} property`/`@param {string=} arg` instead `[arg]` for optional properties and parameters"
},
// No `*` type
{
comment: "JsdocBlock:has(JsdocTypeAny)",
message: "Please use `any` or `EXPECTED_ANY` type."
},
// No `?` type
{
comment: "JsdocBlock:has(JsdocTypeUnknown)",
message: "Please use `unknown` or `any` (or `EXPECTED_ANY`) type"
},
// No `any` type
{
comment: "JsdocBlock:has(JsdocTypeName[value=/^any$/])",
message: "Please use provide types instead `any`"
},
// No `Function` type
{
comment:
"JsdocBlock:has(JsdocTypeName[value=/^(function|Function)$/])",
message:
"Please use provide types for function - `(a: number, b: number) -> number` instead `Function`/`function` or use `EXPECTED_FUNCTION` type"
},
// No `Object`
{
comment:
"JsdocBlock:has(JsdocTag[tag!=/^(typedef|template|param)$/]:has(JsdocTypeName[value=/^(Object|object)$/]))",
message:
"Please use provide types for object - `{ property: number:, result: () => number}` instead `Object`/`object` or use `EXPECTED_OBJECT` type"
},
{
comment:
"JsdocBlock:has(JsdocTag[tag=typedef][parsedType.type!=JsdocTypeName]:has(JsdocTypeName[value=/^(Object|object)$/]))",
message:
"Please use provide types for object - `{ property: number:, result: () => number}` instead `Object`/`object` or use `EXPECTED_OBJECT` type"
}
]
}
]
// TODO enable me in future
"unicorn/prefer-regexp-test": "off",
"unicorn/prefer-string-slice": "off",
// TODO false positive, need to fix in upstream
"n/prefer-node-protocol": "off",
"n/prefer-global/url": "off"
}
},
{
...jest.configs["flat/recommended"],
files: ["test/**/*.{js,cjs,mjs}"],
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.jest,
nsObj: false
}
},
rules: {
...jest.configs["flat/recommended"].rules,
"jest/no-standalone-expect": "off",
"jest/valid-title": [
"error",
{
ignoreTypeOfDescribeName: true,
ignoreTypeOfTestName: true
}
],
"jest/no-done-callback": "off",
"jest/expect-expect": "off",
"jest/no-conditional-expect": "off",
"no-console": "off",
"jsdoc/require-jsdoc": "off",
"n/no-unsupported-features/es-syntax": [
"error",
{
version: ">=22",
ignores: []
}
],
"n/no-unsupported-features/es-builtins": [
"error",
{
version: ">=22",
ignores: []
}
],
"n/no-unsupported-features/node-builtins": [
"error",
{
allowExperimental: true,
version: ">=22",
ignores: []
}
]
}
},
{
files: ["lib/**/*.runtime.js", "hot/*.js"],
languageOptions: {
ecmaVersion: 5,
globals: {
...globals.browser,
...globals.es5
}
},
rules: {
"prefer-const": "off",
"object-shorthand": "off",
"no-undef-init": "off",
"no-var": "off",
"n/exports-style": "off",
"prefer-template": "off",
"no-implicit-coercion": "off",
"no-console": "off",
"func-style": "off",
"unicorn/prefer-includes": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/no-array-for-each": "off",
"jsdoc/require-jsdoc": "off"
}
files: ["lib/**/*.js"],
extends: [configs["webpack/special"]]
},
{
files: ["bin/**/*.js"],
@ -475,6 +113,8 @@ export default defineConfig([
},
rules: {
"no-console": "off",
// Allow to use `dynamic` import and hashbang
"n/no-unsupported-features/es-syntax": [
"error",
{
@ -484,34 +124,108 @@ export default defineConfig([
}
},
{
files: ["setup/**/*.js", "tooling/**/*.js"],
// Allow to use `dynamic` import
files: ["lib/**/*.runtime.js", "hot/*.js"],
extends: [configs["javascript/es5"]],
languageOptions: {
ecmaVersion: 2020
sourceType: "commonjs",
globals: {
...globals.browser,
...globals.es5,
Promise: false,
Map: false,
Set: false,
process: false
}
},
rules: {
strict: "off",
"block-scoped-var": "off",
// Allow logging
"no-console": "off",
// We replace `$VAR$` on real code
"no-unused-vars": "off",
"no-undef-init": "off",
"id-length": "off",
"unicorn/no-array-for-each": "off",
"unicorn/prefer-includes": "off",
"jsdoc/require-jsdoc": "off",
// Revisit it in future
"no-use-before-define": "off",
"func-names": "off",
"func-style": "off"
}
},
{
files: ["test/**/*.js"],
rules: {
// TODO enable me
strict: "off",
// No need here, we have custom test logic, so except can be placed in different places
"jest/no-standalone-expect": "off",
// We have a lot of custom tests
"jest/expect-expect": "off",
// We have a lot of custom tests
"jest/no-confusing-set-timeout": "off"
}
},
{
files: ["test/helpers/**/*.{js,cjs,mjs}"],
languageOptions: {
globals: {
...globals.jest
}
},
rules: {
"no-eval": "off",
"no-console": "off",
// Allow to use any builtins, syntax and node API in tests
"n/no-unsupported-features/es-builtins": "off",
"n/no-unsupported-features/es-syntax": "off",
"n/no-unsupported-features/node-builtins": "off"
}
},
{
files: ["test/**/*.mjs"],
languageOptions: {
ecmaVersion: 2022
}
},
{
files: ["setup/**/*.js", "tooling/**/*.js"],
languageOptions: {
ecmaVersion: 2022
},
rules: {
"no-console": "off"
}
},
{
files: [
"test/configCases/{dll-plugin-entry,dll-plugin-side-effects,dll-plugin}/**/webpack.config.js",
"examples/**/*.js",
"test/NodeTemplatePlugin.test.js"
],
rules: {
"n/no-missing-require": "off"
files: ["test/Compiler-filesystem-caching.test.js"],
languageOptions: {
ecmaVersion: 2022
}
},
{
...prettierConfig,
plugins: {
...prettierConfig.plugins,
prettier
},
files: [
"test/configCases/{dll-plugin-entry,dll-plugin-side-effects,dll-plugin}/**/webpack.config.js",
"examples/**/*.js",
"test/NodeTemplatePlugin.test.js",
"test/PersistentCaching.test.js"
],
rules: {
...prettierConfig.rules,
"prettier/prettier": "error"
"import/extensions": "off",
"import/no-unresolved": "off"
}
}
]);

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const { AggressiveMergingPlugin } = require("../..").optimize;

View File

@ -1,3 +1,5 @@
"use strict";
const svgToMiniDataURI = require("mini-svg-data-uri");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
output: {
assetModuleFilename: "images/[hash][ext]"

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// enable debug logging to see network requests!
// stats: {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = [
{
entry: "./example.js",

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
entry: {
app: { import: "./app.js", dependOn: ["other-vendors"] },

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
entry: {
app: { import: "./app.js", dependOn: ["react-vendors"] },

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
module: {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,4 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
output: {
uniqueName: "app"

View File

@ -1,3 +1,5 @@
"use strict";
const toml = require("toml");
const json5 = require("json5");
const yaml = require("yamljs");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
output: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
optimization: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
optimization: {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
optimization: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const { HotModuleReplacementPlugin } = require("../../");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
module: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
entry: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
output: {
module: true,

View File

@ -1,5 +1,8 @@
"use strict";
const path = require("path");
const { ModuleFederationPlugin } = require("../../").container;
const rules = [
{
test: /\.js$/,
@ -22,6 +25,7 @@ const stats = {
chunkModules: true,
chunkOrigins: true
};
module.exports = (env = "development") => [
// For this example we have 3 configs in a single file
// In practice you probably would have separate config

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
output: {
module: true,

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
output: {
module: true,

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
const webpack = require("../../");

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
entry: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named"

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
target: "node",

View File

@ -1,4 +1,7 @@
"use strict";
const path = require("path");
module.exports = (env = "development") => ({
mode: env,
infrastructureLogging: {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
optimization: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
sideEffects: true

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = [

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
optimization: {
chunkIds: "named" // To keep filename consistent between different modes (for example building only)

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
module.exports = (env = "development") => ({

View File

@ -1,14 +1,14 @@
{
"name": "hi-wasm",
"type": "module",
"version": "0.1.0",
"sideEffects": false,
"type": "module",
"main": "hi_wasm.js",
"types": "hi_wasm.d.ts",
"files": [
"hi_wasm_bg.wasm",
"hi_wasm.js",
"hi_wasm_bg.js",
"hi_wasm.d.ts"
],
"main": "hi_wasm.js",
"types": "hi_wasm.d.ts",
"sideEffects": false
]
}

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development || "production",
output: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
output: {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
// mode: "development" || "production",
output: {

View File

@ -1,3 +1,5 @@
"use strict";
const path = require("path");
module.exports = {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = {
nameMapping: {
FsStats: /^Stats Import fs/,

View File

@ -45,6 +45,21 @@ module.exports = function (level, msg) {
}
};
/**
* @param {Error} err error
* @returns {string} formatted error
*/
module.exports.formatError = function (err) {
var message = err.message;
var stack = err.stack;
if (!stack) {
return message;
} else if (stack.indexOf(message) < 0) {
return message + "\n" + stack;
}
return stack;
};
var group = console.group || dummy;
var groupCollapsed = console.groupCollapsed || dummy;
var groupEnd = console.groupEnd || dummy;
@ -61,18 +76,3 @@ module.exports.groupEnd = logGroup(groupEnd);
module.exports.setLogLevel = function (level) {
logLevel = level;
};
/**
* @param {Error} err error
* @returns {string} formatted error
*/
module.exports.formatError = function (err) {
var message = err.message;
var stack = err.stack;
if (!stack) {
return message;
} else if (stack.indexOf(message) < 0) {
return message + "\n" + stack;
}
return stack;
};

View File

@ -4,6 +4,7 @@
*/
/* globals __resourceQuery */
if (module.hot) {
// eslint-disable-next-line no-implicit-coercion
var hotPollInterval = +__resourceQuery.slice(1) || 10 * 60 * 1000;
var log = require("./log");

View File

@ -1,3 +1,5 @@
"use strict";
/** @type {import('jest').Config} */
const config = {
prettierPath: require.resolve("prettier-2"),

View File

@ -6,6 +6,7 @@
"use strict";
const WebpackError = require("./WebpackError");
const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
/**

View File

@ -62,4 +62,5 @@ class AutomaticPrefetchPlugin {
});
}
}
module.exports = AutomaticPrefetchPlugin;

View File

@ -20,7 +20,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
const validate = createSchemaValidation(
/** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
(require("../schemas/plugins/BannerPlugin.check.js")),
(require("../schemas/plugins/BannerPlugin.check")),
() => require("../schemas/plugins/BannerPlugin.json"),
{
name: "Banner Plugin",

View File

@ -420,8 +420,9 @@ class ChunkGraph {
*/
attachDependentHashModules(chunk, modules) {
const cgc = this._getChunkGraphChunk(chunk);
if (cgc.dependentHashModules === undefined)
if (cgc.dependentHashModules === undefined) {
cgc.dependentHashModules = new Set();
}
for (const module of modules) {
cgc.dependentHashModules.add(module);
}
@ -1117,8 +1118,9 @@ class ChunkGraph {
*/
addDependentHashModuleToChunk(chunk, module) {
const cgc = this._getChunkGraphChunk(chunk);
if (cgc.dependentHashModules === undefined)
if (cgc.dependentHashModules === undefined) {
cgc.dependentHashModules = new Set();
}
cgc.dependentHashModules.add(module);
}
@ -1646,8 +1648,9 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
const module = connection.module;
stateInfo += module.getExportsType(this.moduleGraph, strict);
// cspell:word Tnamespace
if (stateInfo === "Tnamespace") activeNamespaceModules.add(module);
else {
if (stateInfo === "Tnamespace") {
activeNamespaceModules.add(module);
} else {
const oldModule = connectedModules.get(stateInfo);
if (oldModule === undefined) {
connectedModules.set(stateInfo, module);
@ -1687,8 +1690,9 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
}
}
// cspell:word Tnamespace
if (activeNamespaceModules.size === 0 && connectedModules.size === 0)
if (activeNamespaceModules.size === 0 && connectedModules.size === 0) {
return graphHash;
}
const connectedModulesInOrder =
connectedModules.size > 1
? Array.from(connectedModules).sort(([a], [b]) => (a < b ? -1 : 1))
@ -1712,9 +1716,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
const addModulesToHash = modules => {
let xor = ZERO_BIG_INT;
for (const m of modules) {
xor =
xor ^
this._getModuleGraphHashBigInt(
xor ^= this._getModuleGraphHashBigInt(
this._getChunkGraphModule(m),
m,
runtime
@ -1722,12 +1724,13 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
}
hash.update(xor.toString(16));
};
if (activeNamespaceModules.size === 1)
if (activeNamespaceModules.size === 1) {
addModuleToHash(
/** @type {Module} */ (activeNamespaceModules.values().next().value)
);
else if (activeNamespaceModules.size > 1)
} else if (activeNamespaceModules.size > 1) {
addModulesToHash(activeNamespaceModules);
}
for (const [stateInfo, modules] of connectedModulesInOrder) {
hash.update(stateInfo);
if (modules instanceof Set) {
@ -1767,12 +1770,13 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
*/
module => {
const chunkGraph = chunkGraphForModuleMap.get(module);
if (!chunkGraph)
if (!chunkGraph) {
throw new Error(
`${
deprecateMessage
}: There was no ChunkGraph assigned to the Module for backward-compat (Use the new API)`
);
}
return chunkGraph;
},
`${deprecateMessage}: Use new ChunkGraph API`,
@ -1818,12 +1822,13 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
*/
chunk => {
const chunkGraph = chunkGraphForChunkMap.get(chunk);
if (!chunkGraph)
if (!chunkGraph) {
throw new Error(
`${
deprecateMessage
}There was no ChunkGraph assigned to the Chunk for backward-compat (Use the new API)`
);
}
return chunkGraph;
},
`${deprecateMessage}: Use new ChunkGraph API`,

View File

@ -37,6 +37,7 @@ const validate = createSchemaValidation(
undefined,
() => {
const { definitions } = require("../schemas/WebpackOptions.json");
return {
definitions,
oneOf: [{ $ref: "#/definitions/CleanOptions" }]

View File

@ -44,8 +44,9 @@ class CompatibilityPlugin {
if (
parserOptions.browserify !== undefined &&
!parserOptions.browserify
)
) {
return;
}
parser.hooks.call.for("require").tap(
PLUGIN_NAME,
@ -75,9 +76,10 @@ class CompatibilityPlugin {
last.options.request === "." &&
last.userRequest === "." &&
last.options.recursive
)
) {
parser.state.current.dependencies.pop();
}
}
parser.state.module.addPresentationalDependency(dep);
return true;
}
@ -191,4 +193,5 @@ class CompatibilityPlugin {
);
}
}
module.exports = CompatibilityPlugin;

View File

@ -530,8 +530,9 @@ class Compilation {
if (
/** @type {ProcessedAssets} */
(processedAssets).has(this.assets)
)
) {
additionalAssetsFn(assets);
}
});
}
return {
@ -548,8 +549,9 @@ class Compilation {
} catch (err) {
return callback(/** @type {Error} */ (err));
}
if (processedAssets !== undefined)
if (processedAssets !== undefined) {
processedAssets.add(this.assets);
}
const newAssets = popNewAssets(assets);
if (newAssets !== undefined) {
this.hooks.processAdditionalAssets.callAsync(
@ -569,8 +571,9 @@ class Compilation {
if (
/** @type {ProcessedAssets} */
(processedAssets).has(this.assets)
)
) {
return additionalAssetsFn(assets, callback);
}
callback();
}
);
@ -591,8 +594,9 @@ class Compilation {
*/
err => {
if (err) return callback(err);
if (processedAssets !== undefined)
if (processedAssets !== undefined) {
processedAssets.add(this.assets);
}
const newAssets = popNewAssets(assets);
if (newAssets !== undefined) {
this.hooks.processAdditionalAssets.callAsync(
@ -612,8 +616,9 @@ class Compilation {
if (
/** @type {ProcessedAssets} */
(processedAssets).has(this.assets)
)
) {
return additionalAssetsFn(assets);
}
return Promise.resolve();
});
}
@ -627,8 +632,9 @@ class Compilation {
const p = fn(assets);
if (!p || !p.then) return p;
return p.then(() => {
if (processedAssets !== undefined)
if (processedAssets !== undefined) {
processedAssets.add(this.assets);
}
const newAssets = popNewAssets(assets);
if (newAssets !== undefined) {
return this.hooks.processAdditionalAssets.promise(
@ -1231,7 +1237,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
// properties in the prototype chain
/** @type {Partial<NormalizedStatsOptions>} */
const options = {};
// eslint-disable-next-line guard-for-in
for (const key in optionsOrPreset) {
options[key] = optionsOrPreset[/** @type {keyof StatsOptions} */ (key)];
}
@ -1444,8 +1449,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
}
this._modules.set(identifier, module);
this.modules.add(module);
if (this._backCompat)
if (this._backCompat) {
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
}
if (currentProfile !== undefined) {
currentProfile.markIntegrationEnd();
}
@ -1738,9 +1744,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
inProgressTransitive = -1;
onTransitiveTasksFinished(err);
}
if (--inProgressTransitive === 0)
if (--inProgressTransitive === 0) {
return onTransitiveTasksFinished();
}
}
);
if (--inProgressSorting === 0) onDependenciesSorted();
return;
@ -1890,8 +1897,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this._modules.set(module.identifier(), module);
this.modules.add(module);
if (this._backCompat)
if (this._backCompat) {
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
}
this._handleModuleBuildAndDependencies(
originModule,
@ -2782,7 +2790,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.factorizeQueue.clear();
if (this.profile) {
this.logger.time("finish module profiles");
const ParallelismFactorCalculator = require("./util/ParallelismFactorCalculator");
const p = new ParallelismFactorCalculator();
const moduleGraph = this.moduleGraph;
/** @type {Map<Module, ModuleProfile>} */
@ -3455,9 +3465,10 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
}
}
if (this.reportDependencyErrorsAndWarnings(module, block.blocks))
if (this.reportDependencyErrorsAndWarnings(module, block.blocks)) {
hasProblems = true;
}
}
return hasProblems;
}
@ -3841,8 +3852,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
*/
addRuntimeModule(chunk, module, chunkGraph = this.chunkGraph) {
// Deprecated ModuleGraph association
if (this._backCompat)
if (this._backCompat) {
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
}
// add it to the list
this.modules.add(module);
@ -3914,7 +3926,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
}
}
const chunkGroup = new ChunkGroup(groupOptions);
if (module)
if (module) {
chunkGroup.addOrigin(
module,
/** @type {DependencyLocation} */
@ -3922,6 +3934,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
/** @type {string} */
(request)
);
}
const chunk = this.addChunk(name);
connectChunkGroupAndChunk(chunkGroup, chunk);
@ -3991,8 +4004,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
}
const chunk = new Chunk(name, this._backCompat);
this.chunks.add(chunk);
if (this._backCompat)
if (this._backCompat) {
ChunkGraph.setChunkGraphForChunk(chunk, this.chunkGraph);
}
if (name) {
this.namedChunks.set(name, chunk);
}
@ -4772,7 +4786,9 @@ This prevents using hashes of each other and should be avoided.`);
newEntry = entry.map(x => (x === file ? newFile : x));
} else if (entry === file) {
newEntry = newFile;
} else continue;
} else {
continue;
}
this.assetsInfo.set(name, {
...info,
related: {
@ -5500,6 +5516,7 @@ This prevents using hashes of each other and should be avoided.`);
(moduleArgumentsMap.get(runtimeModule))
);
}
exports = __webpack_require__(module.identifier());
} catch (execErr) {
const { message, stack, module } =

View File

@ -1167,7 +1167,7 @@ ${other}`);
try {
this.records = parseJson(
/** @type {Buffer} */ (content).toString("utf-8")
/** @type {Buffer} */ (content).toString("utf8")
);
} catch (parseErr) {
return callback(

View File

@ -109,7 +109,7 @@ class ConcatenationScope {
? "_asiSafe0"
: "";
const exportData = ids
? Buffer.from(JSON.stringify(ids), "utf-8").toString("hex")
? Buffer.from(JSON.stringify(ids), "utf8").toString("hex")
: "ns";
// a "._" is appended to allow "delete ...", which would cause a SyntaxError in strict mode
return `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${directImportFlag}${deferredImportFlag}${asiSafeFlag}__._`;
@ -137,7 +137,7 @@ class ConcatenationScope {
ids:
match[2] === "ns"
? []
: JSON.parse(Buffer.from(match[2], "hex").toString("utf-8")),
: JSON.parse(Buffer.from(match[2], "hex").toString("utf8")),
call: Boolean(match[3]),
directImport: Boolean(match[4]),
deferredImport: Boolean(match[5]),

View File

@ -189,8 +189,9 @@ class ConstPlugin {
parser.scope.isAsmJs ||
// Check top level scope here again
parser.scope.topLevelScope === true
)
) {
return;
}
this.eliminateUnusedStatement(parser, statement);
return true;
});

View File

@ -412,8 +412,9 @@ class ContextModule extends Module {
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
// always build when we have no snapshot and context
if (!buildInfo.snapshot)
if (!buildInfo.snapshot) {
return callback(null, Boolean(this.context || this.options.resource));
}
fileSystemInfo.checkSnapshotValid(buildInfo.snapshot, (err, valid) => {
callback(err, !valid);
@ -1188,9 +1189,11 @@ module.exports = webpackEmptyAsyncContext;`;
this.dependencies.length > 0
? /** @type {ContextElementDependency[]} */ (this.dependencies).slice()
: [];
for (const block of this.blocks)
for (const dep of block.dependencies)
for (const block of this.blocks) {
for (const dep of block.dependencies) {
allDeps.push(/** @type {ContextElementDependency} */ (dep));
}
}
set.add(RuntimeGlobals.module);
set.add(RuntimeGlobals.hasOwnProperty);
if (allDeps.length > 0) {

View File

@ -344,8 +344,9 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
const processedFiles = cmf.hooks.contextModuleFiles.call(
/** @type {string[]} */ (files).map(file => file.normalize("NFC"))
);
if (!processedFiles || processedFiles.length === 0)
if (!processedFiles || processedFiles.length === 0) {
return callback(null, []);
}
asyncLib.map(
processedFiles.filter(p => p.indexOf(".") !== 0),
(segment, callback) => {

View File

@ -388,8 +388,9 @@ class DefinePlugin {
const buildInfo = /** @type {BuildInfo} */ (
parser.state.module.buildInfo
);
if (!buildInfo.valueDependencies)
if (!buildInfo.valueDependencies) {
buildInfo.valueDependencies = new Map();
}
buildInfo.valueDependencies.set(VALUE_DEP_MAIN, mainValue);
});
@ -717,4 +718,5 @@ class DefinePlugin {
);
}
}
module.exports = DefinePlugin;

View File

@ -110,4 +110,5 @@ class DelegatedModuleFactoryPlugin {
}
}
}
module.exports = DelegatedModuleFactoryPlugin;

View File

@ -62,6 +62,7 @@ class DependencyTemplate {
*/
apply(dependency, source, templateContext) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
}

View File

@ -16,7 +16,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
/** @typedef {import("./DllEntryPlugin").Options} Options */
const validate = createSchemaValidation(
require("../schemas/plugins/DllPlugin.check.js"),
require("../schemas/plugins/DllPlugin.check"),
() => require("../schemas/plugins/DllPlugin.json"),
{
name: "Dll Plugin",

View File

@ -22,7 +22,7 @@ const makePathsRelative = require("./util/identifier").makePathsRelative;
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
const validate = createSchemaValidation(
require("../schemas/plugins/DllReferencePlugin.check.js"),
require("../schemas/plugins/DllReferencePlugin.check"),
() => require("../schemas/plugins/DllReferencePlugin.json"),
{
name: "Dll Reference Plugin",
@ -78,7 +78,7 @@ class DllReferencePlugin {
// or malformed manifest files don't kill the process.
try {
data.data = parseJson(
/** @type {Buffer} */ (result).toString("utf-8")
/** @type {Buffer} */ (result).toString("utf8")
);
} catch (parseErr) {
// Store the error in the params so that it can

View File

@ -33,9 +33,11 @@ class EntryOptionPlugin {
static applyEntryOption(compiler, context, entry) {
if (typeof entry === "function") {
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
new DynamicEntryPlugin(context, entry).apply(compiler);
} else {
const EntryPlugin = require("./EntryPlugin");
for (const name of Object.keys(entry)) {
const desc = entry[name];
const options = EntryOptionPlugin.entryDescriptionToOptions(
@ -81,14 +83,17 @@ class EntryOptionPlugin {
}
if (desc.chunkLoading) {
const EnableChunkLoadingPlugin = require("./javascript/EnableChunkLoadingPlugin");
EnableChunkLoadingPlugin.checkEnabled(compiler, desc.chunkLoading);
}
if (desc.wasmLoading) {
const EnableWasmLoadingPlugin = require("./wasm/EnableWasmLoadingPlugin");
EnableWasmLoadingPlugin.checkEnabled(compiler, desc.wasmLoading);
}
if (desc.library) {
const EnableLibraryPlugin = require("./library/EnableLibraryPlugin");
EnableLibraryPlugin.checkEnabled(compiler, desc.library.type);
}
return options;

View File

@ -159,8 +159,9 @@ class ExportsInfo {
* @returns {ExportInfo} the export info of unlisted exports
*/
get otherExportsInfo() {
if (this._redirectTo !== undefined)
if (this._redirectTo !== undefined) {
return this._redirectTo.otherExportsInfo;
}
return this._otherExportsInfo;
}
@ -259,8 +260,9 @@ class ExportsInfo {
getExportInfo(name) {
const info = this._exports.get(name);
if (info !== undefined) return info;
if (this._redirectTo !== undefined)
if (this._redirectTo !== undefined) {
return this._redirectTo.getExportInfo(name);
}
const newInfo = new ExportInfo(name, this._otherExportsInfo);
this._exports.set(name, newInfo);
this._exportsAreOrdered = false;
@ -274,8 +276,9 @@ class ExportsInfo {
getReadOnlyExportInfo(name) {
const info = this._exports.get(name);
if (info !== undefined) return info;
if (this._redirectTo !== undefined)
if (this._redirectTo !== undefined) {
return this._redirectTo.getReadOnlyExportInfo(name);
}
return this._otherExportsInfo;
}
@ -494,8 +497,9 @@ class ExportsInfo {
*/
isModuleUsed(runtime) {
if (this.isUsed(runtime)) return true;
if (this._sideEffectsOnlyInfo.getUsed(runtime) !== UsageState.Unused)
if (this._sideEffectsOnlyInfo.getUsed(runtime) !== UsageState.Unused) {
return true;
}
return false;
}
@ -671,9 +675,10 @@ class ExportsInfo {
return false;
}
for (const exportInfo of this.ownedExports) {
if (exportInfo.getUsed(runtimeA) !== exportInfo.getUsed(runtimeB))
if (exportInfo.getUsed(runtimeA) !== exportInfo.getUsed(runtimeB)) {
return false;
}
}
return true;
}
@ -1294,8 +1299,9 @@ class ExportInfo {
_getMaxTarget() {
if (this._maxTarget !== undefined) return this._maxTarget;
if (/** @type {Target} */ (this._target).size <= 1)
if (/** @type {Target} */ (this._target).size <= 1) {
return (this._maxTarget = this._target);
}
let maxPriority = -Infinity;
let minPriority = Infinity;
for (const { priority } of /** @type {Target} */ (this._target).values()) {
@ -1472,8 +1478,9 @@ class ExportInfo {
if (
target.export &&
!equals(/** @type {ArrayLike<string>} */ (t.export), target.export)
)
) {
return;
}
result = values.next();
}
return target;
@ -1521,8 +1528,9 @@ class ExportInfo {
* @returns {ExportsInfo} an exports info
*/
createNestedExportsInfo() {
if (this.exportsInfoOwned)
if (this.exportsInfoOwned) {
return /** @type {ExportsInfo} */ (this.exportsInfo);
}
this.exportsInfoOwned = true;
const oldExportsInfo = this.exportsInfo;
this.exportsInfo = new ExportsInfo();

View File

@ -352,8 +352,9 @@ const getSourceForModuleExternal = (
runtimeTemplate,
dependencyMeta
) => {
if (!Array.isArray(moduleAndSpecifiers))
if (!Array.isArray(moduleAndSpecifiers)) {
moduleAndSpecifiers = [moduleAndSpecifiers];
}
const initFragment = new ModuleExternalInitFragment(
moduleAndSpecifiers[0],
undefined,
@ -683,8 +684,9 @@ class ExternalModule extends Module {
_getRequestAndExternalType() {
let { request, externalType } = this;
if (typeof request === "object" && !Array.isArray(request))
if (typeof request === "object" && !Array.isArray(request)) {
request = request[externalType];
}
externalType = this._resolveExternalType(externalType);
return { request, externalType };
}
@ -900,8 +902,9 @@ class ExternalModule extends Module {
);
let sourceString = sourceData.expression;
if (sourceData.iife)
if (sourceData.iife) {
sourceString = `(function() { return ${sourceString}; }())`;
}
if (concatenationScope) {
sourceString = `${
runtimeTemplate.supportsConst() ? "const" : "var"
@ -912,8 +915,9 @@ class ExternalModule extends Module {
} else {
sourceString = `module.exports = ${sourceString};`;
}
if (sourceData.init)
if (sourceData.init) {
sourceString = `${sourceData.init}\n${sourceString}`;
}
let data;
if (sourceData.chunkInitFragments) {

View File

@ -337,4 +337,5 @@ class ExternalModuleFactoryPlugin {
);
}
}
module.exports = ExternalModuleFactoryPlugin;

View File

@ -313,7 +313,7 @@ class Snapshot {
* @param {number} value start value
*/
setStartTime(value) {
this._flags = this._flags | 1;
this._flags |= 1;
this.startTime = value;
}
@ -350,7 +350,7 @@ class Snapshot {
* @param {FileTimestamps} value file timestamps
*/
setFileTimestamps(value) {
this._flags = this._flags | 2;
this._flags |= 2;
this.fileTimestamps = value;
}
@ -362,7 +362,7 @@ class Snapshot {
* @param {FileHashes} value file hashes
*/
setFileHashes(value) {
this._flags = this._flags | 4;
this._flags |= 4;
this.fileHashes = value;
}
@ -374,7 +374,7 @@ class Snapshot {
* @param {FileTshs} value file tshs
*/
setFileTshs(value) {
this._flags = this._flags | 8;
this._flags |= 8;
this.fileTshs = value;
}
@ -386,7 +386,7 @@ class Snapshot {
* @param {ContextTimestamps} value context timestamps
*/
setContextTimestamps(value) {
this._flags = this._flags | 0x10;
this._flags |= 0x10;
this.contextTimestamps = value;
}
@ -398,7 +398,7 @@ class Snapshot {
* @param {ContextHashes} value context hashes
*/
setContextHashes(value) {
this._flags = this._flags | 0x20;
this._flags |= 0x20;
this.contextHashes = value;
}
@ -410,7 +410,7 @@ class Snapshot {
* @param {ContextTshs} value context tshs
*/
setContextTshs(value) {
this._flags = this._flags | 0x40;
this._flags |= 0x40;
this.contextTshs = value;
}
@ -422,7 +422,7 @@ class Snapshot {
* @param {MissingExistence} value context tshs
*/
setMissingExistence(value) {
this._flags = this._flags | 0x80;
this._flags |= 0x80;
this.missingExistence = value;
}
@ -434,7 +434,7 @@ class Snapshot {
* @param {ManagedItemInfo} value managed item info
*/
setManagedItemInfo(value) {
this._flags = this._flags | 0x100;
this._flags |= 0x100;
this.managedItemInfo = value;
}
@ -446,7 +446,7 @@ class Snapshot {
* @param {ManagedFiles} value managed files
*/
setManagedFiles(value) {
this._flags = this._flags | 0x200;
this._flags |= 0x200;
this.managedFiles = value;
}
@ -458,7 +458,7 @@ class Snapshot {
* @param {ManagedContexts} value managed contexts
*/
setManagedContexts(value) {
this._flags = this._flags | 0x400;
this._flags |= 0x400;
this.managedContexts = value;
}
@ -470,7 +470,7 @@ class Snapshot {
* @param {ManagedMissing} value managed missing
*/
setManagedMissing(value) {
this._flags = this._flags | 0x800;
this._flags |= 0x800;
this.managedMissing = value;
}
@ -482,7 +482,7 @@ class Snapshot {
* @param {Children} value children
*/
setChildren(value) {
this._flags = this._flags | 0x1000;
this._flags |= 0x1000;
this.children = value;
}
@ -792,8 +792,9 @@ class SnapshotOptimization {
snapshotContent: new Set(commonMap.keys()),
children: undefined
};
if (optimizationEntry.children === undefined)
if (optimizationEntry.children === undefined) {
optimizationEntry.children = new Set();
}
optimizationEntry.children.add(newEntry);
storeOptimizationEntry(newEntry);
this._statSharedSnapshots++;
@ -872,8 +873,9 @@ class SnapshotOptimization {
* @returns {string} result
*/
const parseString = str => {
if (str[0] === "'" || str[0] === "`")
if (str[0] === "'" || str[0] === "`") {
str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
}
return JSON.parse(str);
};
@ -1475,16 +1477,18 @@ class FileSystemInfo {
const cache = this._contextHashes.get(path);
if (cache !== undefined) {
const resolved = getResolvedHash(cache);
if (resolved !== undefined)
if (resolved !== undefined) {
return callback(null, /** @type {string} */ (resolved));
}
return this._resolveContextHash(cache, callback);
}
this.contextHashQueue.add(path, (err, _entry) => {
if (err) return callback(err);
const entry = /** @type {ContextHash} */ (_entry);
const resolved = getResolvedHash(entry);
if (resolved !== undefined)
if (resolved !== undefined) {
return callback(null, /** @type {string} */ (resolved));
}
this._resolveContextHash(entry, callback);
});
}
@ -1893,8 +1897,9 @@ class FileSystemInfo {
});
}
let request = subPath.replace(/\\/g, "/");
if (request.endsWith(".js"))
if (request.endsWith(".js")) {
request = request.slice(0, -3);
}
push({
type: RBDT_RESOLVE_CJS_FILE_AS_CHILD,
context,
@ -1929,7 +1934,9 @@ class FileSystemInfo {
);
this._warnAboutExperimentalEsmTracking = true;
}
const lexer = require("es-module-lexer");
lexer.init.then(() => {
this.fs.readFile(path, (err, content) => {
if (err) return callback(err);
@ -2025,7 +2032,8 @@ class FileSystemInfo {
let packageData;
try {
packageData = JSON.parse(
/** @type {Buffer} */ (content).toString("utf-8")
/** @type {Buffer} */
(content).toString("utf8")
);
} catch (parseErr) {
return callback(/** @type {Error} */ (parseErr));
@ -2099,8 +2107,9 @@ class FileSystemInfo {
switch (type) {
case "d":
resolveContext(context, path, {}, (err, _, result) => {
if (expectedResult === false)
if (expectedResult === false) {
return callback(err ? undefined : INVALID);
}
if (err) return callback(err);
const resultPath = /** @type {ResolveRequest} */ (result).path;
if (resultPath !== expectedResult) return callback(INVALID);
@ -2109,8 +2118,9 @@ class FileSystemInfo {
break;
case "f":
resolveCjs(context, path, {}, (err, _, result) => {
if (expectedResult === false)
if (expectedResult === false) {
return callback(err ? undefined : INVALID);
}
if (err) return callback(err);
const resultPath = /** @type {ResolveRequest} */ (result).path;
if (resultPath !== expectedResult) return callback(INVALID);
@ -2119,8 +2129,9 @@ class FileSystemInfo {
break;
case "c":
resolveCjsAsChild(context, path, {}, (err, _, result) => {
if (expectedResult === false)
if (expectedResult === false) {
return callback(err ? undefined : INVALID);
}
if (err) return callback(err);
const resultPath = /** @type {ResolveRequest} */ (result).path;
if (resultPath !== expectedResult) return callback(INVALID);
@ -2129,8 +2140,9 @@ class FileSystemInfo {
break;
case "e":
resolveEsm(context, path, {}, (err, _, result) => {
if (expectedResult === false)
if (expectedResult === false) {
return callback(err ? undefined : INVALID);
}
if (err) return callback(err);
const resultPath = /** @type {ResolveRequest} */ (result).path;
if (resultPath !== expectedResult) return callback(INVALID);
@ -3515,8 +3527,9 @@ class FileSystemInfo {
fromFile: (file, stat, callback) => {
// Prefer the cached value over our new stat to report consistent results
const cache = this._fileTimestamps.get(file);
if (cache !== undefined)
if (cache !== undefined) {
return callback(null, cache === "ignore" ? null : cache);
}
const mtime = Number(stat.mtime);
@ -4029,7 +4042,7 @@ class FileSystemInfo {
}
let data;
try {
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf-8"));
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf8"));
} catch (parseErr) {
return callback(/** @type {WebpackError} */ (parseErr));
}
@ -4048,8 +4061,9 @@ class FileSystemInfo {
}
getDeprecatedFileTimestamps() {
if (this._cachedDeprecatedFileTimestamps !== undefined)
if (this._cachedDeprecatedFileTimestamps !== undefined) {
return this._cachedDeprecatedFileTimestamps;
}
/** @type {Map<string, number | null>} */
const map = new Map();
for (const [path, info] of this._fileTimestamps) {
@ -4059,8 +4073,9 @@ class FileSystemInfo {
}
getDeprecatedContextTimestamps() {
if (this._cachedDeprecatedContextTimestamps !== undefined)
if (this._cachedDeprecatedContextTimestamps !== undefined) {
return this._cachedDeprecatedContextTimestamps;
}
/** @type {Map<string, number | null>} */
const map = new Map();
for (const [path, info] of this._contextTimestamps) {

View File

@ -200,21 +200,28 @@ class FlagDependencyExportsPlugin {
name = exportNameOrSpec;
} else {
name = exportNameOrSpec.name;
if (exportNameOrSpec.canMangle !== undefined)
if (exportNameOrSpec.canMangle !== undefined) {
canMangle = exportNameOrSpec.canMangle;
if (exportNameOrSpec.export !== undefined)
}
if (exportNameOrSpec.export !== undefined) {
fromExport = exportNameOrSpec.export;
if (exportNameOrSpec.exports !== undefined)
}
if (exportNameOrSpec.exports !== undefined) {
exports = exportNameOrSpec.exports;
if (exportNameOrSpec.from !== undefined)
}
if (exportNameOrSpec.from !== undefined) {
from = exportNameOrSpec.from;
if (exportNameOrSpec.priority !== undefined)
}
if (exportNameOrSpec.priority !== undefined) {
priority = exportNameOrSpec.priority;
if (exportNameOrSpec.terminalBinding !== undefined)
}
if (exportNameOrSpec.terminalBinding !== undefined) {
terminalBinding = exportNameOrSpec.terminalBinding;
if (exportNameOrSpec.hidden !== undefined)
}
if (exportNameOrSpec.hidden !== undefined) {
hidden = exportNameOrSpec.hidden;
}
}
const exportInfo = exportsInfo.getExportInfo(name);
if (

View File

@ -68,6 +68,7 @@ class Generator {
*/
getTypes(module) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
@ -80,6 +81,7 @@ class Generator {
*/
getSize(module, type) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
@ -95,6 +97,7 @@ class Generator {
{ dependencyTemplates, runtimeTemplate, moduleGraph, type }
) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}

View File

@ -47,6 +47,7 @@ const makeWebpackError = (error, hook) => {
if (error instanceof WebpackError) return error;
return new HookWebpackError(error, hook);
};
module.exports.makeWebpackError = makeWebpackError;
/**

View File

@ -110,8 +110,9 @@ class HotModuleReplacementPlugin {
*/
apply(compiler) {
const { _backCompat: backCompat } = compiler;
if (compiler.options.output.strictModuleErrorHandling === undefined)
if (compiler.options.output.strictModuleErrorHandling === undefined) {
compiler.options.output.strictModuleErrorHandling = true;
}
const runtimeRequirements = [RuntimeGlobals.module];
/**
@ -677,9 +678,10 @@ class HotModuleReplacementPlugin {
} else if (
moduleRuntime !== undefined &&
moduleRuntime.has(/** @type {string} */ (runtime))
)
) {
return;
}
}
const item =
/** @type {HotUpdateMainContentByRuntimeItem} */ (
hotUpdateMainContentByRuntime.get(
@ -696,16 +698,18 @@ class HotModuleReplacementPlugin {
(newRuntimeModules && newRuntimeModules.length > 0)
) {
const hotUpdateChunk = new HotUpdateChunk();
if (backCompat)
if (backCompat) {
ChunkGraph.setChunkGraphForChunk(hotUpdateChunk, chunkGraph);
}
hotUpdateChunk.id = chunkId;
hotUpdateChunk.runtime = currentChunk
? currentChunk.runtime
: newRuntime;
if (currentChunk) {
for (const group of currentChunk.groupsIterable)
for (const group of currentChunk.groupsIterable) {
hotUpdateChunk.addGroup(group);
}
}
chunkGraph.attachModules(hotUpdateChunk, newModules || []);
chunkGraph.attachRuntimeModules(
hotUpdateChunk,
@ -796,12 +800,15 @@ The configured output.hotUpdateMainFilename doesn't lead to unique filenames per
This might lead to incorrect runtime behavior of the applied update.
To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename option, or use the default config.`)
);
for (const chunkId of removedChunkIds)
for (const chunkId of removedChunkIds) {
old.removedChunkIds.add(chunkId);
for (const chunkId of removedModules)
}
for (const chunkId of removedModules) {
old.removedModules.add(chunkId);
for (const chunkId of updatedChunkIds)
}
for (const chunkId of updatedChunkIds) {
old.updatedChunkIds.add(chunkId);
}
continue;
}
hotUpdateMainContentByFilename.set(filename, {

View File

@ -14,7 +14,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
const validate = createSchemaValidation(
require("../schemas/plugins/IgnorePlugin.check.js"),
require("../schemas/plugins/IgnorePlugin.check"),
() => require("../schemas/plugins/IgnorePlugin.json"),
{
name: "Ignore Plugin",

View File

@ -140,4 +140,5 @@ class LibManifestPlugin {
);
}
}
module.exports = LibManifestPlugin;

Some files were not shown because too many files have changed in this diff Show More