mirror of https://github.com/webpack/webpack.git
refactor(types): more
This commit is contained in:
parent
4809421990
commit
e381884115
|
@ -89,9 +89,9 @@ const getIgnoredModule = memoize(() => {
|
||||||
|
|
||||||
class Dependency {
|
class Dependency {
|
||||||
constructor() {
|
constructor() {
|
||||||
/** @type {Module} */
|
/** @type {Module | undefined} */
|
||||||
this._parentModule = undefined;
|
this._parentModule = undefined;
|
||||||
/** @type {DependenciesBlock} */
|
/** @type {DependenciesBlock | undefined} */
|
||||||
this._parentDependenciesBlock = undefined;
|
this._parentDependenciesBlock = undefined;
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
this._parentDependenciesBlockIndex = -1;
|
this._parentDependenciesBlockIndex = -1;
|
||||||
|
@ -174,6 +174,12 @@ class Dependency {
|
||||||
this._loc = loc;
|
this._loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} startLine start line
|
||||||
|
* @param {number} startColumn start column
|
||||||
|
* @param {number} endLine end line
|
||||||
|
* @param {number} endColumn end column
|
||||||
|
*/
|
||||||
setLoc(startLine, startColumn, endLine, endColumn) {
|
setLoc(startLine, startColumn, endLine, endColumn) {
|
||||||
this._locSL = startLine;
|
this._locSL = startLine;
|
||||||
this._locSC = startColumn;
|
this._locSC = startColumn;
|
||||||
|
@ -247,7 +253,7 @@ class Dependency {
|
||||||
/**
|
/**
|
||||||
* Returns warnings
|
* Returns warnings
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} warnings
|
* @returns {WebpackError[] | null | undefined} warnings
|
||||||
*/
|
*/
|
||||||
getWarnings(moduleGraph) {
|
getWarnings(moduleGraph) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -256,7 +262,7 @@ class Dependency {
|
||||||
/**
|
/**
|
||||||
* Returns errors
|
* Returns errors
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} errors
|
* @returns {WebpackError[] | null | undefined} errors
|
||||||
*/
|
*/
|
||||||
getErrors(moduleGraph) {
|
getErrors(moduleGraph) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -288,7 +294,7 @@ class Dependency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context directory
|
* @param {string} context context directory
|
||||||
* @returns {Module} a module
|
* @returns {Module | null} a module
|
||||||
*/
|
*/
|
||||||
createIgnoredModule(context) {
|
createIgnoredModule(context) {
|
||||||
return getIgnoredModule();
|
return getIgnoredModule();
|
||||||
|
|
|
@ -9,6 +9,8 @@ const DllModuleFactory = require("./DllModuleFactory");
|
||||||
const DllEntryDependency = require("./dependencies/DllEntryDependency");
|
const DllEntryDependency = require("./dependencies/DllEntryDependency");
|
||||||
const EntryDependency = require("./dependencies/EntryDependency");
|
const EntryDependency = require("./dependencies/EntryDependency");
|
||||||
|
|
||||||
|
/** @typedef {import("./Compiler")} Compiler */
|
||||||
|
|
||||||
class DllEntryPlugin {
|
class DllEntryPlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} context context
|
* @param {string} context context
|
||||||
|
@ -21,6 +23,11 @@ class DllEntryPlugin {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the plugin
|
||||||
|
* @param {Compiler} compiler the compiler instance
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
compiler.hooks.compilation.tap(
|
compiler.hooks.compilation.tap(
|
||||||
"DllEntryPlugin",
|
"DllEntryPlugin",
|
||||||
|
|
|
@ -45,6 +45,7 @@ const cutOffMultilineMessage = (stack, message) => {
|
||||||
const stackSplitByLines = stack.split("\n");
|
const stackSplitByLines = stack.split("\n");
|
||||||
const messageSplitByLines = message.split("\n");
|
const messageSplitByLines = message.split("\n");
|
||||||
|
|
||||||
|
/** @type {string[]} */
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
stackSplitByLines.forEach((line, idx) => {
|
stackSplitByLines.forEach((line, idx) => {
|
||||||
|
|
|
@ -444,7 +444,7 @@ class Module extends DependenciesBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ModuleGraph} moduleGraph the module graph
|
* @param {ModuleGraph} moduleGraph the module graph
|
||||||
* @param {boolean} strict the importing module is strict
|
* @param {boolean | undefined} strict the importing module is strict
|
||||||
* @returns {"namespace" | "default-only" | "default-with-named" | "dynamic"} export type
|
* @returns {"namespace" | "default-only" | "default-with-named" | "dynamic"} export type
|
||||||
* "namespace": Exports is already a namespace object. namespace = exports.
|
* "namespace": Exports is already a namespace object. namespace = exports.
|
||||||
* "dynamic": Check at runtime if __esModule is set. When set: namespace = { ...exports, default: exports }. When not set: namespace = { default: exports }.
|
* "dynamic": Check at runtime if __esModule is set. When set: namespace = { ...exports, default: exports }. When not set: namespace = { default: exports }.
|
||||||
|
|
|
@ -396,7 +396,7 @@ class RuntimeTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} options options object
|
* @param {Object} options options object
|
||||||
* @param {Module} options.module the module
|
* @param {Module | null} options.module the module
|
||||||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||||
* @param {string} options.request the request that should be printed as comment
|
* @param {string} options.request the request that should be printed as comment
|
||||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||||
|
@ -439,7 +439,7 @@ class RuntimeTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} options options object
|
* @param {Object} options options object
|
||||||
* @param {Module} options.module the module
|
* @param {Module | null} options.module the module
|
||||||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||||
* @param {string} options.request the request that should be printed as comment
|
* @param {string} options.request the request that should be printed as comment
|
||||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||||
|
|
|
@ -23,6 +23,10 @@ const getCriticalDependencyWarning = memoize(() =>
|
||||||
|
|
||||||
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
|
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {RegExp | null | undefined} r regexp
|
||||||
|
* @returns {string} stringified regexp
|
||||||
|
*/
|
||||||
const regExpToString = r => (r ? r + "" : "");
|
const regExpToString = r => (r ? r + "" : "");
|
||||||
|
|
||||||
class ContextDependency extends Dependency {
|
class ContextDependency extends Dependency {
|
||||||
|
@ -93,7 +97,7 @@ class ContextDependency extends Dependency {
|
||||||
/**
|
/**
|
||||||
* Returns warnings
|
* Returns warnings
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} warnings
|
* @returns {WebpackError[] | null | undefined} warnings
|
||||||
*/
|
*/
|
||||||
getWarnings(moduleGraph) {
|
getWarnings(moduleGraph) {
|
||||||
let warnings = super.getWarnings(moduleGraph);
|
let warnings = super.getWarnings(moduleGraph);
|
||||||
|
|
|
@ -74,7 +74,7 @@ class CssImportDependency extends ModuleDependency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context directory
|
* @param {string} context context directory
|
||||||
* @returns {Module} a module
|
* @returns {Module | null} a module
|
||||||
*/
|
*/
|
||||||
createIgnoredModule(context) {
|
createIgnoredModule(context) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -75,6 +75,11 @@ class CssLocalIdentifierDependency extends NullDependency {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str string
|
||||||
|
* @param {string | boolean} omitUnderscore true if you need to omit underscore
|
||||||
|
* @returns {string} escaped css identifier
|
||||||
|
*/
|
||||||
const escapeCssIdentifier = (str, omitUnderscore) => {
|
const escapeCssIdentifier = (str, omitUnderscore) => {
|
||||||
const escaped = `${str}`.replace(
|
const escaped = `${str}`.replace(
|
||||||
// cspell:word uffff
|
// cspell:word uffff
|
||||||
|
|
|
@ -48,7 +48,7 @@ class CssUrlDependency extends ModuleDependency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context directory
|
* @param {string} context context directory
|
||||||
* @returns {Module} a module
|
* @returns {Module | null} a module
|
||||||
*/
|
*/
|
||||||
createIgnoredModule(context) {
|
createIgnoredModule(context) {
|
||||||
const RawDataUrlModule = getRawDataUrlModule();
|
const RawDataUrlModule = getRawDataUrlModule();
|
||||||
|
@ -133,7 +133,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
||||||
newValue = cssEscapeString(
|
newValue = cssEscapeString(
|
||||||
runtimeTemplate.assetUrl({
|
runtimeTemplate.assetUrl({
|
||||||
publicPath: "",
|
publicPath: "",
|
||||||
module: moduleGraph.getModule(dep),
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
||||||
codeGenerationResults
|
codeGenerationResults
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -142,7 +142,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
||||||
newValue = `url(${cssEscapeString(
|
newValue = `url(${cssEscapeString(
|
||||||
runtimeTemplate.assetUrl({
|
runtimeTemplate.assetUrl({
|
||||||
publicPath: "",
|
publicPath: "",
|
||||||
module: moduleGraph.getModule(dep),
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
||||||
codeGenerationResults
|
codeGenerationResults
|
||||||
})
|
})
|
||||||
)})`;
|
)})`;
|
||||||
|
|
|
@ -10,8 +10,13 @@ const makeSerializable = require("../util/makeSerializable");
|
||||||
|
|
||||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||||
|
/** @typedef {import("./EntryDependency")} EntryDependency */
|
||||||
|
|
||||||
class DllEntryDependency extends Dependency {
|
class DllEntryDependency extends Dependency {
|
||||||
|
/**
|
||||||
|
* @param {EntryDependency[]} dependencies dependencies
|
||||||
|
* @param {string} name name
|
||||||
|
*/
|
||||||
constructor(dependencies, name) {
|
constructor(dependencies, name) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||||
|
|
||||||
/** @type {WeakMap<ParserState, boolean>} */
|
/** @type {WeakMap<ParserState, boolean>} */
|
||||||
|
@ -18,8 +19,9 @@ exports.bailout = parserState => {
|
||||||
const value = parserStateExportsState.get(parserState);
|
const value = parserStateExportsState.get(parserState);
|
||||||
parserStateExportsState.set(parserState, false);
|
parserStateExportsState.set(parserState, false);
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
parserState.module.buildMeta.exportsType = undefined;
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||||
parserState.module.buildMeta.defaultObject = false;
|
buildMeta.exportsType = undefined;
|
||||||
|
buildMeta.defaultObject = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,8 +34,9 @@ exports.enable = parserState => {
|
||||||
if (value === false) return;
|
if (value === false) return;
|
||||||
parserStateExportsState.set(parserState, true);
|
parserStateExportsState.set(parserState, true);
|
||||||
if (value !== true) {
|
if (value !== true) {
|
||||||
parserState.module.buildMeta.exportsType = "default";
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||||
parserState.module.buildMeta.defaultObject = "redirect";
|
buildMeta.exportsType = "default";
|
||||||
|
buildMeta.defaultObject = "redirect";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ exports.enable = parserState => {
|
||||||
exports.setFlagged = parserState => {
|
exports.setFlagged = parserState => {
|
||||||
const value = parserStateExportsState.get(parserState);
|
const value = parserStateExportsState.get(parserState);
|
||||||
if (value !== true) return;
|
if (value !== true) return;
|
||||||
const buildMeta = parserState.module.buildMeta;
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||||
if (buildMeta.exportsType === "dynamic") return;
|
if (buildMeta.exportsType === "dynamic") return;
|
||||||
buildMeta.exportsType = "flagged";
|
buildMeta.exportsType = "flagged";
|
||||||
};
|
};
|
||||||
|
@ -56,7 +59,8 @@ exports.setFlagged = parserState => {
|
||||||
exports.setDynamic = parserState => {
|
exports.setDynamic = parserState => {
|
||||||
const value = parserStateExportsState.get(parserState);
|
const value = parserStateExportsState.get(parserState);
|
||||||
if (value !== true) return;
|
if (value !== true) return;
|
||||||
parserState.module.buildMeta.exportsType = "dynamic";
|
/** @type {BuildMeta} */
|
||||||
|
(parserState.module.buildMeta).exportsType = "dynamic";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,19 +51,23 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case "canMangle": {
|
case "canMangle": {
|
||||||
const exportsInfo = moduleGraph.getExportsInfo(module);
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
||||||
const exportInfo = exportsInfo.getExportInfo(exportName);
|
const exportInfo = exportsInfo.getExportInfo(
|
||||||
|
/** @type {string} */ (exportName)
|
||||||
|
);
|
||||||
if (exportInfo) return exportInfo.canMangle;
|
if (exportInfo) return exportInfo.canMangle;
|
||||||
return exportsInfo.otherExportsInfo.canMangle;
|
return exportsInfo.otherExportsInfo.canMangle;
|
||||||
}
|
}
|
||||||
case "used":
|
case "used":
|
||||||
return (
|
return (
|
||||||
moduleGraph.getExportsInfo(module).getUsed(exportName, runtime) !==
|
moduleGraph
|
||||||
|
.getExportsInfo(module)
|
||||||
|
.getUsed(/** @type {string} */ (exportName), runtime) !==
|
||||||
UsageState.Unused
|
UsageState.Unused
|
||||||
);
|
);
|
||||||
case "useInfo": {
|
case "useInfo": {
|
||||||
const state = moduleGraph
|
const state = moduleGraph
|
||||||
.getExportsInfo(module)
|
.getExportsInfo(module)
|
||||||
.getUsed(exportName, runtime);
|
.getUsed(/** @type {string} */ (exportName), runtime);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case UsageState.Used:
|
case UsageState.Used:
|
||||||
case UsageState.OnlyPropertiesUsed:
|
case UsageState.OnlyPropertiesUsed:
|
||||||
|
@ -79,7 +83,9 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "provideInfo":
|
case "provideInfo":
|
||||||
return moduleGraph.getExportsInfo(module).isExportProvided(exportName);
|
return moduleGraph
|
||||||
|
.getExportsInfo(module)
|
||||||
|
.isExportProvided(/** @type {string} */ (exportName));
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
@ -108,6 +114,10 @@ class ExportsInfoDependency extends NullDependency {
|
||||||
super.serialize(context);
|
super.serialize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ObjectDeserializerContext} context context
|
||||||
|
* @returns {ExportsInfoDependency} ExportsInfoDependency
|
||||||
|
*/
|
||||||
static deserialize(context) {
|
static deserialize(context) {
|
||||||
const obj = new ExportsInfoDependency(
|
const obj = new ExportsInfoDependency(
|
||||||
context.read(),
|
context.read(),
|
||||||
|
|
|
@ -15,6 +15,7 @@ const NullDependency = require("./NullDependency");
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||||
/** @typedef {import("../Module")} Module */
|
/** @typedef {import("../Module")} Module */
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
|
|
||||||
class HarmonyCompatibilityDependency extends NullDependency {
|
class HarmonyCompatibilityDependency extends NullDependency {
|
||||||
get type() {
|
get type() {
|
||||||
|
@ -80,7 +81,7 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
|
||||||
0,
|
0,
|
||||||
undefined,
|
undefined,
|
||||||
`\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }${
|
`\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }${
|
||||||
module.buildMeta.async ? ", 1" : ""
|
/** @type {BuildMeta} */ (module.buildMeta).async ? ", 1" : ""
|
||||||
});`
|
});`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,7 @@ const DynamicExports = require("./DynamicExports");
|
||||||
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
||||||
const HarmonyExports = require("./HarmonyExports");
|
const HarmonyExports = require("./HarmonyExports");
|
||||||
|
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||||
/** @typedef {import("./HarmonyModulesPlugin").HarmonyModulesPluginOptions} HarmonyModulesPluginOptions */
|
/** @typedef {import("./HarmonyModulesPlugin").HarmonyModulesPluginOptions} HarmonyModulesPluginOptions */
|
||||||
|
|
||||||
|
@ -72,7 +73,8 @@ module.exports = class HarmonyDetectionParserPlugin {
|
||||||
"Top-level-await is only supported in EcmaScript Modules"
|
"Top-level-await is only supported in EcmaScript Modules"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
module.buildMeta.async = true;
|
/** @type {BuildMeta} */
|
||||||
|
(module.buildMeta).async = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,8 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
|
||||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
||||||
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
|
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
|
||||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||||
|
@ -85,14 +87,19 @@ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImpor
|
||||||
// Skip rendering depending when dependency is conditional
|
// Skip rendering depending when dependency is conditional
|
||||||
if (connection && !connection.isTargetActive(runtime)) return;
|
if (connection && !connection.isTargetActive(runtime)) return;
|
||||||
|
|
||||||
const exportsInfo = moduleGraph.getExportsInfo(connection.module);
|
const exportsInfo = moduleGraph.getExportsInfo(
|
||||||
|
/** @type {ModuleGraphConnection} */ (connection).module
|
||||||
|
);
|
||||||
const ids = dep.getIds(moduleGraph);
|
const ids = dep.getIds(moduleGraph);
|
||||||
|
|
||||||
let value;
|
let value;
|
||||||
|
|
||||||
const exportsType = connection.module.getExportsType(
|
const exportsType =
|
||||||
|
/** @type {ModuleGraphConnection} */
|
||||||
|
(connection).module.getExportsType(
|
||||||
moduleGraph,
|
moduleGraph,
|
||||||
module.buildMeta.strictHarmonyModule
|
/** @type {BuildMeta} */
|
||||||
|
(module.buildMeta).strictHarmonyModule
|
||||||
);
|
);
|
||||||
switch (exportsType) {
|
switch (exportsType) {
|
||||||
case "default-with-named": {
|
case "default-with-named": {
|
||||||
|
|
|
@ -756,7 +756,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||||
/**
|
/**
|
||||||
* Returns warnings
|
* Returns warnings
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} warnings
|
* @returns {WebpackError[] | null | undefined} warnings
|
||||||
*/
|
*/
|
||||||
getWarnings(moduleGraph) {
|
getWarnings(moduleGraph) {
|
||||||
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
||||||
|
@ -769,7 +769,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||||
/**
|
/**
|
||||||
* Returns errors
|
* Returns errors
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} errors
|
* @returns {WebpackError[] | null | undefined} errors
|
||||||
*/
|
*/
|
||||||
getErrors(moduleGraph) {
|
getErrors(moduleGraph) {
|
||||||
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||||
|
|
||||||
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||||
|
|
||||||
/** @type {WeakMap<ParserState, boolean>} */
|
/** @type {WeakMap<ParserState, boolean>} */
|
||||||
|
@ -22,12 +24,14 @@ exports.enable = (parserState, isStrictHarmony) => {
|
||||||
if (value === false) return;
|
if (value === false) return;
|
||||||
parserStateExportsState.set(parserState, true);
|
parserStateExportsState.set(parserState, true);
|
||||||
if (value !== true) {
|
if (value !== true) {
|
||||||
parserState.module.buildMeta.exportsType = "namespace";
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||||
parserState.module.buildInfo.strict = true;
|
buildMeta.exportsType = "namespace";
|
||||||
parserState.module.buildInfo.exportsArgument = RuntimeGlobals.exports;
|
const buildInfo = /** @type {BuildInfo} */ (parserState.module.buildInfo);
|
||||||
|
buildInfo.strict = true;
|
||||||
|
buildInfo.exportsArgument = RuntimeGlobals.exports;
|
||||||
if (isStrictHarmony) {
|
if (isStrictHarmony) {
|
||||||
parserState.module.buildMeta.strictHarmonyModule = true;
|
buildMeta.strictHarmonyModule = true;
|
||||||
parserState.module.buildInfo.moduleArgument = "__webpack_module__";
|
buildInfo.moduleArgument = "__webpack_module__";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -209,7 +209,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||||
/**
|
/**
|
||||||
* Returns warnings
|
* Returns warnings
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} warnings
|
* @returns {WebpackError[] | null | undefined} warnings
|
||||||
*/
|
*/
|
||||||
getWarnings(moduleGraph) {
|
getWarnings(moduleGraph) {
|
||||||
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
||||||
|
@ -222,7 +222,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||||
/**
|
/**
|
||||||
* Returns errors
|
* Returns errors
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} errors
|
* @returns {WebpackError[] | null | undefined} errors
|
||||||
*/
|
*/
|
||||||
getErrors(moduleGraph) {
|
getErrors(moduleGraph) {
|
||||||
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
|
||||||
|
|
|
@ -8,15 +8,27 @@
|
||||||
const ConstDependency = require("./ConstDependency");
|
const ConstDependency = require("./ConstDependency");
|
||||||
const HarmonyExports = require("./HarmonyExports");
|
const HarmonyExports = require("./HarmonyExports");
|
||||||
|
|
||||||
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||||
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||||
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
|
|
||||||
class HarmonyTopLevelThisParserPlugin {
|
class HarmonyTopLevelThisParserPlugin {
|
||||||
|
/**
|
||||||
|
* @param {JavascriptParser} parser the parser
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
apply(parser) {
|
apply(parser) {
|
||||||
parser.hooks.expression
|
parser.hooks.expression
|
||||||
.for("this")
|
.for("this")
|
||||||
.tap("HarmonyTopLevelThisParserPlugin", node => {
|
.tap("HarmonyTopLevelThisParserPlugin", node => {
|
||||||
if (!parser.scope.topLevelScope) return;
|
if (!parser.scope.topLevelScope) return;
|
||||||
if (HarmonyExports.isEnabled(parser.state)) {
|
if (HarmonyExports.isEnabled(parser.state)) {
|
||||||
const dep = new ConstDependency("undefined", node.range, null);
|
const dep = new ConstDependency(
|
||||||
dep.loc = node.loc;
|
"undefined",
|
||||||
|
/** @type {Range} */ (node.range),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
dep.loc = /** @type {DependencyLocation} */ (node.loc);
|
||||||
parser.state.module.addPresentationalDependency(dep);
|
parser.state.module.addPresentationalDependency(dep);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ const ImportDependency = require("./ImportDependency");
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
||||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||||
|
/** @typedef {import("../Module")} Module */
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
|
|
||||||
|
@ -56,9 +58,9 @@ ImportEagerDependency.Template = class ImportEagerDependencyTemplate extends (
|
||||||
const dep = /** @type {ImportEagerDependency} */ (dependency);
|
const dep = /** @type {ImportEagerDependency} */ (dependency);
|
||||||
const content = runtimeTemplate.moduleNamespacePromise({
|
const content = runtimeTemplate.moduleNamespacePromise({
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
module: moduleGraph.getModule(dep),
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
||||||
request: dep.request,
|
request: dep.request,
|
||||||
strict: module.buildMeta.strictHarmonyModule,
|
strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
|
||||||
message: "import() eager",
|
message: "import() eager",
|
||||||
runtimeRequirements
|
runtimeRequirements
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,8 @@ const ImportDependency = require("./ImportDependency");
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
||||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||||
|
/** @typedef {import("../Module")} Module */
|
||||||
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
|
|
||||||
|
@ -53,9 +55,9 @@ ImportWeakDependency.Template = class ImportDependencyTemplate extends (
|
||||||
const dep = /** @type {ImportWeakDependency} */ (dependency);
|
const dep = /** @type {ImportWeakDependency} */ (dependency);
|
||||||
const content = runtimeTemplate.moduleNamespacePromise({
|
const content = runtimeTemplate.moduleNamespacePromise({
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
module: moduleGraph.getModule(dep),
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
||||||
request: dep.request,
|
request: dep.request,
|
||||||
strict: module.buildMeta.strictHarmonyModule,
|
strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
|
||||||
message: "import() weak",
|
message: "import() weak",
|
||||||
weak: true,
|
weak: true,
|
||||||
runtimeRequirements
|
runtimeRequirements
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ModuleDependency extends Dependency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context directory
|
* @param {string} context context directory
|
||||||
* @returns {Module} a module
|
* @returns {Module | null} a module
|
||||||
*/
|
*/
|
||||||
createIgnoredModule(context) {
|
createIgnoredModule(context) {
|
||||||
const RawModule = getRawModule();
|
const RawModule = getRawModule();
|
||||||
|
|
|
@ -10,6 +10,7 @@ const ModuleDependency = require("./ModuleDependency");
|
||||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||||
|
/** @typedef {import("../Module")} Module */
|
||||||
|
|
||||||
class ModuleDependencyTemplateAsId extends ModuleDependency.Template {
|
class ModuleDependencyTemplateAsId extends ModuleDependency.Template {
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +23,7 @@ class ModuleDependencyTemplateAsId extends ModuleDependency.Template {
|
||||||
const dep = /** @type {ModuleDependency} */ (dependency);
|
const dep = /** @type {ModuleDependency} */ (dependency);
|
||||||
if (!dep.range) return;
|
if (!dep.range) return;
|
||||||
const content = runtimeTemplate.moduleId({
|
const content = runtimeTemplate.moduleId({
|
||||||
module: moduleGraph.getModule(dep),
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
request: dep.request,
|
request: dep.request,
|
||||||
weak: dep.weak
|
weak: dep.weak
|
||||||
|
|
|
@ -13,6 +13,10 @@ const {
|
||||||
const makeSerializable = require("../util/makeSerializable");
|
const makeSerializable = require("../util/makeSerializable");
|
||||||
const RequireIncludeDependency = require("./RequireIncludeDependency");
|
const RequireIncludeDependency = require("./RequireIncludeDependency");
|
||||||
|
|
||||||
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||||
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||||
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
|
|
||||||
module.exports = class RequireIncludeDependencyParserPlugin {
|
module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
/**
|
/**
|
||||||
* @param {boolean} warn true: warn about deprecation, false: don't warn
|
* @param {boolean} warn true: warn about deprecation, false: don't warn
|
||||||
|
@ -20,6 +24,11 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
constructor(warn) {
|
constructor(warn) {
|
||||||
this.warn = warn;
|
this.warn = warn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {JavascriptParser} parser the parser
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
apply(parser) {
|
apply(parser) {
|
||||||
const { warn } = this;
|
const { warn } = this;
|
||||||
parser.hooks.call
|
parser.hooks.call
|
||||||
|
@ -31,12 +40,17 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
|
|
||||||
if (warn) {
|
if (warn) {
|
||||||
parser.state.module.addWarning(
|
parser.state.module.addWarning(
|
||||||
new RequireIncludeDeprecationWarning(expr.loc)
|
new RequireIncludeDeprecationWarning(
|
||||||
|
/** @type {DependencyLocation} */ (expr.loc)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dep = new RequireIncludeDependency(param.string, expr.range);
|
const dep = new RequireIncludeDependency(
|
||||||
dep.loc = expr.loc;
|
/** @type {string} */ (param.string),
|
||||||
|
/** @type {Range} */ (expr.range)
|
||||||
|
);
|
||||||
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||||
parser.state.current.addDependency(dep);
|
parser.state.current.addDependency(dep);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -45,7 +59,9 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
.tap("RequireIncludePlugin", expr => {
|
.tap("RequireIncludePlugin", expr => {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
parser.state.module.addWarning(
|
parser.state.module.addWarning(
|
||||||
new RequireIncludeDeprecationWarning(expr.loc)
|
new RequireIncludeDeprecationWarning(
|
||||||
|
/** @type {DependencyLocation} */ (expr.loc)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return evaluateToString("function")(expr);
|
return evaluateToString("function")(expr);
|
||||||
|
@ -55,7 +71,9 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
.tap("RequireIncludePlugin", expr => {
|
.tap("RequireIncludePlugin", expr => {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
parser.state.module.addWarning(
|
parser.state.module.addWarning(
|
||||||
new RequireIncludeDeprecationWarning(expr.loc)
|
new RequireIncludeDeprecationWarning(
|
||||||
|
/** @type {DependencyLocation} */ (expr.loc)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return toConstantDependency(parser, JSON.stringify("function"))(expr);
|
return toConstantDependency(parser, JSON.stringify("function"))(expr);
|
||||||
|
@ -64,6 +82,9 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
||||||
};
|
};
|
||||||
|
|
||||||
class RequireIncludeDeprecationWarning extends WebpackError {
|
class RequireIncludeDeprecationWarning extends WebpackError {
|
||||||
|
/**
|
||||||
|
* @param {DependencyLocation} loc location
|
||||||
|
*/
|
||||||
constructor(loc) {
|
constructor(loc) {
|
||||||
super("require.include() is deprecated and will be removed soon.");
|
super("require.include() is deprecated and will be removed soon.");
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ class RequireResolveHeaderDependency extends NullDependency {
|
||||||
super.serialize(context);
|
super.serialize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ObjectDeserializerContext} context context
|
||||||
|
* @returns {RequireResolveHeaderDependency} RequireResolveHeaderDependency
|
||||||
|
*/
|
||||||
static deserialize(context) {
|
static deserialize(context) {
|
||||||
const obj = new RequireResolveHeaderDependency(context.read());
|
const obj = new RequireResolveHeaderDependency(context.read());
|
||||||
obj.deserialize(context);
|
obj.deserialize(context);
|
||||||
|
@ -64,6 +68,11 @@ RequireResolveHeaderDependency.Template = class RequireResolveHeaderDependencyTe
|
||||||
source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
|
source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} name name
|
||||||
|
* @param {RequireResolveHeaderDependency} dep dependency
|
||||||
|
* @param {ReplaceSource} source source
|
||||||
|
*/
|
||||||
applyAsTemplateArgument(name, dep, source) {
|
applyAsTemplateArgument(name, dep, source) {
|
||||||
source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
|
source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ const SystemRuntimeModule = require("./SystemRuntimeModule");
|
||||||
|
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||||
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
||||||
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||||
|
|
||||||
const PLUGIN_NAME = "SystemPlugin";
|
const PLUGIN_NAME = "SystemPlugin";
|
||||||
|
|
||||||
|
@ -58,6 +60,9 @@ class SystemPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} name name
|
||||||
|
*/
|
||||||
const setNotSupported = name => {
|
const setNotSupported = name => {
|
||||||
parser.hooks.evaluateTypeof
|
parser.hooks.evaluateTypeof
|
||||||
.for(name)
|
.for(name)
|
||||||
|
@ -97,17 +102,21 @@ class SystemPlugin {
|
||||||
setNotSupported("System.register");
|
setNotSupported("System.register");
|
||||||
|
|
||||||
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => {
|
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => {
|
||||||
const dep = new ConstDependency(RuntimeGlobals.system, expr.range, [
|
const dep = new ConstDependency(
|
||||||
RuntimeGlobals.system
|
RuntimeGlobals.system,
|
||||||
]);
|
/** @type {Range} */ (expr.range),
|
||||||
dep.loc = expr.loc;
|
[RuntimeGlobals.system]
|
||||||
|
);
|
||||||
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||||
parser.state.module.addPresentationalDependency(dep);
|
parser.state.module.addPresentationalDependency(dep);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => {
|
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => {
|
||||||
parser.state.module.addWarning(
|
parser.state.module.addWarning(
|
||||||
new SystemImportDeprecationWarning(expr.loc)
|
new SystemImportDeprecationWarning(
|
||||||
|
/** @type {DependencyLocation} */ (expr.loc)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return parser.hooks.importCall.call({
|
return parser.hooks.importCall.call({
|
||||||
|
@ -133,6 +142,9 @@ class SystemPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SystemImportDeprecationWarning extends WebpackError {
|
class SystemImportDeprecationWarning extends WebpackError {
|
||||||
|
/**
|
||||||
|
* @param {DependencyLocation} loc location
|
||||||
|
*/
|
||||||
constructor(loc) {
|
constructor(loc) {
|
||||||
super(
|
super(
|
||||||
"System.import() is deprecated and will be removed soon. Use import() instead.\n" +
|
"System.import() is deprecated and will be removed soon. Use import() instead.\n" +
|
||||||
|
|
|
@ -42,7 +42,7 @@ class URLDependency extends ModuleDependency {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.outerRange = outerRange;
|
this.outerRange = outerRange;
|
||||||
this.relative = relative || false;
|
this.relative = relative || false;
|
||||||
/** @type {Set<string> | boolean} */
|
/** @type {Set<string> | boolean | undefined} */
|
||||||
this.usedByExports = undefined;
|
this.usedByExports = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class URLDependency extends ModuleDependency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context directory
|
* @param {string} context context directory
|
||||||
* @returns {Module} a module
|
* @returns {Module | null} a module
|
||||||
*/
|
*/
|
||||||
createIgnoredModule(context) {
|
createIgnoredModule(context) {
|
||||||
const RawDataUrlModule = getRawDataUrlModule();
|
const RawDataUrlModule = getRawDataUrlModule();
|
||||||
|
|
|
@ -55,7 +55,7 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
||||||
/**
|
/**
|
||||||
* Returns errors
|
* Returns errors
|
||||||
* @param {ModuleGraph} moduleGraph module graph
|
* @param {ModuleGraph} moduleGraph module graph
|
||||||
* @returns {WebpackError[]} errors
|
* @returns {WebpackError[] | null | undefined} errors
|
||||||
*/
|
*/
|
||||||
getErrors(moduleGraph) {
|
getErrors(moduleGraph) {
|
||||||
const module = moduleGraph.getModule(this);
|
const module = moduleGraph.getModule(this);
|
||||||
|
|
|
@ -33,12 +33,17 @@ const WorkerDependency = require("./WorkerDependency");
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
||||||
|
/** @typedef {import("../NormalModule")} NormalModule */
|
||||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||||
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
||||||
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {NormalModule} module module
|
||||||
|
* @returns {string} url
|
||||||
|
*/
|
||||||
const getUrl = module => {
|
const getUrl = module => {
|
||||||
return pathToFileURL(module.resource).toString();
|
return pathToFileURL(module.resource).toString();
|
||||||
};
|
};
|
||||||
|
@ -99,7 +104,7 @@ class WorkerPlugin {
|
||||||
/**
|
/**
|
||||||
* @param {JavascriptParser} parser the parser
|
* @param {JavascriptParser} parser the parser
|
||||||
* @param {Expression} expr expression
|
* @param {Expression} expr expression
|
||||||
* @returns {[BasicEvaluatedExpression, [number, number]]} parsed
|
* @returns {[BasicEvaluatedExpression, [number, number]] | void} parsed
|
||||||
*/
|
*/
|
||||||
const parseModuleUrl = (parser, expr) => {
|
const parseModuleUrl = (parser, expr) => {
|
||||||
if (
|
if (
|
||||||
|
@ -382,6 +387,9 @@ class WorkerPlugin {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @param {string} item item
|
||||||
|
*/
|
||||||
const processItem = item => {
|
const processItem = item => {
|
||||||
if (
|
if (
|
||||||
item.startsWith("*") &&
|
item.startsWith("*") &&
|
||||||
|
|
|
@ -309,7 +309,7 @@ exports.isDependencyUsedByExports = (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Dependency} dependency the dependency
|
* @param {Dependency} dependency the dependency
|
||||||
* @param {Set<string> | boolean} usedByExports usedByExports info
|
* @param {Set<string> | boolean | undefined} usedByExports usedByExports info
|
||||||
* @param {ModuleGraph} moduleGraph moduleGraph
|
* @param {ModuleGraph} moduleGraph moduleGraph
|
||||||
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
|
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
"alwaysStrict": true,
|
"alwaysStrict": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
|
|
|
@ -2948,10 +2948,10 @@ declare class Dependency {
|
||||||
get category(): string;
|
get category(): string;
|
||||||
loc: DependencyLocation;
|
loc: DependencyLocation;
|
||||||
setLoc(
|
setLoc(
|
||||||
startLine?: any,
|
startLine: number,
|
||||||
startColumn?: any,
|
startColumn: number,
|
||||||
endLine?: any,
|
endLine: number,
|
||||||
endColumn?: any
|
endColumn: number
|
||||||
): void;
|
): void;
|
||||||
getContext(): undefined | string;
|
getContext(): undefined | string;
|
||||||
getResourceIdentifier(): null | string;
|
getResourceIdentifier(): null | string;
|
||||||
|
@ -2984,12 +2984,12 @@ declare class Dependency {
|
||||||
/**
|
/**
|
||||||
* Returns warnings
|
* Returns warnings
|
||||||
*/
|
*/
|
||||||
getWarnings(moduleGraph: ModuleGraph): WebpackError[];
|
getWarnings(moduleGraph: ModuleGraph): undefined | null | WebpackError[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns errors
|
* Returns errors
|
||||||
*/
|
*/
|
||||||
getErrors(moduleGraph: ModuleGraph): WebpackError[];
|
getErrors(moduleGraph: ModuleGraph): undefined | null | WebpackError[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the hash
|
* Update the hash
|
||||||
|
@ -3003,7 +3003,7 @@ declare class Dependency {
|
||||||
getModuleEvaluationSideEffectsState(
|
getModuleEvaluationSideEffectsState(
|
||||||
moduleGraph: ModuleGraph
|
moduleGraph: ModuleGraph
|
||||||
): ConnectionState;
|
): ConnectionState;
|
||||||
createIgnoredModule(context: string): Module;
|
createIgnoredModule(context: string): null | Module;
|
||||||
serialize(__0: ObjectSerializerContext): void;
|
serialize(__0: ObjectSerializerContext): void;
|
||||||
deserialize(__0: ObjectDeserializerContext): void;
|
deserialize(__0: ObjectDeserializerContext): void;
|
||||||
module: any;
|
module: any;
|
||||||
|
@ -7540,7 +7540,7 @@ declare class Module extends DependenciesBlock {
|
||||||
get moduleArgument(): string;
|
get moduleArgument(): string;
|
||||||
getExportsType(
|
getExportsType(
|
||||||
moduleGraph: ModuleGraph,
|
moduleGraph: ModuleGraph,
|
||||||
strict: boolean
|
strict?: boolean
|
||||||
): "namespace" | "default-only" | "default-with-named" | "dynamic";
|
): "namespace" | "default-only" | "default-with-named" | "dynamic";
|
||||||
addPresentationalDependency(presentationalDependency: Dependency): void;
|
addPresentationalDependency(presentationalDependency: Dependency): void;
|
||||||
addCodeGenerationDependency(codeGenerationDependency: Dependency): void;
|
addCodeGenerationDependency(codeGenerationDependency: Dependency): void;
|
||||||
|
@ -11369,7 +11369,7 @@ declare abstract class RuntimeTemplate {
|
||||||
/**
|
/**
|
||||||
* the module
|
* the module
|
||||||
*/
|
*/
|
||||||
module: Module;
|
module: null | Module;
|
||||||
/**
|
/**
|
||||||
* the chunk graph
|
* the chunk graph
|
||||||
*/
|
*/
|
||||||
|
@ -11391,7 +11391,7 @@ declare abstract class RuntimeTemplate {
|
||||||
/**
|
/**
|
||||||
* the module
|
* the module
|
||||||
*/
|
*/
|
||||||
module: Module;
|
module: null | Module;
|
||||||
/**
|
/**
|
||||||
* the chunk graph
|
* the chunk graph
|
||||||
*/
|
*/
|
||||||
|
@ -13781,7 +13781,7 @@ declare namespace exports {
|
||||||
) => boolean;
|
) => boolean;
|
||||||
export let getDependencyUsedByExportsCondition: (
|
export let getDependencyUsedByExportsCondition: (
|
||||||
dependency: Dependency,
|
dependency: Dependency,
|
||||||
usedByExports: boolean | Set<string>,
|
usedByExports: undefined | boolean | Set<string>,
|
||||||
moduleGraph: ModuleGraph
|
moduleGraph: ModuleGraph
|
||||||
) =>
|
) =>
|
||||||
| null
|
| null
|
||||||
|
|
Loading…
Reference in New Issue