improve typings and test them in CI
lazy load all webpack exports
This commit is contained in:
parent
3f9e6d5ec6
commit
6178aea763
|
@ -0,0 +1,18 @@
|
|||
declare module "*.json";
|
||||
|
||||
declare namespace jest {
|
||||
interface Matchers<R> {
|
||||
toBeTypeOf: (
|
||||
expected:
|
||||
| "string"
|
||||
| "number"
|
||||
| "bigint"
|
||||
| "boolean"
|
||||
| "symbol"
|
||||
| "undefined"
|
||||
| "object"
|
||||
| "function"
|
||||
) => void;
|
||||
toEndWith: (expected: string) => void;
|
||||
}
|
||||
}
|
|
@ -242,7 +242,13 @@ export type RuleSetLoaderOptions =
|
|||
*/
|
||||
export type RuleSetUse =
|
||||
| RuleSetUseItem[]
|
||||
| ((data: object) => RuleSetUseItem[])
|
||||
| ((data: {
|
||||
resource: string;
|
||||
realResource: string;
|
||||
resourceQuery: string;
|
||||
issuer: string;
|
||||
compiler: string;
|
||||
}) => RuleSetUseItem[])
|
||||
| RuleSetUseItem;
|
||||
/**
|
||||
* A description of an applied loader.
|
||||
|
|
118
lib/index.js
118
lib/index.js
|
@ -5,23 +5,78 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const validate = require("schema-utils");
|
||||
const util = require("util");
|
||||
const { version } = require("../package.json");
|
||||
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
||||
const WebpackOptionsApply = require("./WebpackOptionsApply");
|
||||
const memorize = require("./util/memorize");
|
||||
const validateSchema = require("./validateSchema");
|
||||
const webpack = require("./webpack");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
||||
/** @typedef {import("./Parser").ParserState} ParserState */
|
||||
|
||||
module.exports = Object.assign(webpack, {
|
||||
webpack,
|
||||
WebpackOptionsApply,
|
||||
validate: validateSchema.bind(null, webpackOptionsSchema),
|
||||
validateSchema,
|
||||
version,
|
||||
/**
|
||||
* @template {Function} T
|
||||
* @param {function(): T} factory factory function
|
||||
* @returns {T} function
|
||||
*/
|
||||
const lazyFunction = factory => {
|
||||
const fac = memorize(factory);
|
||||
const f = /** @type {any} */ ((...args) => {
|
||||
return fac()(...args);
|
||||
});
|
||||
return /** @type {T} */ (f);
|
||||
};
|
||||
|
||||
/**
|
||||
* @template A
|
||||
* @template B
|
||||
* @param {A} obj input a
|
||||
* @param {B} exports input b
|
||||
* @returns {A & B} merged
|
||||
*/
|
||||
const mergeExports = (obj, exports) => {
|
||||
const descriptors = Object.getOwnPropertyDescriptors(exports);
|
||||
for (const name of Object.keys(descriptors)) {
|
||||
const descriptor = descriptors[name];
|
||||
if (descriptor.get) {
|
||||
const fn = descriptor.get;
|
||||
Object.defineProperty(obj, name, {
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
get: memorize(fn)
|
||||
});
|
||||
} else if (typeof descriptor.value === "object") {
|
||||
Object.defineProperty(obj, name, {
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: false,
|
||||
value: mergeExports({}, descriptor.value)
|
||||
});
|
||||
} else {
|
||||
throw new Error(
|
||||
"Exposed values must be either a getter or an nested object"
|
||||
);
|
||||
}
|
||||
}
|
||||
return /** @type {A & B} */ (Object.freeze(obj));
|
||||
};
|
||||
|
||||
const fn = lazyFunction(() => require("./webpack"));
|
||||
module.exports = mergeExports(fn, {
|
||||
get webpack() {
|
||||
return require("./webpack");
|
||||
},
|
||||
get validate() {
|
||||
const validateSchema = require("./validateSchema");
|
||||
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
||||
return validateSchema.bind(null, webpackOptionsSchema);
|
||||
},
|
||||
get validateSchema() {
|
||||
const validateSchema = require("./validateSchema");
|
||||
return validateSchema;
|
||||
},
|
||||
get version() {
|
||||
return require("../package.json").version;
|
||||
},
|
||||
|
||||
get cli() {
|
||||
return require("./cli");
|
||||
|
@ -35,6 +90,12 @@ module.exports = Object.assign(webpack, {
|
|||
get Cache() {
|
||||
return require("./Cache");
|
||||
},
|
||||
get Chunk() {
|
||||
return require("./Chunk");
|
||||
},
|
||||
get ChunkGraph() {
|
||||
return require("./ChunkGraph");
|
||||
},
|
||||
get Compilation() {
|
||||
return require("./Compilation");
|
||||
},
|
||||
|
@ -74,6 +135,9 @@ module.exports = Object.assign(webpack, {
|
|||
get EvalSourceMapDevToolPlugin() {
|
||||
return require("./EvalSourceMapDevToolPlugin");
|
||||
},
|
||||
get ExternalModule() {
|
||||
return require("./ExternalModule");
|
||||
},
|
||||
get ExternalsPlugin() {
|
||||
return require("./ExternalsPlugin");
|
||||
},
|
||||
|
@ -115,6 +179,9 @@ module.exports = Object.assign(webpack, {
|
|||
get ModuleFilenameHelpers() {
|
||||
return require("./ModuleFilenameHelpers");
|
||||
},
|
||||
get ModuleGraph() {
|
||||
return require("./ModuleGraph");
|
||||
},
|
||||
get NoEmitOnErrorsPlugin() {
|
||||
return require("./NoEmitOnErrorsPlugin");
|
||||
},
|
||||
|
@ -164,6 +231,9 @@ module.exports = Object.assign(webpack, {
|
|||
get WatchIgnorePlugin() {
|
||||
return require("./WatchIgnorePlugin");
|
||||
},
|
||||
get WebpackOptionsApply() {
|
||||
return require("./WebpackOptionsApply");
|
||||
},
|
||||
get WebpackOptionsDefaulter() {
|
||||
return util.deprecate(
|
||||
() => require("./WebpackOptionsDefaulter"),
|
||||
|
@ -173,10 +243,10 @@ module.exports = Object.assign(webpack, {
|
|||
},
|
||||
// TODO webpack 6 deprecate
|
||||
get WebpackOptionsValidationError() {
|
||||
return validate.ValidationError;
|
||||
return require("schema-utils").ValidationError;
|
||||
},
|
||||
get ValidationError() {
|
||||
return validate.ValidationError;
|
||||
return require("schema-utils").ValidationError;
|
||||
},
|
||||
|
||||
cache: {
|
||||
|
@ -318,23 +388,3 @@ module.exports = Object.assign(webpack, {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
const finishExports = obj => {
|
||||
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
||||
for (const name of Object.keys(descriptors)) {
|
||||
const descriptor = descriptors[name];
|
||||
if (descriptor.get) {
|
||||
const fn = descriptor.get;
|
||||
Object.defineProperty(obj, name, {
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
get: memorize(fn)
|
||||
});
|
||||
} else if (typeof descriptor.value === "object") {
|
||||
finishExports(descriptor.value);
|
||||
}
|
||||
}
|
||||
Object.freeze(obj);
|
||||
};
|
||||
|
||||
finishExports(module.exports);
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
"strip-ansi": "^6.0.0",
|
||||
"style-loader": "^1.0.0",
|
||||
"toml": "^3.0.0",
|
||||
"tooling": "webpack/tooling",
|
||||
"tooling": "webpack/tooling#v1.0.0",
|
||||
"ts-loader": "^6.0.4",
|
||||
"typescript": "^3.6.4",
|
||||
"url-loader": "^2.1.0",
|
||||
|
@ -131,10 +131,10 @@
|
|||
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
|
||||
"pretest": "yarn lint",
|
||||
"prelint": "yarn setup",
|
||||
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn pretty-lint && yarn spellcheck",
|
||||
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-lint && yarn pretty-lint && yarn spellcheck",
|
||||
"code-lint": "eslint . --ext '.js' --cache",
|
||||
"type-lint": "tsc",
|
||||
"test:types": "tsc -p tsconfig.test.json",
|
||||
"typings-lint": "tsc -p tsconfig.test.json",
|
||||
"spellcheck": "cspell \"{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}\" \"*.md\"",
|
||||
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/generate-types",
|
||||
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/generate-types --write",
|
||||
|
|
|
@ -2572,7 +2572,7 @@
|
|||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((data: object) => RuleSetUseItem[])"
|
||||
"tsType": "((data: { resource: string, realResource: string, resourceQuery: string, issuer: string, compiler: string }) => RuleSetUseItem[])"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/RuleSetUseItem"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["./index", "./index2"]
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["react", "react-dom", "lodash"]
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: "./index"
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: "./index",
|
||||
devtool: "eval-cheap-module-source-map"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: "./index"
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").WebpackPluginFunction} */
|
||||
var testPlugin = function () {
|
||||
var counter = 1;
|
||||
this.hooks.compilation.tap("TestPlugin", compilation => {
|
||||
|
@ -8,6 +9,7 @@ var testPlugin = function () {
|
|||
});
|
||||
};
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [testPlugin]
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
amd: false
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const Compilation = require("../../../../").Compilation;
|
||||
const Source = require("webpack-sources").Source;
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
compiler => {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
output: {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const path = require("path");
|
||||
const NormalModule = require("../../../../").NormalModule;
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
output: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
output: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
output: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
module: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
performance: {
|
||||
hints: false
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "none",
|
||||
entry: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
b: "./entry-b",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/** @typedef {import("../../../../").Compilation} Compilation */
|
||||
/** @typedef {import("../../../../").Module} Module */
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
entry1: "./entry1",
|
||||
|
@ -22,6 +23,7 @@ module.exports = {
|
|||
for (const [name, group] of compilation.namedChunkGroups) {
|
||||
/** @type {Map<Module, number>} */
|
||||
const modules = new Map();
|
||||
/** @type {Map<Module, number>} */
|
||||
const modules2 = new Map();
|
||||
for (const chunk of group.chunks) {
|
||||
for (const module of compilation.chunkGraph.getChunkModulesIterable(
|
||||
|
@ -75,7 +77,13 @@ module.exports = {
|
|||
asyncIndex2: "0: ./async.js"
|
||||
});
|
||||
const indices = Array.from(compilation.modules)
|
||||
.map(m => [moduleGraph.getPreOrderIndex(m), m])
|
||||
.map(
|
||||
m =>
|
||||
/** @type {[number, Module]} */ ([
|
||||
moduleGraph.getPreOrderIndex(m),
|
||||
m
|
||||
])
|
||||
)
|
||||
.filter(p => typeof p[0] === "number")
|
||||
.sort((a, b) => a[0] - b[0])
|
||||
.map(
|
||||
|
@ -84,7 +92,13 @@ module.exports = {
|
|||
)
|
||||
.join(", ");
|
||||
const indices2 = Array.from(compilation.modules)
|
||||
.map(m => [moduleGraph.getPostOrderIndex(m), m])
|
||||
.map(
|
||||
m =>
|
||||
/** @type {[number, Module]} */ ([
|
||||
moduleGraph.getPostOrderIndex(m),
|
||||
m
|
||||
])
|
||||
)
|
||||
.filter(p => typeof p[0] === "number")
|
||||
.sort((a, b) => a[0] - b[0])
|
||||
.map(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "production",
|
||||
optimization: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
moduleIds: "hashed"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
node: {
|
||||
__dirname: false,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
strictExportPresence: true
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
entry1: "./entry1",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
concatenateModules: true
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
main: "./index"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [new webpack.ContextExclusionPlugin(/dont/)]
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(/context-replacement.b$/, /^\.\/only/)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
target: "web",
|
||||
output: {
|
||||
|
|
|
@ -6,11 +6,19 @@ const Parser = require("../../../../").Parser;
|
|||
const webpack = require("../../../../");
|
||||
|
||||
/** @typedef {import("../../../../").Compiler} Compiler */
|
||||
/** @typedef {import("../../../../").ParserState} ParserState */
|
||||
|
||||
class LocalizationParser extends Parser {
|
||||
parse(source, { module }) {
|
||||
/**
|
||||
* @param {string | Buffer | Record<string, any>} source input source
|
||||
* @param {ParserState} state state
|
||||
* @returns {ParserState} state
|
||||
*/
|
||||
parse(source, state) {
|
||||
if (typeof source !== "string") throw new Error("Unexpected input");
|
||||
const { module } = state;
|
||||
module.buildInfo.content = JSON.parse(source);
|
||||
return true;
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/** @typedef {import("../../../../").Compilation} Compilation */
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
usedExports: true,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/** @typedef {import("../../../../").Compilation} Compilation */
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
usedExports: true,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
resolve: Object.freeze({})
|
||||
// this fails to compile when the object is not cloned
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var DelegatedPlugin = require("../../../../").DelegatedPlugin;
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
moduleIds: "hashed"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var DelegatedPlugin = require("../../../../").DelegatedPlugin;
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new DelegatedPlugin({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const ExternalModule = require("../../../../lib/ExternalModule");
|
||||
const ChunkGraph = require("../../../../lib/ChunkGraph");
|
||||
const { ChunkGraph, ExternalModule } = require("../../../../");
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
compiler => {
|
||||
|
@ -44,7 +44,9 @@ module.exports = {
|
|||
expect(m.issuer).toBe(null);
|
||||
m.issuer = module;
|
||||
expect(m.issuer).toBe(module);
|
||||
expect([...m.usedExports]).toEqual(["testExport"]);
|
||||
expect(
|
||||
typeof m.usedExports === "boolean" ? [] : [...m.usedExports]
|
||||
).toEqual(["testExport"]);
|
||||
expect(m.optimizationBailout).toEqual([]);
|
||||
expect(m.optional).toBe(false);
|
||||
expect(m.isInChunk(chunk)).toBe(true);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
compiler => {
|
||||
compiler.hooks.done.tap("Test", ({ compilation }) => {
|
||||
for (const chunk of compilation.chunks) {
|
||||
for (const c of compilation.chunks) {
|
||||
const chunk = /** @type {{ files: string[] } & import("../../../../").Chunk} */ (c);
|
||||
expect(chunk.files.length).toBe(chunk.files.size);
|
||||
expect(chunk.files[0]).toBe(Array.from(chunk.files)[0]);
|
||||
expect(chunk.files.join(",")).toBe(Array.from(chunk.files).join(","));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
devtool: "eval-source-map"
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
devtool: "eval"
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["."],
|
||||
output: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
moduleIds: "named"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
moduleIds: "named"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["."],
|
||||
resolve: {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["./index"],
|
||||
output: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.DllReferencePlugin({
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["./a", "./b", "./_d", "./_e", "./f", "./g.abc", "./h"],
|
||||
resolve: {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["./index.js"],
|
||||
output: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.DllReferencePlugin({
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
moduleIds: "named"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var path = require("path");
|
||||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
ecmaVersion: 2009
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
ecmaVersion: 2015
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
ecmaVersion: 5
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
ecmaVersion: 6
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const EntryPlugin = require("../../../../").EntryPlugin;
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: () => ({}),
|
||||
optimization: {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/** @typedef {import("../../../../").Configuration} Configuration */
|
||||
|
||||
/** @type {Configuration} */
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry() {
|
||||
return Promise.resolve({
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/** @typedef {import("../../../../").Compiler} Compiler */
|
||||
/** @typedef {import("../../../../").Compilation} Compilation */
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: { import: "./app.js", dependOn: "react-vendors" },
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry() {
|
||||
return {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry() {
|
||||
return Promise.resolve({
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry() {
|
||||
return {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: [
|
||||
"./a",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
bundle0: "./a",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
bundle0: "./require-entry-point",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: "./single-entry-point"
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: ["./a", "./b"]
|
||||
};
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {};
|
||||
|
|
|
@ -11,6 +11,7 @@ class ThrowsExceptionInRender {
|
|||
}
|
||||
}
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [new ThrowsExceptionInRender()]
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
bail: true
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const IgnorePlugin = require("../../../../").IgnorePlugin;
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
a: "./intentionally-missing-module.js",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "production"
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
externals: {
|
||||
external: "1+2",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: {
|
||||
main: "./index",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "system"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
externals: {
|
||||
external: "global EXTERNAL_TEST_GLOBAL"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
externals: {
|
||||
external: "var 'abc'"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "umd"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "umd2"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "commonjs2"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
externalsType: "var",
|
||||
externals: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "umd"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue