webpack
Advanced tools
Comparing version 5.77.0 to 5.78.0
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -117,2 +122,4 @@ const WebpackError = require("./WebpackError"); | ||
const PLUGIN_NAME = "APIPlugin"; | ||
class APIPlugin { | ||
@@ -126,3 +133,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"APIPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -136,3 +143,3 @@ compilation.dependencyTemplates.set( | ||
.for(RuntimeGlobals.chunkName) | ||
.tap("APIPlugin", chunk => { | ||
.tap(PLUGIN_NAME, chunk => { | ||
compilation.addRuntimeModule( | ||
@@ -147,3 +154,3 @@ chunk, | ||
.for(RuntimeGlobals.getFullHash) | ||
.tap("APIPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule()); | ||
@@ -162,7 +169,7 @@ return true; | ||
.tap( | ||
"APIPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, info.expr, info.req) | ||
); | ||
if (info.assign === false) { | ||
parser.hooks.assign.for(key).tap("APIPlugin", expr => { | ||
parser.hooks.assign.for(key).tap(PLUGIN_NAME, expr => { | ||
const err = new WebpackError(`${key} must not be assigned`); | ||
@@ -176,3 +183,3 @@ err.loc = expr.loc; | ||
.for(key) | ||
.tap("APIPlugin", evaluateToString(info.type)); | ||
.tap(PLUGIN_NAME, evaluateToString(info.type)); | ||
} | ||
@@ -183,3 +190,3 @@ }); | ||
.for("__webpack_layer__") | ||
.tap("APIPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
@@ -195,3 +202,3 @@ JSON.stringify(parser.state.module.layer), | ||
.for("__webpack_layer__") | ||
.tap("APIPlugin", expr => | ||
.tap(PLUGIN_NAME, expr => | ||
(parser.state.module.layer === null | ||
@@ -206,3 +213,3 @@ ? new BasicEvaluatedExpression().setNull() | ||
.for("__webpack_layer__") | ||
.tap("APIPlugin", expr => | ||
.tap(PLUGIN_NAME, expr => | ||
new BasicEvaluatedExpression() | ||
@@ -217,3 +224,3 @@ .setString( | ||
.for("__webpack_module__.id") | ||
.tap("APIPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = | ||
@@ -233,3 +240,3 @@ "__webpack_module__.id"; | ||
.for("__webpack_module__") | ||
.tap("APIPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = | ||
@@ -248,14 +255,14 @@ "__webpack_module__"; | ||
.for("__webpack_module__") | ||
.tap("APIPlugin", evaluateToString("object")); | ||
.tap(PLUGIN_NAME, evaluateToString("object")); | ||
}; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("APIPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("APIPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("APIPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -262,0 +269,0 @@ ); |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const ConstDependency = require("./dependencies/ConstDependency"); | ||
@@ -15,2 +20,3 @@ | ||
const nestedWebpackRequireTag = Symbol("nested __webpack_require__"); | ||
const PLUGIN_NAME = "CompatibilityPlugin"; | ||
@@ -25,3 +31,3 @@ class CompatibilityPlugin { | ||
compiler.hooks.compilation.tap( | ||
"CompatibilityPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -34,4 +40,4 @@ compilation.dependencyTemplates.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("CompatibilityPlugin", (parser, parserOptions) => { | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, (parser, parserOptions) => { | ||
if ( | ||
@@ -43,29 +49,27 @@ parserOptions.browserify !== undefined && | ||
parser.hooks.call | ||
.for("require") | ||
.tap("CompatibilityPlugin", expr => { | ||
// support for browserify style require delegator: "require(o, !0)" | ||
if (expr.arguments.length !== 2) return; | ||
const second = parser.evaluateExpression(expr.arguments[1]); | ||
if (!second.isBoolean()) return; | ||
if (second.asBool() !== true) return; | ||
const dep = new ConstDependency("require", expr.callee.range); | ||
dep.loc = expr.loc; | ||
if (parser.state.current.dependencies.length > 0) { | ||
const last = | ||
parser.state.current.dependencies[ | ||
parser.state.current.dependencies.length - 1 | ||
]; | ||
if ( | ||
last.critical && | ||
last.options && | ||
last.options.request === "." && | ||
last.userRequest === "." && | ||
last.options.recursive | ||
) | ||
parser.state.current.dependencies.pop(); | ||
} | ||
parser.state.module.addPresentationalDependency(dep); | ||
return true; | ||
}); | ||
parser.hooks.call.for("require").tap(PLUGIN_NAME, expr => { | ||
// support for browserify style require delegator: "require(o, !0)" | ||
if (expr.arguments.length !== 2) return; | ||
const second = parser.evaluateExpression(expr.arguments[1]); | ||
if (!second.isBoolean()) return; | ||
if (second.asBool() !== true) return; | ||
const dep = new ConstDependency("require", expr.callee.range); | ||
dep.loc = expr.loc; | ||
if (parser.state.current.dependencies.length > 0) { | ||
const last = | ||
parser.state.current.dependencies[ | ||
parser.state.current.dependencies.length - 1 | ||
]; | ||
if ( | ||
last.critical && | ||
last.options && | ||
last.options.request === "." && | ||
last.userRequest === "." && | ||
last.options.recursive | ||
) | ||
parser.state.current.dependencies.pop(); | ||
} | ||
parser.state.module.addPresentationalDependency(dep); | ||
return true; | ||
}); | ||
}); | ||
@@ -79,3 +83,3 @@ | ||
// Handle nested requires | ||
parser.hooks.preStatement.tap("CompatibilityPlugin", statement => { | ||
parser.hooks.preStatement.tap(PLUGIN_NAME, statement => { | ||
if ( | ||
@@ -100,3 +104,3 @@ statement.type === "FunctionDeclaration" && | ||
.for("__webpack_require__") | ||
.tap("CompatibilityPlugin", pattern => { | ||
.tap(PLUGIN_NAME, pattern => { | ||
const newName = `__nested_webpack_require_${pattern.range[0]}__`; | ||
@@ -115,3 +119,3 @@ parser.tagVariable(pattern.name, nestedWebpackRequireTag, { | ||
.for(nestedWebpackRequireTag) | ||
.tap("CompatibilityPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const { name, declaration } = parser.currentTagData; | ||
@@ -131,27 +135,24 @@ if (!declaration.updated) { | ||
// Handle hashbang | ||
parser.hooks.program.tap( | ||
"CompatibilityPlugin", | ||
(program, comments) => { | ||
if (comments.length === 0) return; | ||
const c = comments[0]; | ||
if (c.type === "Line" && c.range[0] === 0) { | ||
if (parser.state.source.slice(0, 2).toString() !== "#!") return; | ||
// this is a hashbang comment | ||
const dep = new ConstDependency("//", 0); | ||
dep.loc = c.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
} | ||
parser.hooks.program.tap(PLUGIN_NAME, (program, comments) => { | ||
if (comments.length === 0) return; | ||
const c = comments[0]; | ||
if (c.type === "Line" && c.range[0] === 0) { | ||
if (parser.state.source.slice(0, 2).toString() !== "#!") return; | ||
// this is a hashbang comment | ||
const dep = new ConstDependency("//", 0); | ||
dep.loc = c.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
} | ||
); | ||
}); | ||
}; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("CompatibilityPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("CompatibilityPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("CompatibilityPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -158,0 +159,0 @@ ); |
@@ -10,2 +10,10 @@ /* | ||
const path = require("path"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JSON_MODULE_TYPE, | ||
WEBASSEMBLY_MODULE_TYPE_ASYNC, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
WEBASSEMBLY_MODULE_TYPE_SYNC | ||
} = require("../ModuleTypeConstants"); | ||
const Template = require("../Template"); | ||
@@ -521,3 +529,3 @@ const { cleverMerge } = require("../util/cleverMerge"); | ||
const esm = { | ||
type: "javascript/esm", | ||
type: JAVASCRIPT_MODULE_TYPE_ESM, | ||
resolve: { | ||
@@ -532,3 +540,3 @@ byDependency: { | ||
const commonjs = { | ||
type: "javascript/dynamic" | ||
type: JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
}; | ||
@@ -539,11 +547,11 @@ /** @type {RuleSetRules} */ | ||
mimetype: "application/node", | ||
type: "javascript/auto" | ||
type: JAVASCRIPT_MODULE_TYPE_AUTO | ||
}, | ||
{ | ||
test: /\.json$/i, | ||
type: "json" | ||
type: JSON_MODULE_TYPE | ||
}, | ||
{ | ||
mimetype: "application/json", | ||
type: "json" | ||
type: JSON_MODULE_TYPE | ||
}, | ||
@@ -581,3 +589,3 @@ { | ||
const wasm = { | ||
type: "webassembly/async", | ||
type: WEBASSEMBLY_MODULE_TYPE_ASYNC, | ||
rules: [ | ||
@@ -604,3 +612,3 @@ { | ||
const wasm = { | ||
type: "webassembly/sync", | ||
type: WEBASSEMBLY_MODULE_TYPE_SYNC, | ||
rules: [ | ||
@@ -676,3 +684,3 @@ { | ||
assert: { type: "json" }, | ||
type: "json" | ||
type: JSON_MODULE_TYPE | ||
} | ||
@@ -679,0 +687,0 @@ ); |
@@ -343,2 +343,6 @@ /* | ||
: libraryBase.auxiliaryComment, | ||
amdContainer: | ||
output.amdContainer !== undefined | ||
? output.amdContainer | ||
: libraryBase.amdContainer, | ||
export: | ||
@@ -345,0 +349,0 @@ output.libraryExport !== undefined |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const CachedConstDependency = require("./dependencies/CachedConstDependency"); | ||
@@ -112,2 +117,4 @@ const ConstDependency = require("./dependencies/ConstDependency"); | ||
const PLUGIN_NAME = "ConstPlugin"; | ||
class ConstPlugin { | ||
@@ -122,3 +129,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"ConstPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -136,3 +143,3 @@ compilation.dependencyTemplates.set( | ||
const handler = parser => { | ||
parser.hooks.statementIf.tap("ConstPlugin", statement => { | ||
parser.hooks.statementIf.tap(PLUGIN_NAME, statement => { | ||
if (parser.scope.isAsmJs) return; | ||
@@ -209,3 +216,3 @@ const param = parser.evaluateExpression(statement.test); | ||
parser.hooks.expressionConditionalOperator.tap( | ||
"ConstPlugin", | ||
PLUGIN_NAME, | ||
expression => { | ||
@@ -245,3 +252,3 @@ if (parser.scope.isAsmJs) return; | ||
parser.hooks.expressionLogicalOperator.tap( | ||
"ConstPlugin", | ||
PLUGIN_NAME, | ||
expression => { | ||
@@ -383,3 +390,3 @@ if (parser.scope.isAsmJs) return; | ||
); | ||
parser.hooks.optionalChaining.tap("ConstPlugin", expr => { | ||
parser.hooks.optionalChaining.tap(PLUGIN_NAME, expr => { | ||
/** @type {ExpressionNode[]} */ | ||
@@ -439,3 +446,3 @@ const optionalExpressionsStack = []; | ||
.for("__resourceQuery") | ||
.tap("ConstPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (parser.scope.isAsmJs) return; | ||
@@ -449,3 +456,3 @@ if (!parser.state.module) return; | ||
.for("__resourceQuery") | ||
.tap("ConstPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (parser.scope.isAsmJs) return; | ||
@@ -467,3 +474,3 @@ if (!parser.state.module) return; | ||
.for("__resourceFragment") | ||
.tap("ConstPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (parser.scope.isAsmJs) return; | ||
@@ -477,3 +484,3 @@ if (!parser.state.module) return; | ||
.for("__resourceFragment") | ||
.tap("ConstPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (parser.scope.isAsmJs) return; | ||
@@ -495,10 +502,10 @@ if (!parser.state.module) return; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ConstPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("ConstPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ConstPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -505,0 +512,0 @@ ); |
@@ -11,2 +11,3 @@ /* | ||
const Module = require("../Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -48,3 +49,3 @@ const Template = require("../Template"); | ||
constructor(name, exposes, shareScope) { | ||
super("javascript/dynamic", null); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); | ||
this._name = name; | ||
@@ -51,0 +52,0 @@ this._exposes = exposes; |
@@ -12,2 +12,3 @@ /* | ||
const Module = require("./Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -109,3 +110,3 @@ const Template = require("./Template"); | ||
super("javascript/dynamic", resource); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, resource); | ||
/** @type {ContextModuleOptions} */ | ||
@@ -119,3 +120,3 @@ this.options = { | ||
} else { | ||
super("javascript/dynamic"); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC); | ||
/** @type {ContextModuleOptions} */ | ||
@@ -122,0 +123,0 @@ this.options = { |
@@ -141,2 +141,3 @@ /* | ||
const modeStack = []; | ||
let awaitRightParenthesis = false; | ||
const isTopLevelLocal = () => | ||
@@ -300,2 +301,3 @@ modeData === "local" || | ||
}; | ||
const eatAtRuleNested = eatUntil("{};/"); | ||
const eatKeyframes = eatUntil("{};/"); | ||
@@ -385,2 +387,14 @@ const eatNameInVar = eatUntil(",)};/"); | ||
} | ||
if (name === "@media" || name === "@supports") { | ||
let pos = end; | ||
const [newPos] = eatText(input, pos, eatAtRuleNested); | ||
pos = newPos; | ||
if (pos === input.length) return pos; | ||
if (input.charCodeAt(pos) !== CC_LEFT_CURLY) { | ||
throw new Error( | ||
`Unexpected ${input[pos]} at ${pos} during parsing of @media or @supports (expected '{')` | ||
); | ||
} | ||
return pos + 1; | ||
} | ||
return end; | ||
@@ -517,2 +531,5 @@ }, | ||
case CSS_MODE_TOP_LEVEL: { | ||
if (awaitRightParenthesis) { | ||
awaitRightParenthesis = false; | ||
} | ||
const newModeData = modeStack.pop(); | ||
@@ -568,2 +585,3 @@ if (newModeData !== false) { | ||
} else { | ||
awaitRightParenthesis = true; | ||
modeStack.push(false); | ||
@@ -605,4 +623,6 @@ } | ||
case CSS_MODE_TOP_LEVEL: | ||
modeData = undefined; | ||
modeStack.length = 0; | ||
if (!awaitRightParenthesis) { | ||
modeData = undefined; | ||
modeStack.length = 0; | ||
} | ||
break; | ||
@@ -609,0 +629,0 @@ case CSS_MODE_IN_LOCAL_RULE: |
@@ -8,2 +8,10 @@ /* | ||
const { Tracer } = require("chrome-trace-event"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
WEBASSEMBLY_MODULE_TYPE_ASYNC, | ||
WEBASSEMBLY_MODULE_TYPE_SYNC, | ||
JSON_MODULE_TYPE | ||
} = require("../ModuleTypeConstants"); | ||
const createSchemaValidation = require("../util/create-schema-validation"); | ||
@@ -186,3 +194,3 @@ const { dirname, mkdirpSync } = require("../util/fs"); | ||
const pluginName = "ProfilingPlugin"; | ||
const PLUGIN_NAME = "ProfilingPlugin"; | ||
@@ -221,3 +229,3 @@ class ProfilingPlugin { | ||
compiler.hooks.compilation.tap( | ||
pluginName, | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory, contextModuleFactory }) => { | ||
@@ -243,3 +251,3 @@ interceptAllHooksFor(compilation, tracer, "Compilation"); | ||
{ | ||
name: pluginName, | ||
name: PLUGIN_NAME, | ||
stage: Infinity | ||
@@ -319,8 +327,8 @@ }, | ||
const moduleTypes = [ | ||
"javascript/auto", | ||
"javascript/dynamic", | ||
"javascript/esm", | ||
"json", | ||
"webassembly/async", | ||
"webassembly/sync" | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
JSON_MODULE_TYPE, | ||
WEBASSEMBLY_MODULE_TYPE_ASYNC, | ||
WEBASSEMBLY_MODULE_TYPE_SYNC | ||
]; | ||
@@ -331,3 +339,3 @@ | ||
.for(moduleType) | ||
.tap("ProfilingPlugin", (parser, parserOpts) => { | ||
.tap(PLUGIN_NAME, (parser, parserOpts) => { | ||
interceptAllHooksFor(parser, tracer, "Parser"); | ||
@@ -356,3 +364,3 @@ }); | ||
// Don't tap our own hooks to ensure stream can close cleanly | ||
name === pluginName | ||
name === PLUGIN_NAME | ||
? fn | ||
@@ -428,3 +436,3 @@ : makeNewProfiledTapFn(hookName, tracer, { | ||
// profile needing to be the last event in the trace. | ||
if (name === pluginName) { | ||
if (name === PLUGIN_NAME) { | ||
return fn(...args); | ||
@@ -431,0 +439,0 @@ } |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -13,2 +18,3 @@ const WebpackError = require("./WebpackError"); | ||
const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression"); | ||
const { | ||
@@ -254,4 +260,8 @@ evaluateToString, | ||
const VALUE_DEP_PREFIX = "webpack/DefinePlugin "; | ||
const VALUE_DEP_MAIN = "webpack/DefinePlugin_hash"; | ||
const PLUGIN_NAME = "DefinePlugin"; | ||
const VALUE_DEP_PREFIX = `webpack/${PLUGIN_NAME} `; | ||
const VALUE_DEP_MAIN = `webpack/${PLUGIN_NAME}_hash`; | ||
const TYPEOF_OPERATOR_REGEXP = /^typeof\s+/; | ||
const WEBPACK_REQUIRE_FUNCTION_REGEXP = /__webpack_require__\s*(!?\.)/; | ||
const WEBPACK_REQUIRE_IDENTIFIER_REGEXP = /__webpack_require__/; | ||
@@ -284,3 +294,3 @@ class DefinePlugin { | ||
compiler.hooks.compilation.tap( | ||
"DefinePlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -307,3 +317,3 @@ compilation.dependencyTemplates.set( | ||
const mainValue = compilation.valueCacheVersions.get(VALUE_DEP_MAIN); | ||
parser.hooks.program.tap("DefinePlugin", () => { | ||
parser.hooks.program.tap(PLUGIN_NAME, () => { | ||
const { buildInfo } = parser.state.module; | ||
@@ -364,3 +374,3 @@ if (!buildInfo.valueDependencies) | ||
const fullKey = prefix + splittedKey.slice(0, i + 1).join("."); | ||
parser.hooks.canRename.for(fullKey).tap("DefinePlugin", () => { | ||
parser.hooks.canRename.for(fullKey).tap(PLUGIN_NAME, () => { | ||
addValueDependency(key); | ||
@@ -380,8 +390,8 @@ return true; | ||
const originalKey = key; | ||
const isTypeof = /^typeof\s+/.test(key); | ||
if (isTypeof) key = key.replace(/^typeof\s+/, ""); | ||
const isTypeof = TYPEOF_OPERATOR_REGEXP.test(key); | ||
if (isTypeof) key = key.replace(TYPEOF_OPERATOR_REGEXP, ""); | ||
let recurse = false; | ||
let recurseTypeof = false; | ||
if (!isTypeof) { | ||
parser.hooks.canRename.for(key).tap("DefinePlugin", () => { | ||
parser.hooks.canRename.for(key).tap(PLUGIN_NAME, () => { | ||
addValueDependency(originalKey); | ||
@@ -392,3 +402,3 @@ return true; | ||
.for(key) | ||
.tap("DefinePlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
/** | ||
@@ -419,3 +429,3 @@ * this is needed in case there is a recursion in the DefinePlugin | ||
}); | ||
parser.hooks.expression.for(key).tap("DefinePlugin", expr => { | ||
parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => { | ||
addValueDependency(originalKey); | ||
@@ -430,7 +440,7 @@ const strCode = toCode( | ||
); | ||
if (/__webpack_require__\s*(!?\.)/.test(strCode)) { | ||
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) { | ||
return toConstantDependency(parser, strCode, [ | ||
RuntimeGlobals.require | ||
])(expr); | ||
} else if (/__webpack_require__/.test(strCode)) { | ||
} else if (WEBPACK_REQUIRE_IDENTIFIER_REGEXP.test(strCode)) { | ||
return toConstantDependency(parser, strCode, [ | ||
@@ -444,3 +454,3 @@ RuntimeGlobals.requireScope | ||
} | ||
parser.hooks.evaluateTypeof.for(key).tap("DefinePlugin", expr => { | ||
parser.hooks.evaluateTypeof.for(key).tap(PLUGIN_NAME, expr => { | ||
/** | ||
@@ -473,3 +483,3 @@ * this is needed in case there is a recursion in the DefinePlugin | ||
}); | ||
parser.hooks.typeof.for(key).tap("DefinePlugin", expr => { | ||
parser.hooks.typeof.for(key).tap(PLUGIN_NAME, expr => { | ||
addValueDependency(originalKey); | ||
@@ -503,22 +513,20 @@ const codeCode = toCode( | ||
const applyObjectDefine = (key, obj) => { | ||
parser.hooks.canRename.for(key).tap("DefinePlugin", () => { | ||
parser.hooks.canRename.for(key).tap(PLUGIN_NAME, () => { | ||
addValueDependency(key); | ||
return true; | ||
}); | ||
parser.hooks.evaluateIdentifier | ||
.for(key) | ||
.tap("DefinePlugin", expr => { | ||
addValueDependency(key); | ||
return new BasicEvaluatedExpression() | ||
.setTruthy() | ||
.setSideEffects(false) | ||
.setRange(expr.range); | ||
}); | ||
parser.hooks.evaluateIdentifier.for(key).tap(PLUGIN_NAME, expr => { | ||
addValueDependency(key); | ||
return new BasicEvaluatedExpression() | ||
.setTruthy() | ||
.setSideEffects(false) | ||
.setRange(expr.range); | ||
}); | ||
parser.hooks.evaluateTypeof | ||
.for(key) | ||
.tap( | ||
"DefinePlugin", | ||
PLUGIN_NAME, | ||
withValueDependency(key, evaluateToString("object")) | ||
); | ||
parser.hooks.expression.for(key).tap("DefinePlugin", expr => { | ||
parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => { | ||
addValueDependency(key); | ||
@@ -534,7 +542,7 @@ const strCode = stringifyObj( | ||
if (/__webpack_require__\s*(!?\.)/.test(strCode)) { | ||
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) { | ||
return toConstantDependency(parser, strCode, [ | ||
RuntimeGlobals.require | ||
])(expr); | ||
} else if (/__webpack_require__/.test(strCode)) { | ||
} else if (WEBPACK_REQUIRE_IDENTIFIER_REGEXP.test(strCode)) { | ||
return toConstantDependency(parser, strCode, [ | ||
@@ -550,3 +558,3 @@ RuntimeGlobals.requireScope | ||
.tap( | ||
"DefinePlugin", | ||
PLUGIN_NAME, | ||
withValueDependency( | ||
@@ -563,10 +571,10 @@ key, | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("DefinePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("DefinePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("DefinePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
@@ -590,3 +598,3 @@ /** | ||
const warning = new WebpackError( | ||
`DefinePlugin\nConflicting values for '${prefix + key}'` | ||
`${PLUGIN_NAME}\nConflicting values for '${prefix + key}'` | ||
); | ||
@@ -593,0 +601,0 @@ warning.details = `'${oldVersion}' !== '${version}'`; |
@@ -10,2 +10,3 @@ /* | ||
const Module = require("./Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -44,3 +45,3 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency"); | ||
constructor(sourceRequest, data, type, userRequest, originalRequest) { | ||
super("javascript/dynamic", null); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); | ||
@@ -47,0 +48,0 @@ // Info from Factory |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -35,2 +39,4 @@ const { | ||
const PLUGIN_NAME = "AMDPlugin"; | ||
class AMDPlugin { | ||
@@ -52,3 +58,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { contextModuleFactory, normalModuleFactory }) => { | ||
@@ -100,3 +106,3 @@ compilation.dependencyTemplates.set( | ||
.for(RuntimeGlobals.amdDefine) | ||
.tap("AMDPlugin", (module, set) => { | ||
.tap(PLUGIN_NAME, (module, set) => { | ||
set.add(RuntimeGlobals.require); | ||
@@ -107,3 +113,3 @@ }); | ||
.for(RuntimeGlobals.amdOptions) | ||
.tap("AMDPlugin", (module, set) => { | ||
.tap(PLUGIN_NAME, (module, set) => { | ||
set.add(RuntimeGlobals.requireScope); | ||
@@ -114,3 +120,3 @@ }); | ||
.for(RuntimeGlobals.amdDefine) | ||
.tap("AMDPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule()); | ||
@@ -121,3 +127,3 @@ }); | ||
.for(RuntimeGlobals.amdOptions) | ||
.tap("AMDPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule( | ||
@@ -136,3 +142,3 @@ chunk, | ||
.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, RuntimeGlobals.amdOptions, [ | ||
@@ -145,3 +151,3 @@ RuntimeGlobals.amdOptions | ||
.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
evaluateToIdentifier(optionExpr, rootName, getMembers, true) | ||
@@ -151,7 +157,7 @@ ); | ||
.for(optionExpr) | ||
.tap("AMDPlugin", evaluateToString("object")); | ||
.tap(PLUGIN_NAME, evaluateToString("object")); | ||
parser.hooks.typeof | ||
.for(optionExpr) | ||
.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("object")) | ||
@@ -174,3 +180,3 @@ ); | ||
parser.hooks.expression.for("define").tap("AMDPlugin", expr => { | ||
parser.hooks.expression.for("define").tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
@@ -188,3 +194,3 @@ RuntimeGlobals.amdDefine, | ||
.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("function")) | ||
@@ -194,5 +200,5 @@ ); | ||
.for("define") | ||
.tap("AMDPlugin", evaluateToString("function")); | ||
parser.hooks.canRename.for("define").tap("AMDPlugin", approve); | ||
parser.hooks.rename.for("define").tap("AMDPlugin", expr => { | ||
.tap(PLUGIN_NAME, evaluateToString("function")); | ||
parser.hooks.canRename.for("define").tap(PLUGIN_NAME, approve); | ||
parser.hooks.rename.for("define").tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
@@ -210,3 +216,3 @@ RuntimeGlobals.amdDefine, | ||
.tap( | ||
"AMDPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("function")) | ||
@@ -216,11 +222,11 @@ ); | ||
.for("require") | ||
.tap("AMDPlugin", evaluateToString("function")); | ||
.tap(PLUGIN_NAME, evaluateToString("function")); | ||
}; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("AMDPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("AMDPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -227,0 +233,0 @@ ); |
@@ -447,9 +447,10 @@ /* | ||
let moduleName; | ||
let moduleName = []; | ||
let specifierName; | ||
if (options.createRequire === true) { | ||
moduleName = "module"; | ||
moduleName = ["module", "node:module"]; | ||
specifierName = "createRequire"; | ||
} else { | ||
let moduleName; | ||
const match = /^(.*) from (.*)$/.exec(options.createRequire); | ||
@@ -549,3 +550,3 @@ if (match) { | ||
if ( | ||
source !== moduleName || | ||
!moduleName.includes(source) || | ||
statement.specifiers.length !== 1 || | ||
@@ -575,3 +576,3 @@ statement.specifiers[0].type !== "ImportSpecifier" || | ||
(statement, source, id, name) => { | ||
if (source !== moduleName || id !== specifierName) return; | ||
if (!moduleName.includes(source) || id !== specifierName) return; | ||
parser.tagVariable(name, createRequireSpecifierTag); | ||
@@ -578,0 +579,0 @@ return true; |
@@ -28,2 +28,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const { | ||
evaluateToIdentifier, | ||
@@ -34,6 +38,8 @@ toConstantDependency | ||
const PLUGIN_NAME = "CommonJsPlugin"; | ||
class CommonJsPlugin { | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"CommonJsPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { contextModuleFactory, normalModuleFactory }) => { | ||
@@ -131,3 +137,3 @@ compilation.dependencyFactories.set( | ||
.for(RuntimeGlobals.harmonyModuleDecorator) | ||
.tap("CommonJsPlugin", (module, set) => { | ||
.tap(PLUGIN_NAME, (module, set) => { | ||
set.add(RuntimeGlobals.module); | ||
@@ -139,3 +145,3 @@ set.add(RuntimeGlobals.requireScope); | ||
.for(RuntimeGlobals.nodeModuleDecorator) | ||
.tap("CommonJsPlugin", (module, set) => { | ||
.tap(PLUGIN_NAME, (module, set) => { | ||
set.add(RuntimeGlobals.module); | ||
@@ -147,3 +153,3 @@ set.add(RuntimeGlobals.requireScope); | ||
.for(RuntimeGlobals.harmonyModuleDecorator) | ||
.tap("CommonJsPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule( | ||
@@ -157,3 +163,3 @@ chunk, | ||
.for(RuntimeGlobals.nodeModuleDecorator) | ||
.tap("CommonJsPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule( | ||
@@ -171,3 +177,3 @@ chunk, | ||
.tap( | ||
"CommonJsPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("object")) | ||
@@ -179,3 +185,3 @@ ); | ||
.tap( | ||
"CommonJsPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency( | ||
@@ -189,3 +195,3 @@ parser, | ||
.for("module.loaded") | ||
.tap("CommonJsPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = | ||
@@ -201,17 +207,15 @@ "module.loaded"; | ||
parser.hooks.expression | ||
.for("module.id") | ||
.tap("CommonJsPlugin", expr => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = | ||
"module.id"; | ||
const dep = new RuntimeRequirementsDependency([ | ||
RuntimeGlobals.moduleId | ||
]); | ||
dep.loc = expr.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
return true; | ||
}); | ||
parser.hooks.expression.for("module.id").tap(PLUGIN_NAME, expr => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = | ||
"module.id"; | ||
const dep = new RuntimeRequirementsDependency([ | ||
RuntimeGlobals.moduleId | ||
]); | ||
dep.loc = expr.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
return true; | ||
}); | ||
parser.hooks.evaluateIdentifier.for("module.hot").tap( | ||
"CommonJsPlugin", | ||
PLUGIN_NAME, | ||
evaluateToIdentifier("module.hot", "module", () => ["hot"], null) | ||
@@ -227,7 +231,7 @@ ); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("CommonJsPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("CommonJsPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -234,0 +238,0 @@ ); |
@@ -8,2 +8,3 @@ /* | ||
const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants"); | ||
const DynamicExports = require("./DynamicExports"); | ||
@@ -21,3 +22,4 @@ const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency"); | ||
parser.hooks.program.tap("HarmonyDetectionParserPlugin", ast => { | ||
const isStrictHarmony = parser.state.module.type === "javascript/esm"; | ||
const isStrictHarmony = | ||
parser.state.module.type === JAVASCRIPT_MODULE_TYPE_ESM; | ||
const isHarmony = | ||
@@ -24,0 +26,0 @@ isStrictHarmony || |
@@ -19,2 +19,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin"); | ||
@@ -27,2 +31,4 @@ const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin"); | ||
const PLUGIN_NAME = "HarmonyModulesPlugin"; | ||
class HarmonyModulesPlugin { | ||
@@ -40,3 +46,3 @@ constructor(options) { | ||
compiler.hooks.compilation.tap( | ||
"HarmonyModulesPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -125,7 +131,7 @@ compilation.dependencyTemplates.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("HarmonyModulesPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("HarmonyModulesPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -132,0 +138,0 @@ ); |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const ContextElementDependency = require("./ContextElementDependency"); | ||
@@ -16,2 +20,4 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency"); | ||
const PLUGIN_NAME = "ImportMetaContextPlugin"; | ||
class ImportMetaContextPlugin { | ||
@@ -25,3 +31,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"RequireContextPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { contextModuleFactory, normalModuleFactory }) => { | ||
@@ -52,7 +58,7 @@ compilation.dependencyFactories.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ImportMetaContextPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ImportMetaContextPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -59,0 +65,0 @@ ); |
@@ -10,2 +10,6 @@ /* | ||
const ModuleDependencyWarning = require("../ModuleDependencyWarning"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const Template = require("../Template"); | ||
@@ -33,2 +37,4 @@ const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression"); | ||
const PLUGIN_NAME = "ImportMetaPlugin"; | ||
class ImportMetaPlugin { | ||
@@ -40,3 +46,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -62,3 +68,3 @@ /** | ||
.for("import.meta") | ||
.tap("ImportMetaPlugin", metaProperty => { | ||
.tap(PLUGIN_NAME, metaProperty => { | ||
const dep = new ConstDependency( | ||
@@ -79,3 +85,3 @@ importMetaName, | ||
.tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("object")) | ||
@@ -85,3 +91,3 @@ ); | ||
.for("import.meta") | ||
.tap("ImportMetaPlugin", metaProperty => { | ||
.tap(PLUGIN_NAME, metaProperty => { | ||
const CriticalDependencyWarning = getCriticalDependencyWarning(); | ||
@@ -107,5 +113,5 @@ parser.state.module.addWarning( | ||
.for("import.meta") | ||
.tap("ImportMetaPlugin", evaluateToString("object")); | ||
.tap(PLUGIN_NAME, evaluateToString("object")); | ||
parser.hooks.evaluateIdentifier.for("import.meta").tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
evaluateToIdentifier("import.meta", "import.meta", () => [], true) | ||
@@ -118,3 +124,3 @@ ); | ||
.tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("string")) | ||
@@ -124,3 +130,3 @@ ); | ||
.for("import.meta.url") | ||
.tap("ImportMetaPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
@@ -136,6 +142,6 @@ JSON.stringify(getUrl(parser.state.module)), | ||
.for("import.meta.url") | ||
.tap("ImportMetaPlugin", evaluateToString("string")); | ||
.tap(PLUGIN_NAME, evaluateToString("string")); | ||
parser.hooks.evaluateIdentifier | ||
.for("import.meta.url") | ||
.tap("ImportMetaPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
return new BasicEvaluatedExpression() | ||
@@ -154,3 +160,3 @@ .setString(getUrl(parser.state.module)) | ||
.tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("number")) | ||
@@ -161,3 +167,3 @@ ); | ||
.tap( | ||
"ImportMetaPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify(webpackVersion)) | ||
@@ -167,6 +173,6 @@ ); | ||
.for("import.meta.webpack") | ||
.tap("ImportMetaPlugin", evaluateToString("number")); | ||
.tap(PLUGIN_NAME, evaluateToString("number")); | ||
parser.hooks.evaluateIdentifier | ||
.for("import.meta.webpack") | ||
.tap("ImportMetaPlugin", evaluateToNumber(webpackVersion)); | ||
.tap(PLUGIN_NAME, evaluateToNumber(webpackVersion)); | ||
@@ -176,3 +182,3 @@ /// Unknown properties /// | ||
.for("import.meta") | ||
.tap("ImportMetaPlugin", (expr, members) => { | ||
.tap(PLUGIN_NAME, (expr, members) => { | ||
const dep = new ConstDependency( | ||
@@ -190,3 +196,3 @@ `${Template.toNormalComment( | ||
.for("MemberExpression") | ||
.tap("ImportMetaPlugin", expression => { | ||
.tap(PLUGIN_NAME, expression => { | ||
const expr = /** @type {MemberExpression} */ (expression); | ||
@@ -208,7 +214,7 @@ if ( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ImportMetaPlugin", parserHandler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, parserHandler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ImportMetaPlugin", parserHandler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, parserHandler); | ||
} | ||
@@ -215,0 +221,0 @@ ); |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const ImportContextDependency = require("./ImportContextDependency"); | ||
@@ -17,2 +22,4 @@ const ImportDependency = require("./ImportDependency"); | ||
const PLUGIN_NAME = "ImportPlugin"; | ||
class ImportPlugin { | ||
@@ -26,3 +33,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"ImportPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { contextModuleFactory, normalModuleFactory }) => { | ||
@@ -73,10 +80,10 @@ compilation.dependencyFactories.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ImportPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("ImportPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ImportPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -83,0 +90,0 @@ ); |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const { cachedSetProperty } = require("../util/cleverMerge"); | ||
@@ -20,2 +24,4 @@ const ContextElementDependency = require("./ContextElementDependency"); | ||
const PLUGIN_NAME = "RequireContextPlugin"; | ||
class RequireContextPlugin { | ||
@@ -29,3 +35,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"RequireContextPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { contextModuleFactory, normalModuleFactory }) => { | ||
@@ -57,10 +63,10 @@ compilation.dependencyFactories.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("RequireContextPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("RequireContextPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
contextModuleFactory.hooks.alternativeRequests.tap( | ||
"RequireContextPlugin", | ||
PLUGIN_NAME, | ||
(items, options) => { | ||
@@ -67,0 +73,0 @@ if (items.length === 0) return items; |
@@ -14,2 +14,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const { | ||
evaluateToString, | ||
@@ -19,6 +23,8 @@ toConstantDependency | ||
const PLUGIN_NAME = "RequireEnsurePlugin"; | ||
class RequireEnsurePlugin { | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"RequireEnsurePlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -49,7 +55,7 @@ compilation.dependencyFactories.set( | ||
.for("require.ensure") | ||
.tap("RequireEnsurePlugin", evaluateToString("function")); | ||
.tap(PLUGIN_NAME, evaluateToString("function")); | ||
parser.hooks.typeof | ||
.for("require.ensure") | ||
.tap( | ||
"RequireEnsurePlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("function")) | ||
@@ -60,7 +66,7 @@ ); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("RequireEnsurePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("RequireEnsurePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -67,0 +73,0 @@ ); |
@@ -8,9 +8,15 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const RequireIncludeDependency = require("./RequireIncludeDependency"); | ||
const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin"); | ||
const PLUGIN_NAME = "RequireIncludePlugin"; | ||
class RequireIncludePlugin { | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"RequireIncludePlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -34,7 +40,7 @@ compilation.dependencyFactories.set( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("RequireIncludePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("RequireIncludePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -41,0 +47,0 @@ ); |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -22,2 +26,4 @@ const WebpackError = require("../WebpackError"); | ||
const PLUGIN_NAME = "SystemPlugin"; | ||
class SystemPlugin { | ||
@@ -31,7 +37,7 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"SystemPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
compilation.hooks.runtimeRequirementInModule | ||
.for(RuntimeGlobals.system) | ||
.tap("SystemPlugin", (module, set) => { | ||
.tap(PLUGIN_NAME, (module, set) => { | ||
set.add(RuntimeGlobals.requireScope); | ||
@@ -42,3 +48,3 @@ }); | ||
.for(RuntimeGlobals.system) | ||
.tap("SystemPlugin", (chunk, set) => { | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
compilation.addRuntimeModule(chunk, new SystemRuntimeModule()); | ||
@@ -55,7 +61,7 @@ }); | ||
.for(name) | ||
.tap("SystemPlugin", evaluateToString("undefined")); | ||
.tap(PLUGIN_NAME, evaluateToString("undefined")); | ||
parser.hooks.expression | ||
.for(name) | ||
.tap( | ||
"SystemPlugin", | ||
PLUGIN_NAME, | ||
expressionIsUnsupported( | ||
@@ -71,3 +77,3 @@ parser, | ||
.tap( | ||
"SystemPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("function")) | ||
@@ -77,7 +83,7 @@ ); | ||
.for("System.import") | ||
.tap("SystemPlugin", evaluateToString("function")); | ||
.tap(PLUGIN_NAME, evaluateToString("function")); | ||
parser.hooks.typeof | ||
.for("System") | ||
.tap( | ||
"SystemPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("object")) | ||
@@ -87,3 +93,3 @@ ); | ||
.for("System") | ||
.tap("SystemPlugin", evaluateToString("object")); | ||
.tap(PLUGIN_NAME, evaluateToString("object")); | ||
@@ -94,3 +100,3 @@ setNotSupported("System.set"); | ||
parser.hooks.expression.for("System").tap("SystemPlugin", expr => { | ||
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency(RuntimeGlobals.system, expr.range, [ | ||
@@ -104,3 +110,3 @@ RuntimeGlobals.system | ||
parser.hooks.call.for("System.import").tap("SystemPlugin", expr => { | ||
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => { | ||
parser.state.module.addWarning( | ||
@@ -120,7 +126,7 @@ new SystemImportDeprecationWarning(expr.loc) | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("SystemPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("SystemPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -127,0 +133,0 @@ ); |
@@ -9,2 +9,6 @@ /* | ||
const { pathToFileURL } = require("url"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression"); | ||
@@ -20,2 +24,4 @@ const { approve } = require("../javascript/JavascriptParserHelpers"); | ||
const PLUGIN_NAME = "URLPlugin"; | ||
class URLPlugin { | ||
@@ -27,3 +33,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"URLPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -82,6 +88,6 @@ compilation.dependencyFactories.set(URLDependency, normalModuleFactory); | ||
parser.hooks.canRename.for("URL").tap("URLPlugin", approve); | ||
parser.hooks.canRename.for("URL").tap(PLUGIN_NAME, approve); | ||
parser.hooks.evaluateNewExpression | ||
.for("URL") | ||
.tap("URLPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const request = getUrlRequest(expr); | ||
@@ -95,3 +101,3 @@ if (!request) return; | ||
}); | ||
parser.hooks.new.for("URL").tap("URLPlugin", _expr => { | ||
parser.hooks.new.for("URL").tap(PLUGIN_NAME, _expr => { | ||
const expr = /** @type {NewExpressionNode} */ (_expr); | ||
@@ -115,3 +121,3 @@ | ||
}); | ||
parser.hooks.isPure.for("NewExpression").tap("URLPlugin", _expr => { | ||
parser.hooks.isPure.for("NewExpression").tap(PLUGIN_NAME, _expr => { | ||
const expr = /** @type {NewExpressionNode} */ (_expr); | ||
@@ -130,8 +136,8 @@ const { callee } = expr; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("URLPlugin", parserCallback); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, parserCallback); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("URLPlugin", parserCallback); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, parserCallback); | ||
} | ||
@@ -138,0 +144,0 @@ ); |
@@ -11,2 +11,6 @@ /* | ||
const CommentCompilationWarning = require("../CommentCompilationWarning"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning"); | ||
@@ -51,2 +55,4 @@ const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin"); | ||
const PLUGIN_NAME = "WorkerPlugin"; | ||
class WorkerPlugin { | ||
@@ -76,3 +82,3 @@ constructor(chunkLoading, wasmLoading, module, workerPublicPath) { | ||
compiler.hooks.thisCompilation.tap( | ||
"WorkerPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -381,3 +387,3 @@ compilation.dependencyFactories.set( | ||
.for(item.slice(0, -2)) | ||
.tap("WorkerPlugin", handleNewWorker); | ||
.tap(PLUGIN_NAME, handleNewWorker); | ||
} else { | ||
@@ -391,3 +397,3 @@ const match = /^(.+?)(\(\))?\s+from\s+(.+)$/.exec(item); | ||
.for(harmonySpecifierTag) | ||
.tap("WorkerPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const settings = /** @type {HarmonySettings} */ ( | ||
@@ -406,3 +412,3 @@ parser.currentTagData | ||
} else { | ||
parser.hooks.new.for(item).tap("WorkerPlugin", handleNewWorker); | ||
parser.hooks.new.for(item).tap(PLUGIN_NAME, handleNewWorker); | ||
} | ||
@@ -418,7 +424,7 @@ } | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("WorkerPlugin", parserPlugin); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, parserPlugin); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("WorkerPlugin", parserPlugin); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, parserPlugin); | ||
} | ||
@@ -425,0 +431,0 @@ ); |
@@ -10,2 +10,3 @@ /* | ||
const Module = require("./Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -39,3 +40,3 @@ const makeSerializable = require("./util/makeSerializable"); | ||
constructor(context, dependencies, name) { | ||
super("javascript/dynamic", context); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, context); | ||
@@ -42,0 +43,0 @@ // Info from Factory |
@@ -12,26 +12,42 @@ /* | ||
exports.cutOffByFlag = (stack, flag) => { | ||
stack = stack.split("\n"); | ||
for (let i = 0; i < stack.length; i++) { | ||
if (stack[i].includes(flag)) { | ||
stack.length = i; | ||
/** | ||
* @param {string} stack stack trace | ||
* @param {string} flag flag to cut off | ||
* @returns {string} stack trace without the specified flag included | ||
*/ | ||
const cutOffByFlag = (stack, flag) => { | ||
const errorStack = stack.split("\n"); | ||
for (let i = 0; i < errorStack.length; i++) { | ||
if (errorStack[i].includes(flag)) { | ||
errorStack.length = i; | ||
} | ||
} | ||
return stack.join("\n"); | ||
return errorStack.join("\n"); | ||
}; | ||
exports.cutOffLoaderExecution = stack => | ||
exports.cutOffByFlag(stack, loaderFlag); | ||
/** | ||
* @param {string} stack stack trace | ||
* @returns {string} stack trace without the loader execution flag included | ||
*/ | ||
const cutOffLoaderExecution = stack => cutOffByFlag(stack, loaderFlag); | ||
exports.cutOffWebpackOptions = stack => | ||
exports.cutOffByFlag(stack, webpackOptionsFlag); | ||
/** | ||
* @param {string} stack stack trace | ||
* @returns {string} stack trace without the webpack options flag included | ||
*/ | ||
const cutOffWebpackOptions = stack => cutOffByFlag(stack, webpackOptionsFlag); | ||
exports.cutOffMultilineMessage = (stack, message) => { | ||
stack = stack.split("\n"); | ||
message = message.split("\n"); | ||
/** | ||
* @param {string} stack stack trace | ||
* @param {string} message error message | ||
* @returns {string} stack trace without the message included | ||
*/ | ||
const cutOffMultilineMessage = (stack, message) => { | ||
const stackSplitByLines = stack.split("\n"); | ||
const messageSplitByLines = message.split("\n"); | ||
const result = []; | ||
stack.forEach((line, idx) => { | ||
if (!line.includes(message[idx])) result.push(line); | ||
stackSplitByLines.forEach((line, idx) => { | ||
if (!line.includes(messageSplitByLines[idx])) result.push(line); | ||
}); | ||
@@ -42,3 +58,8 @@ | ||
exports.cutOffMessage = (stack, message) => { | ||
/** | ||
* @param {string} stack stack trace | ||
* @param {string} message error message | ||
* @returns {string} stack trace without the message included | ||
*/ | ||
const cutOffMessage = (stack, message) => { | ||
const nextLine = stack.indexOf("\n"); | ||
@@ -53,12 +74,30 @@ if (nextLine === -1) { | ||
exports.cleanUp = (stack, message) => { | ||
stack = exports.cutOffLoaderExecution(stack); | ||
stack = exports.cutOffMessage(stack, message); | ||
/** | ||
* @param {string} stack stack trace | ||
* @param {string} message error message | ||
* @returns {string} stack trace without the loader execution flag and message included | ||
*/ | ||
const cleanUp = (stack, message) => { | ||
stack = cutOffLoaderExecution(stack); | ||
stack = cutOffMessage(stack, message); | ||
return stack; | ||
}; | ||
exports.cleanUpWebpackOptions = (stack, message) => { | ||
stack = exports.cutOffWebpackOptions(stack); | ||
stack = exports.cutOffMultilineMessage(stack, message); | ||
/** | ||
* @param {string} stack stack trace | ||
* @param {string} message error message | ||
* @returns {string} stack trace without the webpack options flag and message included | ||
*/ | ||
const cleanUpWebpackOptions = (stack, message) => { | ||
stack = cutOffWebpackOptions(stack); | ||
stack = cutOffMultilineMessage(stack, message); | ||
return stack; | ||
}; | ||
exports.cutOffByFlag = cutOffByFlag; | ||
exports.cutOffLoaderExecution = cutOffLoaderExecution; | ||
exports.cutOffWebpackOptions = cutOffWebpackOptions; | ||
exports.cutOffMultilineMessage = cutOffMultilineMessage; | ||
exports.cutOffMessage = cutOffMessage; | ||
exports.cleanUp = cleanUp; | ||
exports.cleanUpWebpackOptions = cleanUpWebpackOptions; |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const ConstDependency = require("./dependencies/ConstDependency"); | ||
@@ -15,2 +20,4 @@ const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency"); | ||
const PLUGIN_NAME = "ExportsInfoApiPlugin"; | ||
class ExportsInfoApiPlugin { | ||
@@ -24,3 +31,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"ExportsInfoApiPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -38,3 +45,3 @@ compilation.dependencyTemplates.set( | ||
.for("__webpack_exports_info__") | ||
.tap("ExportsInfoApiPlugin", (expr, members) => { | ||
.tap(PLUGIN_NAME, (expr, members) => { | ||
const dep = | ||
@@ -54,3 +61,3 @@ members.length >= 2 | ||
.for("__webpack_exports_info__") | ||
.tap("ExportsInfoApiPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency("true", expr.range); | ||
@@ -63,10 +70,10 @@ dep.loc = expr.loc; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ExportsInfoApiPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("ExportsInfoApiPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ExportsInfoApiPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -73,0 +80,0 @@ ); |
@@ -13,2 +13,3 @@ /* | ||
const Module = require("./Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -382,3 +383,3 @@ const Template = require("./Template"); | ||
constructor(request, type, userRequest) { | ||
super("javascript/dynamic", null); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); | ||
@@ -385,0 +386,0 @@ // Info from Factory |
@@ -13,2 +13,3 @@ /* | ||
const PLUGIN_NAME = "FlagAllModulesAsUsedPlugin"; | ||
class FlagAllModulesAsUsedPlugin { | ||
@@ -25,30 +26,24 @@ constructor(explanation) { | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"FlagAllModulesAsUsedPlugin", | ||
compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
compilation.hooks.optimizeDependencies.tap( | ||
"FlagAllModulesAsUsedPlugin", | ||
modules => { | ||
/** @type {RuntimeSpec} */ | ||
let runtime = undefined; | ||
for (const [name, { options }] of compilation.entries) { | ||
runtime = mergeRuntimeOwned( | ||
runtime, | ||
getEntryRuntime(compilation, name, options) | ||
); | ||
} | ||
for (const module of modules) { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
exportsInfo.setUsedInUnknownWay(runtime); | ||
moduleGraph.addExtraReason(module, this.explanation); | ||
if (module.factoryMeta === undefined) { | ||
module.factoryMeta = {}; | ||
} | ||
module.factoryMeta.sideEffectFree = false; | ||
} | ||
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => { | ||
/** @type {RuntimeSpec} */ | ||
let runtime = undefined; | ||
for (const [name, { options }] of compilation.entries) { | ||
runtime = mergeRuntimeOwned( | ||
runtime, | ||
getEntryRuntime(compilation, name, options) | ||
); | ||
} | ||
for (const module of modules) { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
exportsInfo.setUsedInUnknownWay(runtime); | ||
moduleGraph.addExtraReason(module, this.explanation); | ||
if (module.factoryMeta === undefined) { | ||
module.factoryMeta = {}; | ||
} | ||
); | ||
} | ||
); | ||
module.factoryMeta.sideEffectFree = false; | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -55,0 +50,0 @@ } |
@@ -19,2 +19,5 @@ /* | ||
const PLUGIN_NAME = "FlagDependencyExportsPlugin"; | ||
const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`; | ||
class FlagDependencyExportsPlugin { | ||
@@ -27,390 +30,375 @@ /** | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"FlagDependencyExportsPlugin", | ||
compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
const cache = compilation.getCache("FlagDependencyExportsPlugin"); | ||
compilation.hooks.finishModules.tapAsync( | ||
"FlagDependencyExportsPlugin", | ||
(modules, callback) => { | ||
const logger = compilation.getLogger( | ||
"webpack.FlagDependencyExportsPlugin" | ||
); | ||
let statRestoredFromMemCache = 0; | ||
let statRestoredFromCache = 0; | ||
let statNoExports = 0; | ||
let statFlaggedUncached = 0; | ||
let statNotCached = 0; | ||
let statQueueItemsProcessed = 0; | ||
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
const cache = compilation.getCache(PLUGIN_NAME); | ||
compilation.hooks.finishModules.tapAsync( | ||
PLUGIN_NAME, | ||
(modules, callback) => { | ||
const logger = compilation.getLogger(PLUGIN_LOGGER_NAME); | ||
let statRestoredFromMemCache = 0; | ||
let statRestoredFromCache = 0; | ||
let statNoExports = 0; | ||
let statFlaggedUncached = 0; | ||
let statNotCached = 0; | ||
let statQueueItemsProcessed = 0; | ||
const { moduleMemCaches } = compilation; | ||
const { moduleMemCaches } = compilation; | ||
/** @type {Queue<Module>} */ | ||
const queue = new Queue(); | ||
/** @type {Queue<Module>} */ | ||
const queue = new Queue(); | ||
// Step 1: Try to restore cached provided export info from cache | ||
logger.time("restore cached provided exports"); | ||
asyncLib.each( | ||
modules, | ||
(module, callback) => { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
if (!module.buildMeta || !module.buildMeta.exportsType) { | ||
if (exportsInfo.otherExportsInfo.provided !== null) { | ||
// It's a module without declared exports | ||
statNoExports++; | ||
exportsInfo.setHasProvideInfo(); | ||
exportsInfo.setUnknownExportsProvided(); | ||
return callback(); | ||
} | ||
} | ||
if (typeof module.buildInfo.hash !== "string") { | ||
statFlaggedUncached++; | ||
// Enqueue uncacheable module for determining the exports | ||
queue.enqueue(module); | ||
// Step 1: Try to restore cached provided export info from cache | ||
logger.time("restore cached provided exports"); | ||
asyncLib.each( | ||
modules, | ||
(module, callback) => { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
// If the module doesn't have an exportsType, it's a module | ||
// without declared exports. | ||
if (!module.buildMeta || !module.buildMeta.exportsType) { | ||
if (exportsInfo.otherExportsInfo.provided !== null) { | ||
// It's a module without declared exports | ||
statNoExports++; | ||
exportsInfo.setHasProvideInfo(); | ||
exportsInfo.setUnknownExportsProvided(); | ||
return callback(); | ||
} | ||
const memCache = moduleMemCaches && moduleMemCaches.get(module); | ||
const memCacheValue = memCache && memCache.get(this); | ||
if (memCacheValue !== undefined) { | ||
statRestoredFromMemCache++; | ||
exportsInfo.restoreProvided(memCacheValue); | ||
return callback(); | ||
} | ||
cache.get( | ||
module.identifier(), | ||
module.buildInfo.hash, | ||
(err, result) => { | ||
if (err) return callback(err); | ||
} | ||
// If the module has no hash, it's uncacheable | ||
if (typeof module.buildInfo.hash !== "string") { | ||
statFlaggedUncached++; | ||
// Enqueue uncacheable module for determining the exports | ||
queue.enqueue(module); | ||
exportsInfo.setHasProvideInfo(); | ||
return callback(); | ||
} | ||
const memCache = moduleMemCaches && moduleMemCaches.get(module); | ||
const memCacheValue = memCache && memCache.get(this); | ||
if (memCacheValue !== undefined) { | ||
statRestoredFromMemCache++; | ||
exportsInfo.restoreProvided(memCacheValue); | ||
return callback(); | ||
} | ||
cache.get( | ||
module.identifier(), | ||
module.buildInfo.hash, | ||
(err, result) => { | ||
if (err) return callback(err); | ||
if (result !== undefined) { | ||
statRestoredFromCache++; | ||
exportsInfo.restoreProvided(result); | ||
} else { | ||
statNotCached++; | ||
// Without cached info enqueue module for determining the exports | ||
queue.enqueue(module); | ||
exportsInfo.setHasProvideInfo(); | ||
} | ||
callback(); | ||
if (result !== undefined) { | ||
statRestoredFromCache++; | ||
exportsInfo.restoreProvided(result); | ||
} else { | ||
statNotCached++; | ||
// Without cached info enqueue module for determining the exports | ||
queue.enqueue(module); | ||
exportsInfo.setHasProvideInfo(); | ||
} | ||
); | ||
}, | ||
err => { | ||
logger.timeEnd("restore cached provided exports"); | ||
if (err) return callback(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
err => { | ||
logger.timeEnd("restore cached provided exports"); | ||
if (err) return callback(err); | ||
/** @type {Set<Module>} */ | ||
const modulesToStore = new Set(); | ||
/** @type {Set<Module>} */ | ||
const modulesToStore = new Set(); | ||
/** @type {Map<Module, Set<Module>>} */ | ||
const dependencies = new Map(); | ||
/** @type {Map<Module, Set<Module>>} */ | ||
const dependencies = new Map(); | ||
/** @type {Module} */ | ||
let module; | ||
/** @type {Module} */ | ||
let module; | ||
/** @type {ExportsInfo} */ | ||
let exportsInfo; | ||
/** @type {ExportsInfo} */ | ||
let exportsInfo; | ||
/** @type {Map<Dependency, ExportsSpec>} */ | ||
const exportsSpecsFromDependencies = new Map(); | ||
/** @type {Map<Dependency, ExportsSpec>} */ | ||
const exportsSpecsFromDependencies = new Map(); | ||
let cacheable = true; | ||
let changed = false; | ||
let cacheable = true; | ||
let changed = false; | ||
/** | ||
* @param {DependenciesBlock} depBlock the dependencies block | ||
* @returns {void} | ||
*/ | ||
const processDependenciesBlock = depBlock => { | ||
for (const dep of depBlock.dependencies) { | ||
processDependency(dep); | ||
/** | ||
* @param {DependenciesBlock} depBlock the dependencies block | ||
* @returns {void} | ||
*/ | ||
const processDependenciesBlock = depBlock => { | ||
for (const dep of depBlock.dependencies) { | ||
processDependency(dep); | ||
} | ||
for (const block of depBlock.blocks) { | ||
processDependenciesBlock(block); | ||
} | ||
}; | ||
/** | ||
* @param {Dependency} dep the dependency | ||
* @returns {void} | ||
*/ | ||
const processDependency = dep => { | ||
const exportDesc = dep.getExports(moduleGraph); | ||
if (!exportDesc) return; | ||
exportsSpecsFromDependencies.set(dep, exportDesc); | ||
}; | ||
/** | ||
* @param {Dependency} dep dependency | ||
* @param {ExportsSpec} exportDesc info | ||
* @returns {void} | ||
*/ | ||
const processExportsSpec = (dep, exportDesc) => { | ||
const exports = exportDesc.exports; | ||
const globalCanMangle = exportDesc.canMangle; | ||
const globalFrom = exportDesc.from; | ||
const globalPriority = exportDesc.priority; | ||
const globalTerminalBinding = | ||
exportDesc.terminalBinding || false; | ||
const exportDeps = exportDesc.dependencies; | ||
if (exportDesc.hideExports) { | ||
for (const name of exportDesc.hideExports) { | ||
const exportInfo = exportsInfo.getExportInfo(name); | ||
exportInfo.unsetTarget(dep); | ||
} | ||
for (const block of depBlock.blocks) { | ||
processDependenciesBlock(block); | ||
} | ||
if (exports === true) { | ||
// unknown exports | ||
if ( | ||
exportsInfo.setUnknownExportsProvided( | ||
globalCanMangle, | ||
exportDesc.excludeExports, | ||
globalFrom && dep, | ||
globalFrom, | ||
globalPriority | ||
) | ||
) { | ||
changed = true; | ||
} | ||
}; | ||
} else if (Array.isArray(exports)) { | ||
/** | ||
* merge in new exports | ||
* @param {ExportsInfo} exportsInfo own exports info | ||
* @param {(ExportSpec | string)[]} exports list of exports | ||
*/ | ||
const mergeExports = (exportsInfo, exports) => { | ||
for (const exportNameOrSpec of exports) { | ||
let name; | ||
let canMangle = globalCanMangle; | ||
let terminalBinding = globalTerminalBinding; | ||
let exports = undefined; | ||
let from = globalFrom; | ||
let fromExport = undefined; | ||
let priority = globalPriority; | ||
let hidden = false; | ||
if (typeof exportNameOrSpec === "string") { | ||
name = exportNameOrSpec; | ||
} else { | ||
name = exportNameOrSpec.name; | ||
if (exportNameOrSpec.canMangle !== undefined) | ||
canMangle = exportNameOrSpec.canMangle; | ||
if (exportNameOrSpec.export !== undefined) | ||
fromExport = exportNameOrSpec.export; | ||
if (exportNameOrSpec.exports !== undefined) | ||
exports = exportNameOrSpec.exports; | ||
if (exportNameOrSpec.from !== undefined) | ||
from = exportNameOrSpec.from; | ||
if (exportNameOrSpec.priority !== undefined) | ||
priority = exportNameOrSpec.priority; | ||
if (exportNameOrSpec.terminalBinding !== undefined) | ||
terminalBinding = exportNameOrSpec.terminalBinding; | ||
if (exportNameOrSpec.hidden !== undefined) | ||
hidden = exportNameOrSpec.hidden; | ||
} | ||
const exportInfo = exportsInfo.getExportInfo(name); | ||
/** | ||
* @param {Dependency} dep the dependency | ||
* @returns {void} | ||
*/ | ||
const processDependency = dep => { | ||
const exportDesc = dep.getExports(moduleGraph); | ||
if (!exportDesc) return; | ||
exportsSpecsFromDependencies.set(dep, exportDesc); | ||
}; | ||
if ( | ||
exportInfo.provided === false || | ||
exportInfo.provided === null | ||
) { | ||
exportInfo.provided = true; | ||
changed = true; | ||
} | ||
/** | ||
* @param {Dependency} dep dependency | ||
* @param {ExportsSpec} exportDesc info | ||
* @returns {void} | ||
*/ | ||
const processExportsSpec = (dep, exportDesc) => { | ||
const exports = exportDesc.exports; | ||
const globalCanMangle = exportDesc.canMangle; | ||
const globalFrom = exportDesc.from; | ||
const globalPriority = exportDesc.priority; | ||
const globalTerminalBinding = | ||
exportDesc.terminalBinding || false; | ||
const exportDeps = exportDesc.dependencies; | ||
if (exportDesc.hideExports) { | ||
for (const name of exportDesc.hideExports) { | ||
const exportInfo = exportsInfo.getExportInfo(name); | ||
exportInfo.unsetTarget(dep); | ||
} | ||
} | ||
if (exports === true) { | ||
// unknown exports | ||
if ( | ||
exportsInfo.setUnknownExportsProvided( | ||
globalCanMangle, | ||
exportDesc.excludeExports, | ||
globalFrom && dep, | ||
globalFrom, | ||
globalPriority | ||
) | ||
) { | ||
changed = true; | ||
} | ||
} else if (Array.isArray(exports)) { | ||
/** | ||
* merge in new exports | ||
* @param {ExportsInfo} exportsInfo own exports info | ||
* @param {(ExportSpec | string)[]} exports list of exports | ||
*/ | ||
const mergeExports = (exportsInfo, exports) => { | ||
for (const exportNameOrSpec of exports) { | ||
let name; | ||
let canMangle = globalCanMangle; | ||
let terminalBinding = globalTerminalBinding; | ||
let exports = undefined; | ||
let from = globalFrom; | ||
let fromExport = undefined; | ||
let priority = globalPriority; | ||
let hidden = false; | ||
if (typeof exportNameOrSpec === "string") { | ||
name = exportNameOrSpec; | ||
} else { | ||
name = exportNameOrSpec.name; | ||
if (exportNameOrSpec.canMangle !== undefined) | ||
canMangle = exportNameOrSpec.canMangle; | ||
if (exportNameOrSpec.export !== undefined) | ||
fromExport = exportNameOrSpec.export; | ||
if (exportNameOrSpec.exports !== undefined) | ||
exports = exportNameOrSpec.exports; | ||
if (exportNameOrSpec.from !== undefined) | ||
from = exportNameOrSpec.from; | ||
if (exportNameOrSpec.priority !== undefined) | ||
priority = exportNameOrSpec.priority; | ||
if (exportNameOrSpec.terminalBinding !== undefined) | ||
terminalBinding = exportNameOrSpec.terminalBinding; | ||
if (exportNameOrSpec.hidden !== undefined) | ||
hidden = exportNameOrSpec.hidden; | ||
} | ||
const exportInfo = exportsInfo.getExportInfo(name); | ||
if ( | ||
exportInfo.canMangleProvide !== false && | ||
canMangle === false | ||
) { | ||
exportInfo.canMangleProvide = false; | ||
changed = true; | ||
} | ||
if ( | ||
exportInfo.provided === false || | ||
exportInfo.provided === null | ||
) { | ||
exportInfo.provided = true; | ||
changed = true; | ||
} | ||
if (terminalBinding && !exportInfo.terminalBinding) { | ||
exportInfo.terminalBinding = true; | ||
changed = true; | ||
} | ||
if ( | ||
exportInfo.canMangleProvide !== false && | ||
canMangle === false | ||
) { | ||
exportInfo.canMangleProvide = false; | ||
changed = true; | ||
} | ||
if (exports) { | ||
const nestedExportsInfo = | ||
exportInfo.createNestedExportsInfo(); | ||
mergeExports(nestedExportsInfo, exports); | ||
} | ||
if (terminalBinding && !exportInfo.terminalBinding) { | ||
exportInfo.terminalBinding = true; | ||
changed = true; | ||
} | ||
if ( | ||
from && | ||
(hidden | ||
? exportInfo.unsetTarget(dep) | ||
: exportInfo.setTarget( | ||
dep, | ||
from, | ||
fromExport === undefined ? [name] : fromExport, | ||
priority | ||
)) | ||
) { | ||
changed = true; | ||
} | ||
if (exports) { | ||
const nestedExportsInfo = | ||
exportInfo.createNestedExportsInfo(); | ||
mergeExports(nestedExportsInfo, exports); | ||
// Recalculate target exportsInfo | ||
const target = exportInfo.getTarget(moduleGraph); | ||
let targetExportsInfo = undefined; | ||
if (target) { | ||
const targetModuleExportsInfo = | ||
moduleGraph.getExportsInfo(target.module); | ||
targetExportsInfo = | ||
targetModuleExportsInfo.getNestedExportsInfo( | ||
target.export | ||
); | ||
// add dependency for this module | ||
const set = dependencies.get(target.module); | ||
if (set === undefined) { | ||
dependencies.set(target.module, new Set([module])); | ||
} else { | ||
set.add(module); | ||
} | ||
} | ||
if (exportInfo.exportsInfoOwned) { | ||
if ( | ||
from && | ||
(hidden | ||
? exportInfo.unsetTarget(dep) | ||
: exportInfo.setTarget( | ||
dep, | ||
from, | ||
fromExport === undefined ? [name] : fromExport, | ||
priority | ||
)) | ||
exportInfo.exportsInfo.setRedirectNamedTo( | ||
targetExportsInfo | ||
) | ||
) { | ||
changed = true; | ||
} | ||
// Recalculate target exportsInfo | ||
const target = exportInfo.getTarget(moduleGraph); | ||
let targetExportsInfo = undefined; | ||
if (target) { | ||
const targetModuleExportsInfo = | ||
moduleGraph.getExportsInfo(target.module); | ||
targetExportsInfo = | ||
targetModuleExportsInfo.getNestedExportsInfo( | ||
target.export | ||
); | ||
// add dependency for this module | ||
const set = dependencies.get(target.module); | ||
if (set === undefined) { | ||
dependencies.set(target.module, new Set([module])); | ||
} else { | ||
set.add(module); | ||
} | ||
} | ||
if (exportInfo.exportsInfoOwned) { | ||
if ( | ||
exportInfo.exportsInfo.setRedirectNamedTo( | ||
targetExportsInfo | ||
) | ||
) { | ||
changed = true; | ||
} | ||
} else if ( | ||
exportInfo.exportsInfo !== targetExportsInfo | ||
) { | ||
exportInfo.exportsInfo = targetExportsInfo; | ||
changed = true; | ||
} | ||
} else if (exportInfo.exportsInfo !== targetExportsInfo) { | ||
exportInfo.exportsInfo = targetExportsInfo; | ||
changed = true; | ||
} | ||
}; | ||
mergeExports(exportsInfo, exports); | ||
} | ||
// store dependencies | ||
if (exportDeps) { | ||
cacheable = false; | ||
for (const exportDependency of exportDeps) { | ||
// add dependency for this module | ||
const set = dependencies.get(exportDependency); | ||
if (set === undefined) { | ||
dependencies.set(exportDependency, new Set([module])); | ||
} else { | ||
set.add(module); | ||
} | ||
} | ||
}; | ||
mergeExports(exportsInfo, exports); | ||
} | ||
// store dependencies | ||
if (exportDeps) { | ||
cacheable = false; | ||
for (const exportDependency of exportDeps) { | ||
// add dependency for this module | ||
const set = dependencies.get(exportDependency); | ||
if (set === undefined) { | ||
dependencies.set(exportDependency, new Set([module])); | ||
} else { | ||
set.add(module); | ||
} | ||
} | ||
}; | ||
} | ||
}; | ||
const notifyDependencies = () => { | ||
const deps = dependencies.get(module); | ||
if (deps !== undefined) { | ||
for (const dep of deps) { | ||
queue.enqueue(dep); | ||
} | ||
const notifyDependencies = () => { | ||
const deps = dependencies.get(module); | ||
if (deps !== undefined) { | ||
for (const dep of deps) { | ||
queue.enqueue(dep); | ||
} | ||
}; | ||
} | ||
}; | ||
logger.time("figure out provided exports"); | ||
while (queue.length > 0) { | ||
module = queue.dequeue(); | ||
logger.time("figure out provided exports"); | ||
while (queue.length > 0) { | ||
module = queue.dequeue(); | ||
statQueueItemsProcessed++; | ||
statQueueItemsProcessed++; | ||
exportsInfo = moduleGraph.getExportsInfo(module); | ||
exportsInfo = moduleGraph.getExportsInfo(module); | ||
cacheable = true; | ||
changed = false; | ||
cacheable = true; | ||
changed = false; | ||
exportsSpecsFromDependencies.clear(); | ||
moduleGraph.freeze(); | ||
processDependenciesBlock(module); | ||
moduleGraph.unfreeze(); | ||
for (const [ | ||
dep, | ||
exportsSpec | ||
] of exportsSpecsFromDependencies) { | ||
processExportsSpec(dep, exportsSpec); | ||
} | ||
exportsSpecsFromDependencies.clear(); | ||
moduleGraph.freeze(); | ||
processDependenciesBlock(module); | ||
moduleGraph.unfreeze(); | ||
for (const [dep, exportsSpec] of exportsSpecsFromDependencies) { | ||
processExportsSpec(dep, exportsSpec); | ||
} | ||
if (cacheable) { | ||
modulesToStore.add(module); | ||
} | ||
if (cacheable) { | ||
modulesToStore.add(module); | ||
} | ||
if (changed) { | ||
notifyDependencies(); | ||
} | ||
if (changed) { | ||
notifyDependencies(); | ||
} | ||
logger.timeEnd("figure out provided exports"); | ||
} | ||
logger.timeEnd("figure out provided exports"); | ||
logger.log( | ||
`${Math.round( | ||
(100 * (statFlaggedUncached + statNotCached)) / | ||
(statRestoredFromMemCache + | ||
statRestoredFromCache + | ||
statNotCached + | ||
statFlaggedUncached + | ||
statNoExports) | ||
)}% of exports of modules have been determined (${statNoExports} no declared exports, ${statNotCached} not cached, ${statFlaggedUncached} flagged uncacheable, ${statRestoredFromCache} from cache, ${statRestoredFromMemCache} from mem cache, ${ | ||
statQueueItemsProcessed - | ||
statNotCached - | ||
statFlaggedUncached | ||
} additional calculations due to dependencies)` | ||
); | ||
logger.log( | ||
`${Math.round( | ||
(100 * (statFlaggedUncached + statNotCached)) / | ||
(statRestoredFromMemCache + | ||
statRestoredFromCache + | ||
statNotCached + | ||
statFlaggedUncached + | ||
statNoExports) | ||
)}% of exports of modules have been determined (${statNoExports} no declared exports, ${statNotCached} not cached, ${statFlaggedUncached} flagged uncacheable, ${statRestoredFromCache} from cache, ${statRestoredFromMemCache} from mem cache, ${ | ||
statQueueItemsProcessed - statNotCached - statFlaggedUncached | ||
} additional calculations due to dependencies)` | ||
); | ||
logger.time("store provided exports into cache"); | ||
asyncLib.each( | ||
modulesToStore, | ||
(module, callback) => { | ||
if (typeof module.buildInfo.hash !== "string") { | ||
// not cacheable | ||
return callback(); | ||
} | ||
const cachedData = moduleGraph | ||
.getExportsInfo(module) | ||
.getRestoreProvidedData(); | ||
const memCache = | ||
moduleMemCaches && moduleMemCaches.get(module); | ||
if (memCache) { | ||
memCache.set(this, cachedData); | ||
} | ||
cache.store( | ||
module.identifier(), | ||
module.buildInfo.hash, | ||
cachedData, | ||
callback | ||
); | ||
}, | ||
err => { | ||
logger.timeEnd("store provided exports into cache"); | ||
callback(err); | ||
logger.time("store provided exports into cache"); | ||
asyncLib.each( | ||
modulesToStore, | ||
(module, callback) => { | ||
if (typeof module.buildInfo.hash !== "string") { | ||
// not cacheable | ||
return callback(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
const cachedData = moduleGraph | ||
.getExportsInfo(module) | ||
.getRestoreProvidedData(); | ||
const memCache = | ||
moduleMemCaches && moduleMemCaches.get(module); | ||
if (memCache) { | ||
memCache.set(this, cachedData); | ||
} | ||
cache.store( | ||
module.identifier(), | ||
module.buildInfo.hash, | ||
cachedData, | ||
callback | ||
); | ||
}, | ||
err => { | ||
logger.timeEnd("store provided exports into cache"); | ||
callback(err); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
/** @type {WeakMap<Module, any>} */ | ||
const providedExportsCache = new WeakMap(); | ||
compilation.hooks.rebuildModule.tap( | ||
"FlagDependencyExportsPlugin", | ||
module => { | ||
providedExportsCache.set( | ||
module, | ||
moduleGraph.getExportsInfo(module).getRestoreProvidedData() | ||
); | ||
} | ||
/** @type {WeakMap<Module, any>} */ | ||
const providedExportsCache = new WeakMap(); | ||
compilation.hooks.rebuildModule.tap(PLUGIN_NAME, module => { | ||
providedExportsCache.set( | ||
module, | ||
moduleGraph.getExportsInfo(module).getRestoreProvidedData() | ||
); | ||
compilation.hooks.finishRebuildingModule.tap( | ||
"FlagDependencyExportsPlugin", | ||
module => { | ||
moduleGraph | ||
.getExportsInfo(module) | ||
.restoreProvided(providedExportsCache.get(module)); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
compilation.hooks.finishRebuildingModule.tap(PLUGIN_NAME, module => { | ||
moduleGraph | ||
.getExportsInfo(module) | ||
.restoreProvided(providedExportsCache.get(module)); | ||
}); | ||
}); | ||
} | ||
@@ -417,0 +405,0 @@ } |
@@ -27,2 +27,5 @@ /* | ||
const PLUGIN_NAME = "FlagDependencyUsagePlugin"; | ||
const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`; | ||
class FlagDependencyUsagePlugin { | ||
@@ -42,9 +45,6 @@ /** | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap("FlagDependencyUsagePlugin", compilation => { | ||
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
compilation.hooks.optimizeDependencies.tap( | ||
{ | ||
name: "FlagDependencyUsagePlugin", | ||
stage: STAGE_DEFAULT | ||
}, | ||
{ name: PLUGIN_NAME, stage: STAGE_DEFAULT }, | ||
modules => { | ||
@@ -57,5 +57,3 @@ if (compilation.moduleMemCaches) { | ||
const logger = compilation.getLogger( | ||
"webpack.FlagDependencyUsagePlugin" | ||
); | ||
const logger = compilation.getLogger(PLUGIN_LOGGER_NAME); | ||
/** @type {Map<ExportsInfo, Module>} */ | ||
@@ -62,0 +60,0 @@ const exportInfoToModuleMap = new Map(); |
@@ -12,2 +12,4 @@ /* | ||
const PLUGIN_NAME = "FlagEntryExportAsUsedPlugin"; | ||
class FlagEntryExportAsUsedPlugin { | ||
@@ -25,28 +27,25 @@ constructor(nsObjectUsed, explanation) { | ||
apply(compiler) { | ||
compiler.hooks.thisCompilation.tap( | ||
"FlagEntryExportAsUsedPlugin", | ||
compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
compilation.hooks.seal.tap("FlagEntryExportAsUsedPlugin", () => { | ||
for (const [ | ||
entryName, | ||
{ dependencies: deps, options } | ||
] of compilation.entries) { | ||
const runtime = getEntryRuntime(compilation, entryName, options); | ||
for (const dep of deps) { | ||
const module = moduleGraph.getModule(dep); | ||
if (module) { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
if (this.nsObjectUsed) { | ||
exportsInfo.setUsedInUnknownWay(runtime); | ||
} else { | ||
exportsInfo.setAllKnownExportsUsed(runtime); | ||
} | ||
moduleGraph.addExtraReason(module, this.explanation); | ||
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => { | ||
const moduleGraph = compilation.moduleGraph; | ||
compilation.hooks.seal.tap(PLUGIN_NAME, () => { | ||
for (const [ | ||
entryName, | ||
{ dependencies: deps, options } | ||
] of compilation.entries) { | ||
const runtime = getEntryRuntime(compilation, entryName, options); | ||
for (const dep of deps) { | ||
const module = moduleGraph.getModule(dep); | ||
if (module) { | ||
const exportsInfo = moduleGraph.getExportsInfo(module); | ||
if (this.nsObjectUsed) { | ||
exportsInfo.setUsedInUnknownWay(runtime); | ||
} else { | ||
exportsInfo.setAllKnownExportsUsed(runtime); | ||
} | ||
moduleGraph.addExtraReason(module, this.explanation); | ||
} | ||
} | ||
}); | ||
} | ||
); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -53,0 +52,0 @@ } |
@@ -38,2 +38,8 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
/** @typedef {import("./Chunk")} Chunk */ | ||
@@ -55,2 +61,4 @@ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | ||
const PLUGIN_NAME = "HotModuleReplacementPlugin"; | ||
class HotModuleReplacementPlugin { | ||
@@ -188,3 +196,3 @@ /** | ||
{ | ||
name: "HotModuleReplacementPlugin", | ||
name: PLUGIN_NAME, | ||
before: "NodeStuffPlugin" | ||
@@ -204,3 +212,3 @@ }, | ||
.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
createAcceptHandler(parser, ModuleHotAcceptDependency) | ||
@@ -211,3 +219,3 @@ ); | ||
.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
createDeclineHandler(parser, ModuleHotDeclineDependency) | ||
@@ -217,3 +225,3 @@ ); | ||
.for("module.hot") | ||
.tap("HotModuleReplacementPlugin", createHMRExpressionHandler(parser)); | ||
.tap(PLUGIN_NAME, createHMRExpressionHandler(parser)); | ||
}; | ||
@@ -224,3 +232,3 @@ | ||
.for("import.meta.webpackHot") | ||
.tap("HotModuleReplacementPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
return evaluateToIdentifier( | ||
@@ -236,3 +244,3 @@ "import.meta.webpackHot", | ||
.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
createAcceptHandler(parser, ImportMetaHotAcceptDependency) | ||
@@ -243,3 +251,3 @@ ); | ||
.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
createDeclineHandler(parser, ImportMetaHotDeclineDependency) | ||
@@ -249,7 +257,7 @@ ); | ||
.for("import.meta.webpackHot") | ||
.tap("HotModuleReplacementPlugin", createHMRExpressionHandler(parser)); | ||
.tap(PLUGIN_NAME, createHMRExpressionHandler(parser)); | ||
}; | ||
compiler.hooks.compilation.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -302,29 +310,26 @@ // This applies the HMR plugin only to the targeted compiler | ||
compilation.hooks.record.tap( | ||
"HotModuleReplacementPlugin", | ||
(compilation, records) => { | ||
if (records.hash === compilation.hash) return; | ||
const chunkGraph = compilation.chunkGraph; | ||
records.hash = compilation.hash; | ||
records.hotIndex = hotIndex; | ||
records.fullHashChunkModuleHashes = fullHashChunkModuleHashes; | ||
records.chunkModuleHashes = chunkModuleHashes; | ||
records.chunkHashes = {}; | ||
records.chunkRuntime = {}; | ||
for (const chunk of compilation.chunks) { | ||
records.chunkHashes[chunk.id] = chunk.hash; | ||
records.chunkRuntime[chunk.id] = getRuntimeKey(chunk.runtime); | ||
} | ||
records.chunkModuleIds = {}; | ||
for (const chunk of compilation.chunks) { | ||
records.chunkModuleIds[chunk.id] = Array.from( | ||
chunkGraph.getOrderedChunkModulesIterable( | ||
chunk, | ||
compareModulesById(chunkGraph) | ||
), | ||
m => chunkGraph.getModuleId(m) | ||
); | ||
} | ||
compilation.hooks.record.tap(PLUGIN_NAME, (compilation, records) => { | ||
if (records.hash === compilation.hash) return; | ||
const chunkGraph = compilation.chunkGraph; | ||
records.hash = compilation.hash; | ||
records.hotIndex = hotIndex; | ||
records.fullHashChunkModuleHashes = fullHashChunkModuleHashes; | ||
records.chunkModuleHashes = chunkModuleHashes; | ||
records.chunkHashes = {}; | ||
records.chunkRuntime = {}; | ||
for (const chunk of compilation.chunks) { | ||
records.chunkHashes[chunk.id] = chunk.hash; | ||
records.chunkRuntime[chunk.id] = getRuntimeKey(chunk.runtime); | ||
} | ||
); | ||
records.chunkModuleIds = {}; | ||
for (const chunk of compilation.chunks) { | ||
records.chunkModuleIds[chunk.id] = Array.from( | ||
chunkGraph.getOrderedChunkModulesIterable( | ||
chunk, | ||
compareModulesById(chunkGraph) | ||
), | ||
m => chunkGraph.getModuleId(m) | ||
); | ||
} | ||
}); | ||
/** @type {TupleSet<[Module, Chunk]>} */ | ||
@@ -336,3 +341,3 @@ const updatedModules = new TupleSet(); | ||
const nonCodeGeneratedModules = new TupleSet(); | ||
compilation.hooks.fullHash.tap("HotModuleReplacementPlugin", hash => { | ||
compilation.hooks.fullHash.tap(PLUGIN_NAME, hash => { | ||
const chunkGraph = compilation.chunkGraph; | ||
@@ -427,3 +432,3 @@ const records = compilation.records; | ||
{ | ||
name: "HotModuleReplacementPlugin", | ||
name: PLUGIN_NAME, | ||
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL | ||
@@ -750,3 +755,3 @@ }, | ||
compilation.hooks.additionalTreeRuntimeRequirements.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
(chunk, runtimeRequirements) => { | ||
@@ -765,4 +770,4 @@ runtimeRequirements.add(RuntimeGlobals.hmrDownloadManifest); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("HotModuleReplacementPlugin", parser => { | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, parser => { | ||
applyModuleHot(parser); | ||
@@ -772,9 +777,9 @@ applyImportMetaHot(parser); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("HotModuleReplacementPlugin", parser => { | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, parser => { | ||
applyModuleHot(parser); | ||
}); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("HotModuleReplacementPlugin", parser => { | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, parser => { | ||
applyImportMetaHot(parser); | ||
@@ -784,3 +789,3 @@ }); | ||
NormalModule.getCompilationHooks(compilation).loader.tap( | ||
"HotModuleReplacementPlugin", | ||
PLUGIN_NAME, | ||
context => { | ||
@@ -787,0 +792,0 @@ context.hot = true; |
@@ -21,2 +21,7 @@ /* | ||
const InitFragment = require("../InitFragment"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -137,2 +142,4 @@ const Template = require("../Template"); | ||
const PLUGIN_NAME = "JavascriptModulesPlugin"; | ||
class JavascriptModulesPlugin { | ||
@@ -201,150 +208,143 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"JavascriptModulesPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation); | ||
normalModuleFactory.hooks.createParser | ||
.for("javascript/auto") | ||
.tap("JavascriptModulesPlugin", options => { | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, options => { | ||
return new JavascriptParser("auto"); | ||
}); | ||
normalModuleFactory.hooks.createParser | ||
.for("javascript/dynamic") | ||
.tap("JavascriptModulesPlugin", options => { | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, options => { | ||
return new JavascriptParser("script"); | ||
}); | ||
normalModuleFactory.hooks.createParser | ||
.for("javascript/esm") | ||
.tap("JavascriptModulesPlugin", options => { | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, options => { | ||
return new JavascriptParser("module"); | ||
}); | ||
normalModuleFactory.hooks.createGenerator | ||
.for("javascript/auto") | ||
.tap("JavascriptModulesPlugin", () => { | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, () => { | ||
return new JavascriptGenerator(); | ||
}); | ||
normalModuleFactory.hooks.createGenerator | ||
.for("javascript/dynamic") | ||
.tap("JavascriptModulesPlugin", () => { | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, () => { | ||
return new JavascriptGenerator(); | ||
}); | ||
normalModuleFactory.hooks.createGenerator | ||
.for("javascript/esm") | ||
.tap("JavascriptModulesPlugin", () => { | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, () => { | ||
return new JavascriptGenerator(); | ||
}); | ||
compilation.hooks.renderManifest.tap( | ||
"JavascriptModulesPlugin", | ||
(result, options) => { | ||
const { | ||
hash, | ||
chunk, | ||
chunkGraph, | ||
moduleGraph, | ||
runtimeTemplate, | ||
dependencyTemplates, | ||
outputOptions, | ||
codeGenerationResults | ||
} = options; | ||
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => { | ||
const { | ||
hash, | ||
chunk, | ||
chunkGraph, | ||
moduleGraph, | ||
runtimeTemplate, | ||
dependencyTemplates, | ||
outputOptions, | ||
codeGenerationResults | ||
} = options; | ||
const hotUpdateChunk = | ||
chunk instanceof HotUpdateChunk ? chunk : null; | ||
const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null; | ||
let render; | ||
const filenameTemplate = | ||
JavascriptModulesPlugin.getChunkFilenameTemplate( | ||
chunk, | ||
outputOptions | ||
let render; | ||
const filenameTemplate = | ||
JavascriptModulesPlugin.getChunkFilenameTemplate( | ||
chunk, | ||
outputOptions | ||
); | ||
if (hotUpdateChunk) { | ||
render = () => | ||
this.renderChunk( | ||
{ | ||
chunk, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks | ||
); | ||
if (hotUpdateChunk) { | ||
render = () => | ||
this.renderChunk( | ||
{ | ||
chunk, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks | ||
); | ||
} else if (chunk.hasRuntime()) { | ||
render = () => | ||
this.renderMain( | ||
{ | ||
hash, | ||
chunk, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks, | ||
compilation | ||
); | ||
} else { | ||
if (!chunkHasJs(chunk, chunkGraph)) { | ||
return result; | ||
} | ||
render = () => | ||
this.renderChunk( | ||
{ | ||
chunk, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks | ||
); | ||
} else if (chunk.hasRuntime()) { | ||
render = () => | ||
this.renderMain( | ||
{ | ||
hash, | ||
chunk, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks, | ||
compilation | ||
); | ||
} else { | ||
if (!chunkHasJs(chunk, chunkGraph)) { | ||
return result; | ||
} | ||
result.push({ | ||
render, | ||
filenameTemplate, | ||
pathOptions: { | ||
hash, | ||
runtime: chunk.runtime, | ||
chunk, | ||
contentHashType: "javascript" | ||
}, | ||
info: { | ||
javascriptModule: compilation.runtimeTemplate.isModule() | ||
}, | ||
identifier: hotUpdateChunk | ||
? `hotupdatechunk${chunk.id}` | ||
: `chunk${chunk.id}`, | ||
hash: chunk.contentHash.javascript | ||
}); | ||
return result; | ||
} | ||
); | ||
compilation.hooks.chunkHash.tap( | ||
"JavascriptModulesPlugin", | ||
(chunk, hash, context) => { | ||
hooks.chunkHash.call(chunk, hash, context); | ||
if (chunk.hasRuntime()) { | ||
this.updateHashWithBootstrap( | ||
hash, | ||
render = () => | ||
this.renderChunk( | ||
{ | ||
hash: "0000", | ||
chunk, | ||
codeGenerationResults: context.codeGenerationResults, | ||
chunkGraph: context.chunkGraph, | ||
moduleGraph: context.moduleGraph, | ||
runtimeTemplate: context.runtimeTemplate | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
moduleGraph, | ||
chunkGraph, | ||
codeGenerationResults, | ||
strictMode: runtimeTemplate.isModule() | ||
}, | ||
hooks | ||
); | ||
} | ||
} | ||
); | ||
compilation.hooks.contentHash.tap("JavascriptModulesPlugin", chunk => { | ||
result.push({ | ||
render, | ||
filenameTemplate, | ||
pathOptions: { | ||
hash, | ||
runtime: chunk.runtime, | ||
chunk, | ||
contentHashType: "javascript" | ||
}, | ||
info: { | ||
javascriptModule: compilation.runtimeTemplate.isModule() | ||
}, | ||
identifier: hotUpdateChunk | ||
? `hotupdatechunk${chunk.id}` | ||
: `chunk${chunk.id}`, | ||
hash: chunk.contentHash.javascript | ||
}); | ||
return result; | ||
}); | ||
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, context) => { | ||
hooks.chunkHash.call(chunk, hash, context); | ||
if (chunk.hasRuntime()) { | ||
this.updateHashWithBootstrap( | ||
hash, | ||
{ | ||
hash: "0000", | ||
chunk, | ||
codeGenerationResults: context.codeGenerationResults, | ||
chunkGraph: context.chunkGraph, | ||
moduleGraph: context.moduleGraph, | ||
runtimeTemplate: context.runtimeTemplate | ||
}, | ||
hooks | ||
); | ||
} | ||
}); | ||
compilation.hooks.contentHash.tap(PLUGIN_NAME, chunk => { | ||
const { | ||
@@ -416,3 +416,3 @@ chunkGraph, | ||
compilation.hooks.additionalTreeRuntimeRequirements.tap( | ||
"JavascriptModulesPlugin", | ||
PLUGIN_NAME, | ||
(chunk, set, { chunkGraph }) => { | ||
@@ -428,54 +428,47 @@ if ( | ||
); | ||
compilation.hooks.executeModule.tap( | ||
"JavascriptModulesPlugin", | ||
(options, context) => { | ||
const source = | ||
options.codeGenerationResult.sources.get("javascript"); | ||
if (source === undefined) return; | ||
const { module, moduleObject } = options; | ||
const code = source.source(); | ||
compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => { | ||
const source = options.codeGenerationResult.sources.get("javascript"); | ||
if (source === undefined) return; | ||
const { module, moduleObject } = options; | ||
const code = source.source(); | ||
const fn = vm.runInThisContext( | ||
`(function(${module.moduleArgument}, ${module.exportsArgument}, __webpack_require__) {\n${code}\n/**/})`, | ||
{ | ||
filename: module.identifier(), | ||
lineOffset: -1 | ||
} | ||
const fn = vm.runInThisContext( | ||
`(function(${module.moduleArgument}, ${module.exportsArgument}, __webpack_require__) {\n${code}\n/**/})`, | ||
{ | ||
filename: module.identifier(), | ||
lineOffset: -1 | ||
} | ||
); | ||
try { | ||
fn.call( | ||
moduleObject.exports, | ||
moduleObject, | ||
moduleObject.exports, | ||
context.__webpack_require__ | ||
); | ||
try { | ||
fn.call( | ||
moduleObject.exports, | ||
moduleObject, | ||
moduleObject.exports, | ||
context.__webpack_require__ | ||
); | ||
} catch (e) { | ||
e.stack += printGeneratedCodeForStack(options.module, code); | ||
throw e; | ||
} | ||
} catch (e) { | ||
e.stack += printGeneratedCodeForStack(options.module, code); | ||
throw e; | ||
} | ||
); | ||
compilation.hooks.executeModule.tap( | ||
"JavascriptModulesPlugin", | ||
(options, context) => { | ||
const source = options.codeGenerationResult.sources.get("runtime"); | ||
if (source === undefined) return; | ||
let code = source.source(); | ||
if (typeof code !== "string") code = code.toString(); | ||
}); | ||
compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => { | ||
const source = options.codeGenerationResult.sources.get("runtime"); | ||
if (source === undefined) return; | ||
let code = source.source(); | ||
if (typeof code !== "string") code = code.toString(); | ||
const fn = vm.runInThisContext( | ||
`(function(__webpack_require__) {\n${code}\n/**/})`, | ||
{ | ||
filename: options.module.identifier(), | ||
lineOffset: -1 | ||
} | ||
); | ||
try { | ||
fn.call(null, context.__webpack_require__); | ||
} catch (e) { | ||
e.stack += printGeneratedCodeForStack(options.module, code); | ||
throw e; | ||
const fn = vm.runInThisContext( | ||
`(function(__webpack_require__) {\n${code}\n/**/})`, | ||
{ | ||
filename: options.module.identifier(), | ||
lineOffset: -1 | ||
} | ||
); | ||
try { | ||
fn.call(null, context.__webpack_require__); | ||
} catch (e) { | ||
e.stack += printGeneratedCodeForStack(options.module, code); | ||
throw e; | ||
} | ||
); | ||
}); | ||
} | ||
@@ -482,0 +475,0 @@ ); |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const InnerGraph = require("./optimize/InnerGraph"); | ||
@@ -14,2 +19,4 @@ | ||
const PLUGIN_NAME = "JavascriptMetaInfoPlugin"; | ||
class JavascriptMetaInfoPlugin { | ||
@@ -23,3 +30,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"JavascriptMetaInfoPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -31,3 +38,3 @@ /** | ||
const handler = parser => { | ||
parser.hooks.call.for("eval").tap("JavascriptMetaInfoPlugin", () => { | ||
parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => { | ||
parser.state.module.buildInfo.moduleConcatenationBailout = "eval()"; | ||
@@ -42,3 +49,3 @@ parser.state.module.buildInfo.usingEval = true; | ||
}); | ||
parser.hooks.finish.tap("JavascriptMetaInfoPlugin", () => { | ||
parser.hooks.finish.tap(PLUGIN_NAME, () => { | ||
let topLevelDeclarations = | ||
@@ -60,10 +67,10 @@ parser.state.module.buildInfo.topLevelDeclarations; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("JavascriptMetaInfoPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("JavascriptMetaInfoPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("JavascriptMetaInfoPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -70,0 +77,0 @@ ); |
@@ -8,2 +8,3 @@ /* | ||
const { JSON_MODULE_TYPE } = require("../ModuleTypeConstants"); | ||
const createSchemaValidation = require("../util/create-schema-validation"); | ||
@@ -24,2 +25,8 @@ const JsonGenerator = require("./JsonGenerator"); | ||
const PLUGIN_NAME = "JsonModulesPlugin"; | ||
/** | ||
* The JsonModulesPlugin is the entrypoint plugin for the json modules feature. | ||
* It adds the json module type to the compiler and registers the json parser and generator. | ||
*/ | ||
class JsonModulesPlugin { | ||
@@ -30,10 +37,11 @@ /** | ||
* @returns {void} | ||
* | ||
*/ | ||
apply(compiler) { | ||
compiler.hooks.compilation.tap( | ||
"JsonModulesPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
normalModuleFactory.hooks.createParser | ||
.for("json") | ||
.tap("JsonModulesPlugin", parserOptions => { | ||
.for(JSON_MODULE_TYPE) | ||
.tap(PLUGIN_NAME, parserOptions => { | ||
validate(parserOptions); | ||
@@ -44,4 +52,4 @@ | ||
normalModuleFactory.hooks.createGenerator | ||
.for("json") | ||
.tap("JsonModulesPlugin", () => { | ||
.for(JSON_MODULE_TYPE) | ||
.tap(PLUGIN_NAME, () => { | ||
return new JsonGenerator(); | ||
@@ -48,0 +56,0 @@ }); |
@@ -32,2 +32,3 @@ /* | ||
* @property {string} name | ||
* @property {string} amdContainer | ||
*/ | ||
@@ -56,3 +57,3 @@ | ||
parseOptions(library) { | ||
const { name } = library; | ||
const { name, amdContainer } = library; | ||
if (this.requireAsWrapper) { | ||
@@ -72,3 +73,4 @@ if (name) { | ||
return { | ||
name: /** @type {string=} */ (name) | ||
name: /** @type {string=} */ (name), | ||
amdContainer: /** @type {string=} */ (amdContainer) | ||
}; | ||
@@ -117,5 +119,10 @@ } | ||
let amdContainerPrefix = ""; | ||
if (options.amdContainer) { | ||
amdContainerPrefix = `${options.amdContainer}.`; | ||
} | ||
if (this.requireAsWrapper) { | ||
return new ConcatSource( | ||
`require(${externalsDepsArray}, ${fnStart}`, | ||
`${amdContainerPrefix}require(${externalsDepsArray}, ${fnStart}`, | ||
source, | ||
@@ -130,3 +137,5 @@ `${fnEnd});` | ||
return new ConcatSource( | ||
`define(${JSON.stringify(name)}, ${externalsDepsArray}, ${fnStart}`, | ||
`${amdContainerPrefix}define(${JSON.stringify( | ||
name | ||
)}, ${externalsDepsArray}, ${fnStart}`, | ||
source, | ||
@@ -137,3 +146,3 @@ `${fnEnd});` | ||
return new ConcatSource( | ||
`define(${externalsDepsArray}, ${fnStart}`, | ||
`${amdContainerPrefix}define(${externalsDepsArray}, ${fnStart}`, | ||
source, | ||
@@ -143,3 +152,7 @@ `${fnEnd});` | ||
} else { | ||
return new ConcatSource(`define(${fnStart}`, source, `${fnEnd});`); | ||
return new ConcatSource( | ||
`${amdContainerPrefix}define(${fnStart}`, | ||
source, | ||
`${fnEnd});` | ||
); | ||
} | ||
@@ -165,2 +178,5 @@ } | ||
hash.update(name); | ||
} else if (options.amdContainer) { | ||
hash.update("amdContainer"); | ||
hash.update(options.amdContainer); | ||
} | ||
@@ -167,0 +183,0 @@ } |
@@ -8,2 +8,3 @@ /* | ||
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -89,3 +90,3 @@ const Template = require("../Template"); | ||
chunk, | ||
m => m.type === "webassembly/async" | ||
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC | ||
) | ||
@@ -92,0 +93,0 @@ ) { |
@@ -8,2 +8,3 @@ /* | ||
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -73,3 +74,3 @@ const Template = require("../Template"); | ||
chunk, | ||
m => m.type === "webassembly/sync" | ||
m => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC | ||
) | ||
@@ -76,0 +77,0 @@ ) { |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("./ModuleTypeConstants"); | ||
const NodeStuffInWebError = require("./NodeStuffInWebError"); | ||
@@ -26,2 +30,4 @@ const RuntimeGlobals = require("./RuntimeGlobals"); | ||
const PLUGIN_NAME = "NodeStuffPlugin"; | ||
class NodeStuffPlugin { | ||
@@ -40,3 +46,3 @@ constructor(options) { | ||
compiler.hooks.compilation.tap( | ||
"NodeStuffPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -53,25 +59,23 @@ const handler = (parser, parserOptions) => { | ||
const withWarning = localOptions.global === "warn"; | ||
parser.hooks.expression | ||
.for("global") | ||
.tap("NodeStuffPlugin", expr => { | ||
const dep = new ConstDependency( | ||
RuntimeGlobals.global, | ||
expr.range, | ||
[RuntimeGlobals.global] | ||
parser.hooks.expression.for("global").tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
RuntimeGlobals.global, | ||
expr.range, | ||
[RuntimeGlobals.global] | ||
); | ||
dep.loc = expr.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
// TODO webpack 6 remove | ||
if (withWarning) { | ||
parser.state.module.addWarning( | ||
new NodeStuffInWebError( | ||
dep.loc, | ||
"global", | ||
"The global namespace object is a Node.js feature and isn't available in browsers." | ||
) | ||
); | ||
dep.loc = expr.loc; | ||
parser.state.module.addPresentationalDependency(dep); | ||
// TODO webpack 6 remove | ||
if (withWarning) { | ||
parser.state.module.addWarning( | ||
new NodeStuffInWebError( | ||
dep.loc, | ||
"global", | ||
"The global namespace object is a Node.js feature and isn't available in browsers." | ||
) | ||
); | ||
} | ||
}); | ||
parser.hooks.rename.for("global").tap("NodeStuffPlugin", expr => { | ||
} | ||
}); | ||
parser.hooks.rename.for("global").tap(PLUGIN_NAME, expr => { | ||
const dep = new ConstDependency( | ||
@@ -91,3 +95,3 @@ RuntimeGlobals.global, | ||
.for(expressionName) | ||
.tap("NodeStuffPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
const dep = new CachedConstDependency( | ||
@@ -137,3 +141,3 @@ JSON.stringify(fn(parser.state.module)), | ||
.for("__filename") | ||
.tap("NodeStuffPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (!parser.state.module) return; | ||
@@ -165,3 +169,3 @@ const resource = parseResource(parser.state.module.resource); | ||
.for("__dirname") | ||
.tap("NodeStuffPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if (!parser.state.module) return; | ||
@@ -174,3 +178,3 @@ return evaluateToString(parser.state.module.context)(expr); | ||
.tap( | ||
"NodeStuffPlugin", | ||
PLUGIN_NAME, | ||
expressionIsUnsupported( | ||
@@ -184,7 +188,7 @@ parser, | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("NodeStuffPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("NodeStuffPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -191,0 +195,0 @@ ); |
@@ -25,2 +25,3 @@ /* | ||
const ModuleParseError = require("./ModuleParseError"); | ||
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants"); | ||
const ModuleWarning = require("./ModuleWarning"); | ||
@@ -343,3 +344,3 @@ const RuntimeGlobals = require("./RuntimeGlobals"); | ||
if (this.layer === null) { | ||
if (this.type === "javascript/auto") { | ||
if (this.type === JAVASCRIPT_MODULE_TYPE_AUTO) { | ||
return this.request; | ||
@@ -346,0 +347,0 @@ } else { |
@@ -21,2 +21,3 @@ /* | ||
const ModuleGraph = require("./ModuleGraph"); | ||
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants"); | ||
const NormalModule = require("./NormalModule"); | ||
@@ -493,3 +494,3 @@ const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin"); | ||
} else { | ||
settings.type = "javascript/auto"; | ||
settings.type = JAVASCRIPT_MODULE_TYPE_AUTO; | ||
const resourceDataForRules = matchResourceData || resourceData; | ||
@@ -515,2 +516,7 @@ const result = this.ruleSet.exec({ | ||
for (const r of result) { | ||
// https://github.com/webpack/webpack/issues/16466 | ||
// if a request exists PrePostAutoLoaders, should disable modifying Rule.type | ||
if (r.type === "type" && noPrePostAutoLoaders) { | ||
continue; | ||
} | ||
if (r.type === "use") { | ||
@@ -517,0 +523,0 @@ if (!noAutoLoaders && !noPrePostAutoLoaders) { |
@@ -18,2 +18,3 @@ /* | ||
const Module = require("../Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -687,3 +688,3 @@ const Template = require("../Template"); | ||
constructor({ identifier, rootModule, modules, runtime }) { | ||
super("javascript/esm", null, rootModule && rootModule.layer); | ||
super(JAVASCRIPT_MODULE_TYPE_ESM, null, rootModule && rootModule.layer); | ||
@@ -690,0 +691,0 @@ // Info from Factory |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("../ModuleTypeConstants"); | ||
const PureExpressionDependency = require("../dependencies/PureExpressionDependency"); | ||
@@ -25,2 +29,4 @@ const InnerGraph = require("./InnerGraph"); | ||
const PLUGIN_NAME = "InnerGraphPlugin"; | ||
class InnerGraphPlugin { | ||
@@ -34,3 +40,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"InnerGraphPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -67,7 +73,7 @@ const logger = compilation.getLogger("webpack.InnerGraphPlugin"); | ||
parser.hooks.program.tap("InnerGraphPlugin", () => { | ||
parser.hooks.program.tap(PLUGIN_NAME, () => { | ||
InnerGraph.enable(parser.state); | ||
}); | ||
parser.hooks.finish.tap("InnerGraphPlugin", () => { | ||
parser.hooks.finish.tap(PLUGIN_NAME, () => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
@@ -104,3 +110,3 @@ | ||
parser.hooks.preStatement.tap("InnerGraphPlugin", statement => { | ||
parser.hooks.preStatement.tap(PLUGIN_NAME, statement => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
@@ -118,3 +124,3 @@ | ||
parser.hooks.blockPreStatement.tap("InnerGraphPlugin", statement => { | ||
parser.hooks.blockPreStatement.tap(PLUGIN_NAME, statement => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
@@ -152,29 +158,26 @@ | ||
parser.hooks.preDeclarator.tap( | ||
"InnerGraphPlugin", | ||
(decl, statement) => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
if ( | ||
parser.scope.topLevelScope === true && | ||
decl.init && | ||
decl.id.type === "Identifier" | ||
) { | ||
const name = decl.id.name; | ||
if (decl.init.type === "ClassExpression") { | ||
const fn = InnerGraph.tagTopLevelSymbol(parser, name); | ||
classWithTopLevelSymbol.set(decl.init, fn); | ||
} else if (parser.isPure(decl.init, decl.id.range[1])) { | ||
const fn = InnerGraph.tagTopLevelSymbol(parser, name); | ||
declWithTopLevelSymbol.set(decl, fn); | ||
if ( | ||
!decl.init.type.endsWith("FunctionExpression") && | ||
decl.init.type !== "Literal" | ||
) { | ||
pureDeclarators.add(decl); | ||
} | ||
return true; | ||
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
if ( | ||
parser.scope.topLevelScope === true && | ||
decl.init && | ||
decl.id.type === "Identifier" | ||
) { | ||
const name = decl.id.name; | ||
if (decl.init.type === "ClassExpression") { | ||
const fn = InnerGraph.tagTopLevelSymbol(parser, name); | ||
classWithTopLevelSymbol.set(decl.init, fn); | ||
} else if (parser.isPure(decl.init, decl.id.range[1])) { | ||
const fn = InnerGraph.tagTopLevelSymbol(parser, name); | ||
declWithTopLevelSymbol.set(decl, fn); | ||
if ( | ||
!decl.init.type.endsWith("FunctionExpression") && | ||
decl.init.type !== "Literal" | ||
) { | ||
pureDeclarators.add(decl); | ||
} | ||
return true; | ||
} | ||
} | ||
); | ||
}); | ||
@@ -197,3 +200,3 @@ // During real walking we set the TopLevelSymbol state to the assigned | ||
parser.hooks.statement.tap("InnerGraphPlugin", statement => { | ||
parser.hooks.statement.tap(PLUGIN_NAME, statement => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
@@ -230,3 +233,3 @@ if (parser.scope.topLevelScope === true) { | ||
parser.hooks.classExtendsExpression.tap( | ||
"InnerGraphPlugin", | ||
PLUGIN_NAME, | ||
(expr, statement) => { | ||
@@ -251,3 +254,3 @@ if (!InnerGraph.isEnabled(parser.state)) return; | ||
parser.hooks.classBodyElement.tap( | ||
"InnerGraphPlugin", | ||
PLUGIN_NAME, | ||
(element, classDefinition) => { | ||
@@ -265,3 +268,3 @@ if (!InnerGraph.isEnabled(parser.state)) return; | ||
parser.hooks.classBodyValue.tap( | ||
"InnerGraphPlugin", | ||
PLUGIN_NAME, | ||
(expression, element, classDefinition) => { | ||
@@ -306,3 +309,3 @@ if (!InnerGraph.isEnabled(parser.state)) return; | ||
parser.hooks.declarator.tap("InnerGraphPlugin", (decl, statement) => { | ||
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, statement) => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
@@ -345,3 +348,3 @@ const fn = declWithTopLevelSymbol.get(decl); | ||
.for(topLevelSymbolTag) | ||
.tap("InnerGraphPlugin", () => { | ||
.tap(PLUGIN_NAME, () => { | ||
const topLevelSymbol = /** @type {TopLevelSymbol} */ ( | ||
@@ -359,17 +362,15 @@ parser.currentTagData | ||
}); | ||
parser.hooks.assign | ||
.for(topLevelSymbolTag) | ||
.tap("InnerGraphPlugin", expr => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
if (expr.operator === "=") return true; | ||
}); | ||
parser.hooks.assign.for(topLevelSymbolTag).tap(PLUGIN_NAME, expr => { | ||
if (!InnerGraph.isEnabled(parser.state)) return; | ||
if (expr.operator === "=") return true; | ||
}); | ||
}; | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("InnerGraphPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("InnerGraphPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
compilation.hooks.finishModules.tap("InnerGraphPlugin", () => { | ||
compilation.hooks.finishModules.tap(PLUGIN_NAME, () => { | ||
logger.timeAggregateEnd("infer dependency usage"); | ||
@@ -376,0 +377,0 @@ }); |
@@ -9,2 +9,7 @@ /* | ||
const glob2regexp = require("glob-to-regexp"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("../ModuleTypeConstants"); | ||
const { STAGE_DEFAULT } = require("../OptimizationStages"); | ||
@@ -54,2 +59,4 @@ const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency"); | ||
const PLUGIN_NAME = "SideEffectsFlagPlugin"; | ||
class SideEffectsFlagPlugin { | ||
@@ -74,44 +81,37 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"SideEffectsFlagPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
const moduleGraph = compilation.moduleGraph; | ||
normalModuleFactory.hooks.module.tap( | ||
"SideEffectsFlagPlugin", | ||
(module, data) => { | ||
const resolveData = data.resourceResolveData; | ||
if ( | ||
resolveData && | ||
resolveData.descriptionFileData && | ||
resolveData.relativePath | ||
) { | ||
const sideEffects = resolveData.descriptionFileData.sideEffects; | ||
if (sideEffects !== undefined) { | ||
if (module.factoryMeta === undefined) { | ||
module.factoryMeta = {}; | ||
} | ||
const hasSideEffects = | ||
SideEffectsFlagPlugin.moduleHasSideEffects( | ||
resolveData.relativePath, | ||
sideEffects, | ||
cache | ||
); | ||
module.factoryMeta.sideEffectFree = !hasSideEffects; | ||
} | ||
} | ||
return module; | ||
} | ||
); | ||
normalModuleFactory.hooks.module.tap( | ||
"SideEffectsFlagPlugin", | ||
(module, data) => { | ||
if (typeof data.settings.sideEffects === "boolean") { | ||
normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, data) => { | ||
const resolveData = data.resourceResolveData; | ||
if ( | ||
resolveData && | ||
resolveData.descriptionFileData && | ||
resolveData.relativePath | ||
) { | ||
const sideEffects = resolveData.descriptionFileData.sideEffects; | ||
if (sideEffects !== undefined) { | ||
if (module.factoryMeta === undefined) { | ||
module.factoryMeta = {}; | ||
} | ||
module.factoryMeta.sideEffectFree = !data.settings.sideEffects; | ||
const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects( | ||
resolveData.relativePath, | ||
sideEffects, | ||
cache | ||
); | ||
module.factoryMeta.sideEffectFree = !hasSideEffects; | ||
} | ||
return module; | ||
} | ||
); | ||
return module; | ||
}); | ||
normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, data) => { | ||
if (typeof data.settings.sideEffects === "boolean") { | ||
if (module.factoryMeta === undefined) { | ||
module.factoryMeta = {}; | ||
} | ||
module.factoryMeta.sideEffectFree = !data.settings.sideEffects; | ||
} | ||
return module; | ||
}); | ||
if (this._analyseSource) { | ||
@@ -124,7 +124,7 @@ /** | ||
let sideEffectsStatement; | ||
parser.hooks.program.tap("SideEffectsFlagPlugin", () => { | ||
parser.hooks.program.tap(PLUGIN_NAME, () => { | ||
sideEffectsStatement = undefined; | ||
}); | ||
parser.hooks.statement.tap( | ||
{ name: "SideEffectsFlagPlugin", stage: -100 }, | ||
{ name: PLUGIN_NAME, stage: -100 }, | ||
statement => { | ||
@@ -210,3 +210,3 @@ if (sideEffectsStatement) return; | ||
); | ||
parser.hooks.finish.tap("SideEffectsFlagPlugin", () => { | ||
parser.hooks.finish.tap(PLUGIN_NAME, () => { | ||
if (sideEffectsStatement === undefined) { | ||
@@ -228,9 +228,9 @@ parser.state.module.buildMeta.sideEffectFree = true; | ||
for (const key of [ | ||
"javascript/auto", | ||
"javascript/esm", | ||
"javascript/dynamic" | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_ESM, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
]) { | ||
normalModuleFactory.hooks.parser | ||
.for(key) | ||
.tap("SideEffectsFlagPlugin", parserHandler); | ||
.tap(PLUGIN_NAME, parserHandler); | ||
} | ||
@@ -240,3 +240,3 @@ } | ||
{ | ||
name: "SideEffectsFlagPlugin", | ||
name: PLUGIN_NAME, | ||
stage: STAGE_DEFAULT | ||
@@ -243,0 +243,0 @@ }, |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const ConstDependency = require("./dependencies/ConstDependency"); | ||
@@ -15,2 +20,4 @@ const ProvidedDependency = require("./dependencies/ProvidedDependency"); | ||
const PLUGIN_NAME = "ProvidePlugin"; | ||
class ProvidePlugin { | ||
@@ -32,3 +39,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"ProvidePlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -54,7 +61,7 @@ compilation.dependencyTemplates.set( | ||
const name = splittedName.slice(0, i + 1).join("."); | ||
parser.hooks.canRename.for(name).tap("ProvidePlugin", approve); | ||
parser.hooks.canRename.for(name).tap(PLUGIN_NAME, approve); | ||
}); | ||
} | ||
parser.hooks.expression.for(name).tap("ProvidePlugin", expr => { | ||
parser.hooks.expression.for(name).tap(PLUGIN_NAME, expr => { | ||
const nameIdentifier = name.includes(".") | ||
@@ -74,3 +81,3 @@ ? `__webpack_provided_${name.replace(/\./g, "_dot_")}` | ||
parser.hooks.call.for(name).tap("ProvidePlugin", expr => { | ||
parser.hooks.call.for(name).tap(PLUGIN_NAME, expr => { | ||
const nameIdentifier = name.includes(".") | ||
@@ -93,10 +100,10 @@ ? `__webpack_provided_${name.replace(/\./g, "_dot_")}` | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("ProvidePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("ProvidePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("ProvidePlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -103,0 +110,0 @@ ); |
@@ -10,2 +10,3 @@ /* | ||
const Module = require("./Module"); | ||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants"); | ||
const makeSerializable = require("./util/makeSerializable"); | ||
@@ -39,3 +40,3 @@ | ||
constructor(source, identifier, readableIdentifier, runtimeRequirements) { | ||
super("javascript/dynamic", null); | ||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); | ||
this.sourceStr = source; | ||
@@ -42,0 +43,0 @@ this.identifierStr = identifier || this.sourceStr; |
@@ -8,2 +8,6 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC | ||
} = require("./ModuleTypeConstants"); | ||
const RuntimeGlobals = require("./RuntimeGlobals"); | ||
@@ -17,2 +21,4 @@ const ConstDependency = require("./dependencies/ConstDependency"); | ||
const PLUGIN_NAME = "RequireJsStuffPlugin"; | ||
module.exports = class RequireJsStuffPlugin { | ||
@@ -26,3 +32,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"RequireJsStuffPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -43,12 +49,6 @@ compilation.dependencyTemplates.set( | ||
.for("require.config") | ||
.tap( | ||
"RequireJsStuffPlugin", | ||
toConstantDependency(parser, "undefined") | ||
); | ||
.tap(PLUGIN_NAME, toConstantDependency(parser, "undefined")); | ||
parser.hooks.call | ||
.for("requirejs.config") | ||
.tap( | ||
"RequireJsStuffPlugin", | ||
toConstantDependency(parser, "undefined") | ||
); | ||
.tap(PLUGIN_NAME, toConstantDependency(parser, "undefined")); | ||
@@ -58,3 +58,3 @@ parser.hooks.expression | ||
.tap( | ||
"RequireJsStuffPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("0.0.0")) | ||
@@ -65,3 +65,3 @@ ); | ||
.tap( | ||
"RequireJsStuffPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency( | ||
@@ -75,7 +75,7 @@ parser, | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("RequireJsStuffPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("RequireJsStuffPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -82,0 +82,0 @@ ); |
@@ -227,2 +227,6 @@ /* | ||
} | ||
if (data.name === packageName) { | ||
// Package self-referencing | ||
return resolve(); | ||
} | ||
const requiredVersion = getRequiredVersionFromDescriptionFile( | ||
@@ -229,0 +233,0 @@ data, |
@@ -8,2 +8,7 @@ /* | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const ConstDependency = require("./dependencies/ConstDependency"); | ||
@@ -13,2 +18,4 @@ | ||
const PLUGIN_NAME = "UseStrictPlugin"; | ||
class UseStrictPlugin { | ||
@@ -22,6 +29,6 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"UseStrictPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
const handler = parser => { | ||
parser.hooks.program.tap("UseStrictPlugin", ast => { | ||
parser.hooks.program.tap(PLUGIN_NAME, ast => { | ||
const firstNode = ast.body[0]; | ||
@@ -46,10 +53,10 @@ if ( | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("UseStrictPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("UseStrictPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("UseStrictPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -56,0 +63,0 @@ ); |
@@ -12,2 +12,3 @@ /* | ||
const { tryRunOrWebpackError } = require("../HookWebpackError"); | ||
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants"); | ||
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); | ||
@@ -57,2 +58,4 @@ const { compareModulesByIdentifier } = require("../util/comparators"); | ||
const PLUGIN_NAME = "AsyncWebAssemblyModulesPlugin"; | ||
class AsyncWebAssemblyModulesPlugin { | ||
@@ -94,3 +97,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"AsyncWebAssemblyModulesPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -105,4 +108,4 @@ const hooks = | ||
normalModuleFactory.hooks.createParser | ||
.for("webassembly/async") | ||
.tap("AsyncWebAssemblyModulesPlugin", () => { | ||
.for(WEBASSEMBLY_MODULE_TYPE_ASYNC) | ||
.tap(PLUGIN_NAME, () => { | ||
const AsyncWebAssemblyParser = getAsyncWebAssemblyParser(); | ||
@@ -113,4 +116,4 @@ | ||
normalModuleFactory.hooks.createGenerator | ||
.for("webassembly/async") | ||
.tap("AsyncWebAssemblyModulesPlugin", () => { | ||
.for(WEBASSEMBLY_MODULE_TYPE_ASYNC) | ||
.tap(PLUGIN_NAME, () => { | ||
const AsyncWebAssemblyJavascriptGenerator = | ||
@@ -143,3 +146,3 @@ getAsyncWebAssemblyJavascriptGenerator(); | ||
)) { | ||
if (module.type === "webassembly/async") { | ||
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) { | ||
const filenameTemplate = | ||
@@ -146,0 +149,0 @@ outputOptions.webassemblyModuleFilename; |
@@ -9,2 +9,3 @@ /* | ||
const Generator = require("../Generator"); | ||
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants"); | ||
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency"); | ||
@@ -30,2 +31,4 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); | ||
const PLUGIN_NAME = "WebAssemblyModulesPlugin"; | ||
class WebAssemblyModulesPlugin { | ||
@@ -43,3 +46,3 @@ constructor(options) { | ||
compiler.hooks.compilation.tap( | ||
"WebAssemblyModulesPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -57,4 +60,4 @@ compilation.dependencyFactories.set( | ||
normalModuleFactory.hooks.createParser | ||
.for("webassembly/sync") | ||
.tap("WebAssemblyModulesPlugin", () => { | ||
.for(WEBASSEMBLY_MODULE_TYPE_SYNC) | ||
.tap(PLUGIN_NAME, () => { | ||
const WebAssemblyParser = getWebAssemblyParser(); | ||
@@ -66,4 +69,4 @@ | ||
normalModuleFactory.hooks.createGenerator | ||
.for("webassembly/sync") | ||
.tap("WebAssemblyModulesPlugin", () => { | ||
.for(WEBASSEMBLY_MODULE_TYPE_SYNC) | ||
.tap(PLUGIN_NAME, () => { | ||
const WebAssemblyJavascriptGenerator = | ||
@@ -79,43 +82,39 @@ getWebAssemblyJavascriptGenerator(); | ||
compilation.hooks.renderManifest.tap( | ||
"WebAssemblyModulesPlugin", | ||
(result, options) => { | ||
const { chunkGraph } = compilation; | ||
const { chunk, outputOptions, codeGenerationResults } = options; | ||
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => { | ||
const { chunkGraph } = compilation; | ||
const { chunk, outputOptions, codeGenerationResults } = options; | ||
for (const module of chunkGraph.getOrderedChunkModulesIterable( | ||
chunk, | ||
compareModulesByIdentifier | ||
)) { | ||
if (module.type === "webassembly/sync") { | ||
const filenameTemplate = | ||
outputOptions.webassemblyModuleFilename; | ||
for (const module of chunkGraph.getOrderedChunkModulesIterable( | ||
chunk, | ||
compareModulesByIdentifier | ||
)) { | ||
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) { | ||
const filenameTemplate = outputOptions.webassemblyModuleFilename; | ||
result.push({ | ||
render: () => | ||
codeGenerationResults.getSource( | ||
module, | ||
chunk.runtime, | ||
"webassembly" | ||
), | ||
filenameTemplate, | ||
pathOptions: { | ||
result.push({ | ||
render: () => | ||
codeGenerationResults.getSource( | ||
module, | ||
runtime: chunk.runtime, | ||
chunkGraph | ||
}, | ||
auxiliary: true, | ||
identifier: `webassemblyModule${chunkGraph.getModuleId( | ||
module | ||
)}`, | ||
hash: chunkGraph.getModuleHash(module, chunk.runtime) | ||
}); | ||
} | ||
chunk.runtime, | ||
"webassembly" | ||
), | ||
filenameTemplate, | ||
pathOptions: { | ||
module, | ||
runtime: chunk.runtime, | ||
chunkGraph | ||
}, | ||
auxiliary: true, | ||
identifier: `webassemblyModule${chunkGraph.getModuleId( | ||
module | ||
)}`, | ||
hash: chunkGraph.getModuleHash(module, chunk.runtime) | ||
}); | ||
} | ||
return result; | ||
} | ||
); | ||
compilation.hooks.afterChunks.tap("WebAssemblyModulesPlugin", () => { | ||
return result; | ||
}); | ||
compilation.hooks.afterChunks.tap(PLUGIN_NAME, () => { | ||
const chunkGraph = compilation.chunkGraph; | ||
@@ -126,3 +125,3 @@ const initialWasmModules = new Set(); | ||
for (const module of chunkGraph.getChunkModulesIterable(chunk)) { | ||
if (module.type === "webassembly/sync") { | ||
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) { | ||
initialWasmModules.add(module); | ||
@@ -129,0 +128,0 @@ } |
@@ -8,2 +8,3 @@ /* | ||
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -44,3 +45,3 @@ const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule"); | ||
chunk, | ||
m => m.type === "webassembly/async" | ||
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC | ||
) | ||
@@ -47,0 +48,0 @@ ) { |
@@ -8,2 +8,3 @@ /* | ||
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants"); | ||
const RuntimeGlobals = require("../RuntimeGlobals"); | ||
@@ -16,2 +17,4 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule"); | ||
const PLUGIN_NAME = "FetchCompileWasmPlugin"; | ||
class FetchCompileWasmPlugin { | ||
@@ -28,44 +31,41 @@ constructor(options) { | ||
apply(compiler) { | ||
compiler.hooks.thisCompilation.tap( | ||
"FetchCompileWasmPlugin", | ||
compilation => { | ||
const globalWasmLoading = compilation.outputOptions.wasmLoading; | ||
const isEnabledForChunk = chunk => { | ||
const options = chunk.getEntryOptions(); | ||
const wasmLoading = | ||
options && options.wasmLoading !== undefined | ||
? options.wasmLoading | ||
: globalWasmLoading; | ||
return wasmLoading === "fetch"; | ||
}; | ||
const generateLoadBinaryCode = path => | ||
`fetch(${RuntimeGlobals.publicPath} + ${path})`; | ||
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => { | ||
const globalWasmLoading = compilation.outputOptions.wasmLoading; | ||
const isEnabledForChunk = chunk => { | ||
const options = chunk.getEntryOptions(); | ||
const wasmLoading = | ||
options && options.wasmLoading !== undefined | ||
? options.wasmLoading | ||
: globalWasmLoading; | ||
return wasmLoading === "fetch"; | ||
}; | ||
const generateLoadBinaryCode = path => | ||
`fetch(${RuntimeGlobals.publicPath} + ${path})`; | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.ensureChunkHandlers) | ||
.tap("FetchCompileWasmPlugin", (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) return; | ||
const chunkGraph = compilation.chunkGraph; | ||
if ( | ||
!chunkGraph.hasModuleInGraph( | ||
chunk, | ||
m => m.type === "webassembly/sync" | ||
) | ||
) { | ||
return; | ||
} | ||
set.add(RuntimeGlobals.moduleCache); | ||
set.add(RuntimeGlobals.publicPath); | ||
compilation.addRuntimeModule( | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.ensureChunkHandlers) | ||
.tap(PLUGIN_NAME, (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) return; | ||
const chunkGraph = compilation.chunkGraph; | ||
if ( | ||
!chunkGraph.hasModuleInGraph( | ||
chunk, | ||
new WasmChunkLoadingRuntimeModule({ | ||
generateLoadBinaryCode, | ||
supportsStreaming: true, | ||
mangleImports: this.options.mangleImports, | ||
runtimeRequirements: set | ||
}) | ||
); | ||
}); | ||
} | ||
); | ||
m => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC | ||
) | ||
) { | ||
return; | ||
} | ||
set.add(RuntimeGlobals.moduleCache); | ||
set.add(RuntimeGlobals.publicPath); | ||
compilation.addRuntimeModule( | ||
chunk, | ||
new WasmChunkLoadingRuntimeModule({ | ||
generateLoadBinaryCode, | ||
supportsStreaming: true, | ||
mangleImports: this.options.mangleImports, | ||
runtimeRequirements: set | ||
}) | ||
); | ||
}); | ||
}); | ||
} | ||
@@ -72,0 +72,0 @@ } |
@@ -9,2 +9,7 @@ /* | ||
const IgnoreErrorModuleFactory = require("./IgnoreErrorModuleFactory"); | ||
const { | ||
JAVASCRIPT_MODULE_TYPE_AUTO, | ||
JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
JAVASCRIPT_MODULE_TYPE_ESM | ||
} = require("./ModuleTypeConstants"); | ||
const WebpackIsIncludedDependency = require("./dependencies/WebpackIsIncludedDependency"); | ||
@@ -20,2 +25,4 @@ const { | ||
const PLUGIN_NAME = "WebpackIsIncludedPlugin"; | ||
class WebpackIsIncludedPlugin { | ||
@@ -28,3 +35,3 @@ /** | ||
compiler.hooks.compilation.tap( | ||
"WebpackIsIncludedPlugin", | ||
PLUGIN_NAME, | ||
(compilation, { normalModuleFactory }) => { | ||
@@ -47,3 +54,3 @@ compilation.dependencyFactories.set( | ||
.for("__webpack_is_included__") | ||
.tap("WebpackIsIncludedPlugin", expr => { | ||
.tap(PLUGIN_NAME, expr => { | ||
if ( | ||
@@ -71,3 +78,3 @@ expr.type !== "CallExpression" || | ||
.tap( | ||
"WebpackIsIncludedPlugin", | ||
PLUGIN_NAME, | ||
toConstantDependency(parser, JSON.stringify("function")) | ||
@@ -77,10 +84,10 @@ ); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/auto") | ||
.tap("WebpackIsIncludedPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_AUTO) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/dynamic") | ||
.tap("WebpackIsIncludedPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | ||
.tap(PLUGIN_NAME, handler); | ||
normalModuleFactory.hooks.parser | ||
.for("javascript/esm") | ||
.tap("WebpackIsIncludedPlugin", handler); | ||
.for(JAVASCRIPT_MODULE_TYPE_ESM) | ||
.tap(PLUGIN_NAME, handler); | ||
} | ||
@@ -87,0 +94,0 @@ ); |
{ | ||
"name": "webpack", | ||
"version": "5.77.0", | ||
"version": "5.78.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", |
@@ -6,2 +6,2 @@ /* | ||
*/ | ||
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function t(r,{instancePath:e="",parentData:n,parentDataProperty:s,rootData:a=r}={}){if(!Array.isArray(r))return t.errors=[{params:{type:"array"}}],!1;{const e=r.length;for(let n=0;n<e;n++){let e=r[n];const s=0;if("string"!=typeof e)return t.errors=[{params:{type:"string"}}],!1;if(e.length<1)return t.errors=[{params:{}}],!1;if(0!==s)break}}return t.errors=null,!0}function e(r,{instancePath:n="",parentData:s,parentDataProperty:a,rootData:o=r}={}){let l=null,i=0;if(0===i){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{let s;if(void 0===r.import&&(s="import"))return e.errors=[{params:{missingProperty:s}}],!1;{const s=i;for(const t in r)if("import"!==t&&"name"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(s===i){if(void 0!==r.import){let s=r.import;const a=i,u=i;let c=!1;const m=i;if(i==i)if("string"==typeof s){if(s.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var p=m===i;if(c=c||p,!c){const e=i;t(s,{instancePath:n+"/import",parentData:r,parentDataProperty:"import",rootData:o})||(l=null===l?t.errors:l.concat(t.errors),i=l.length),p=e===i,c=c||p}if(!c){const r={params:{}};return null===l?l=[r]:l.push(r),i++,e.errors=l,!1}i=u,null!==l&&(u?l.length=u:l=null);var f=a===i}else f=!0;if(f)if(void 0!==r.name){const t=i;if("string"!=typeof r.name)return e.errors=[{params:{type:"string"}}],!1;f=t===i}else f=!0}}}}return e.errors=l,0===i}function n(r,{instancePath:s="",parentData:a,parentDataProperty:o,rootData:l=r}={}){let i=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return n.errors=[{params:{type:"object"}}],!1;for(const a in r){let o=r[a];const u=p,c=p;let m=!1;const y=p;e(o,{instancePath:s+"/"+a.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:a,rootData:l})||(i=null===i?e.errors:i.concat(e.errors),p=i.length);var f=y===p;if(m=m||f,!m){const e=p;if(p==p)if("string"==typeof o){if(o.length<1){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}if(f=e===p,m=m||f,!m){const e=p;t(o,{instancePath:s+"/"+a.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:a,rootData:l})||(i=null===i?t.errors:i.concat(t.errors),p=i.length),f=e===p,m=m||f}}if(!m){const r={params:{}};return null===i?i=[r]:i.push(r),p++,n.errors=i,!1}if(p=c,null!==i&&(c?i.length=c:i=null),u!==p)break}}return n.errors=i,0===p}function s(r,{instancePath:t="",parentData:e,parentDataProperty:a,rootData:o=r}={}){let l=null,i=0;const p=i;let f=!1;const u=i;if(i===u)if(Array.isArray(r)){const e=r.length;for(let s=0;s<e;s++){let e=r[s];const a=i,p=i;let f=!1;const u=i;if(i==i)if("string"==typeof e){if(e.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var c=u===i;if(f=f||c,!f){const a=i;n(e,{instancePath:t+"/"+s,parentData:r,parentDataProperty:s,rootData:o})||(l=null===l?n.errors:l.concat(n.errors),i=l.length),c=a===i,f=f||c}if(f)i=p,null!==l&&(p?l.length=p:l=null);else{const r={params:{}};null===l?l=[r]:l.push(r),i++}if(a!==i)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),i++}var m=u===i;if(f=f||m,!f){const s=i;n(r,{instancePath:t,parentData:e,parentDataProperty:a,rootData:o})||(l=null===l?n.errors:l.concat(n.errors),i=l.length),m=s===i,f=f||m}if(!f){const r={params:{}};return null===l?l=[r]:l.push(r),i++,s.errors=l,!1}return i=p,null!==l&&(p?l.length=p:l=null),s.errors=l,0===i}function a(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let o=null,l=0;const i=l;let p=!1;const f=l;if("string"!=typeof r){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}var u=f===l;if(p=p||u,!p){const t=l;if(l==l)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=l;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===o?o=[r]:o.push(r),l++;break}if(t===l){if(void 0!==r.amd){const t=l;if("string"!=typeof r.amd){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}var c=t===l}else c=!0;if(c){if(void 0!==r.commonjs){const t=l;if("string"!=typeof r.commonjs){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}c=t===l}else c=!0;if(c){if(void 0!==r.commonjs2){const t=l;if("string"!=typeof r.commonjs2){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}c=t===l}else c=!0;if(c)if(void 0!==r.root){const t=l;if("string"!=typeof r.root){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}c=t===l}else c=!0}}}}else{const r={params:{type:"object"}};null===o?o=[r]:o.push(r),l++}u=t===l,p=p||u}if(!p){const r={params:{}};return null===o?o=[r]:o.push(r),l++,a.errors=o,!1}return l=i,null!==o&&(i?o.length=i:o=null),a.errors=o,0===l}function o(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let a=null,l=0;const i=l;let p=!1;const f=l;if(l===f)if(Array.isArray(r))if(r.length<1){const r={params:{limit:1}};null===a?a=[r]:a.push(r),l++}else{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=l;if(l===n)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}if(n!==l)break}}else{const r={params:{type:"array"}};null===a?a=[r]:a.push(r),l++}var u=f===l;if(p=p||u,!p){const t=l;if(l===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}if(u=t===l,p=p||u,!p){const t=l;if(l==l)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=l;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===a?a=[r]:a.push(r),l++;break}if(t===l){if(void 0!==r.amd){let t=r.amd;const e=l;if(l===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}var c=e===l}else c=!0;if(c){if(void 0!==r.commonjs){let t=r.commonjs;const e=l;if(l===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}c=e===l}else c=!0;if(c)if(void 0!==r.root){let t=r.root;const e=l,n=l;let s=!1;const o=l;if(l===o)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=l;if(l===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}if(n!==l)break}}else{const r={params:{type:"array"}};null===a?a=[r]:a.push(r),l++}var m=o===l;if(s=s||m,!s){const r=l;if(l===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),l++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),l++}m=r===l,s=s||m}if(s)l=n,null!==a&&(n?a.length=n:a=null);else{const r={params:{}};null===a?a=[r]:a.push(r),l++}c=e===l}else c=!0}}}else{const r={params:{type:"object"}};null===a?a=[r]:a.push(r),l++}u=t===l,p=p||u}}if(!p){const r={params:{}};return null===a?a=[r]:a.push(r),l++,o.errors=a,!1}return l=i,null!==a&&(i?a.length=i:a=null),o.errors=a,0===l}function l(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let i=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return l.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.type&&(e="type"))return l.errors=[{params:{missingProperty:e}}],!1;{const e=p;for(const t in r)if("auxiliaryComment"!==t&&"export"!==t&&"name"!==t&&"type"!==t&&"umdNamedDefine"!==t)return l.errors=[{params:{additionalProperty:t}}],!1;if(e===p){if(void 0!==r.auxiliaryComment){const e=p;a(r.auxiliaryComment,{instancePath:t+"/auxiliaryComment",parentData:r,parentDataProperty:"auxiliaryComment",rootData:s})||(i=null===i?a.errors:i.concat(a.errors),p=i.length);var f=e===p}else f=!0;if(f){if(void 0!==r.export){let t=r.export;const e=p,n=p;let s=!1;const a=p;if(p===a)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=p;if(p===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}if(n!==p)break}}else{const r={params:{type:"array"}};null===i?i=[r]:i.push(r),p++}var u=a===p;if(s=s||u,!s){const r=p;if(p===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}u=r===p,s=s||u}if(!s){const r={params:{}};return null===i?i=[r]:i.push(r),p++,l.errors=i,!1}p=n,null!==i&&(n?i.length=n:i=null),f=e===p}else f=!0;if(f){if(void 0!==r.name){const e=p;o(r.name,{instancePath:t+"/name",parentData:r,parentDataProperty:"name",rootData:s})||(i=null===i?o.errors:i.concat(o.errors),p=i.length),f=e===p}else f=!0;if(f){if(void 0!==r.type){let t=r.type;const e=p,n=p;let s=!1;const a=p;if("var"!==t&&"module"!==t&&"assign"!==t&&"assign-properties"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t){const r={params:{}};null===i?i=[r]:i.push(r),p++}var c=a===p;if(s=s||c,!s){const r=p;if("string"!=typeof t){const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}c=r===p,s=s||c}if(!s){const r={params:{}};return null===i?i=[r]:i.push(r),p++,l.errors=i,!1}p=n,null!==i&&(n?i.length=n:i=null),f=e===p}else f=!0;if(f)if(void 0!==r.umdNamedDefine){const t=p;if("boolean"!=typeof r.umdNamedDefine)return l.errors=[{params:{type:"boolean"}}],!1;f=t===p}else f=!0}}}}}}}return l.errors=i,0===p}function i(t,{instancePath:e="",parentData:n,parentDataProperty:a,rootData:o=t}={}){let p=null,f=0;if(0===f){if(!t||"object"!=typeof t||Array.isArray(t))return i.errors=[{params:{type:"object"}}],!1;{let n;if(void 0===t.name&&(n="name")||void 0===t.exposes&&(n="exposes"))return i.errors=[{params:{missingProperty:n}}],!1;{const n=f;for(const r in t)if("exposes"!==r&&"filename"!==r&&"library"!==r&&"name"!==r&&"runtime"!==r&&"shareScope"!==r)return i.errors=[{params:{additionalProperty:r}}],!1;if(n===f){if(void 0!==t.exposes){const r=f;s(t.exposes,{instancePath:e+"/exposes",parentData:t,parentDataProperty:"exposes",rootData:o})||(p=null===p?s.errors:p.concat(s.errors),f=p.length);var u=r===f}else u=!0;if(u){if(void 0!==t.filename){let e=t.filename;const n=f;if(f===n){if("string"!=typeof e)return i.errors=[{params:{type:"string"}}],!1;if(e.includes("!")||!1!==r.test(e))return i.errors=[{params:{}}],!1;if(e.length<1)return i.errors=[{params:{}}],!1}u=n===f}else u=!0;if(u){if(void 0!==t.library){const r=f;l(t.library,{instancePath:e+"/library",parentData:t,parentDataProperty:"library",rootData:o})||(p=null===p?l.errors:p.concat(l.errors),f=p.length),u=r===f}else u=!0;if(u){if(void 0!==t.name){let r=t.name;const e=f;if(f===e){if("string"!=typeof r)return i.errors=[{params:{type:"string"}}],!1;if(r.length<1)return i.errors=[{params:{}}],!1}u=e===f}else u=!0;if(u){if(void 0!==t.runtime){let r=t.runtime;const e=f,n=f;let s=!1;const a=f;if(!1!==r){const r={params:{}};null===p?p=[r]:p.push(r),f++}var c=a===f;if(s=s||c,!s){const t=f;if(f===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===p?p=[r]:p.push(r),f++}}else{const r={params:{type:"string"}};null===p?p=[r]:p.push(r),f++}c=t===f,s=s||c}if(!s){const r={params:{}};return null===p?p=[r]:p.push(r),f++,i.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),u=e===f}else u=!0;if(u)if(void 0!==t.shareScope){let r=t.shareScope;const e=f;if(f===e){if("string"!=typeof r)return i.errors=[{params:{type:"string"}}],!1;if(r.length<1)return i.errors=[{params:{}}],!1}u=e===f}else u=!0}}}}}}}}return i.errors=p,0===f}module.exports=i,module.exports.default=i; | ||
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function t(r,{instancePath:e="",parentData:n,parentDataProperty:s,rootData:a=r}={}){if(!Array.isArray(r))return t.errors=[{params:{type:"array"}}],!1;{const e=r.length;for(let n=0;n<e;n++){let e=r[n];const s=0;if("string"!=typeof e)return t.errors=[{params:{type:"string"}}],!1;if(e.length<1)return t.errors=[{params:{}}],!1;if(0!==s)break}}return t.errors=null,!0}function e(r,{instancePath:n="",parentData:s,parentDataProperty:a,rootData:o=r}={}){let i=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{let s;if(void 0===r.import&&(s="import"))return e.errors=[{params:{missingProperty:s}}],!1;{const s=l;for(const t in r)if("import"!==t&&"name"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(s===l){if(void 0!==r.import){let s=r.import;const a=l,u=l;let c=!1;const m=l;if(l==l)if("string"==typeof s){if(s.length<1){const r={params:{}};null===i?i=[r]:i.push(r),l++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),l++}var p=m===l;if(c=c||p,!c){const e=l;t(s,{instancePath:n+"/import",parentData:r,parentDataProperty:"import",rootData:o})||(i=null===i?t.errors:i.concat(t.errors),l=i.length),p=e===l,c=c||p}if(!c){const r={params:{}};return null===i?i=[r]:i.push(r),l++,e.errors=i,!1}l=u,null!==i&&(u?i.length=u:i=null);var f=a===l}else f=!0;if(f)if(void 0!==r.name){const t=l;if("string"!=typeof r.name)return e.errors=[{params:{type:"string"}}],!1;f=t===l}else f=!0}}}}return e.errors=i,0===l}function n(r,{instancePath:s="",parentData:a,parentDataProperty:o,rootData:i=r}={}){let l=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return n.errors=[{params:{type:"object"}}],!1;for(const a in r){let o=r[a];const u=p,c=p;let m=!1;const y=p;e(o,{instancePath:s+"/"+a.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:a,rootData:i})||(l=null===l?e.errors:l.concat(e.errors),p=l.length);var f=y===p;if(m=m||f,!m){const e=p;if(p==p)if("string"==typeof o){if(o.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}if(f=e===p,m=m||f,!m){const e=p;t(o,{instancePath:s+"/"+a.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:a,rootData:i})||(l=null===l?t.errors:l.concat(t.errors),p=l.length),f=e===p,m=m||f}}if(!m){const r={params:{}};return null===l?l=[r]:l.push(r),p++,n.errors=l,!1}if(p=c,null!==l&&(c?l.length=c:l=null),u!==p)break}}return n.errors=l,0===p}function s(r,{instancePath:t="",parentData:e,parentDataProperty:a,rootData:o=r}={}){let i=null,l=0;const p=l;let f=!1;const u=l;if(l===u)if(Array.isArray(r)){const e=r.length;for(let s=0;s<e;s++){let e=r[s];const a=l,p=l;let f=!1;const u=l;if(l==l)if("string"==typeof e){if(e.length<1){const r={params:{}};null===i?i=[r]:i.push(r),l++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),l++}var c=u===l;if(f=f||c,!f){const a=l;n(e,{instancePath:t+"/"+s,parentData:r,parentDataProperty:s,rootData:o})||(i=null===i?n.errors:i.concat(n.errors),l=i.length),c=a===l,f=f||c}if(f)l=p,null!==i&&(p?i.length=p:i=null);else{const r={params:{}};null===i?i=[r]:i.push(r),l++}if(a!==l)break}}else{const r={params:{type:"array"}};null===i?i=[r]:i.push(r),l++}var m=u===l;if(f=f||m,!f){const s=l;n(r,{instancePath:t,parentData:e,parentDataProperty:a,rootData:o})||(i=null===i?n.errors:i.concat(n.errors),l=i.length),m=s===l,f=f||m}if(!f){const r={params:{}};return null===i?i=[r]:i.push(r),l++,s.errors=i,!1}return l=p,null!==i&&(p?i.length=p:i=null),s.errors=i,0===l}function a(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let o=null,i=0;const l=i;let p=!1;const f=i;if("string"!=typeof r){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),i++}var u=f===i;if(p=p||u,!p){const t=i;if(i==i)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=i;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===o?o=[r]:o.push(r),i++;break}if(t===i){if(void 0!==r.amd){const t=i;if("string"!=typeof r.amd){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),i++}var c=t===i}else c=!0;if(c){if(void 0!==r.commonjs){const t=i;if("string"!=typeof r.commonjs){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),i++}c=t===i}else c=!0;if(c){if(void 0!==r.commonjs2){const t=i;if("string"!=typeof r.commonjs2){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),i++}c=t===i}else c=!0;if(c)if(void 0!==r.root){const t=i;if("string"!=typeof r.root){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),i++}c=t===i}else c=!0}}}}else{const r={params:{type:"object"}};null===o?o=[r]:o.push(r),i++}u=t===i,p=p||u}if(!p){const r={params:{}};return null===o?o=[r]:o.push(r),i++,a.errors=o,!1}return i=l,null!==o&&(l?o.length=l:o=null),a.errors=o,0===i}function o(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let a=null,i=0;const l=i;let p=!1;const f=i;if(i===f)if(Array.isArray(r))if(r.length<1){const r={params:{limit:1}};null===a?a=[r]:a.push(r),i++}else{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=i;if(i===n)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}if(n!==i)break}}else{const r={params:{type:"array"}};null===a?a=[r]:a.push(r),i++}var u=f===i;if(p=p||u,!p){const t=i;if(i===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}if(u=t===i,p=p||u,!p){const t=i;if(i==i)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=i;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===a?a=[r]:a.push(r),i++;break}if(t===i){if(void 0!==r.amd){let t=r.amd;const e=i;if(i===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}var c=e===i}else c=!0;if(c){if(void 0!==r.commonjs){let t=r.commonjs;const e=i;if(i===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}c=e===i}else c=!0;if(c)if(void 0!==r.root){let t=r.root;const e=i,n=i;let s=!1;const o=i;if(i===o)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=i;if(i===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}if(n!==i)break}}else{const r={params:{type:"array"}};null===a?a=[r]:a.push(r),i++}var m=o===i;if(s=s||m,!s){const r=i;if(i===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===a?a=[r]:a.push(r),i++}}else{const r={params:{type:"string"}};null===a?a=[r]:a.push(r),i++}m=r===i,s=s||m}if(s)i=n,null!==a&&(n?a.length=n:a=null);else{const r={params:{}};null===a?a=[r]:a.push(r),i++}c=e===i}else c=!0}}}else{const r={params:{type:"object"}};null===a?a=[r]:a.push(r),i++}u=t===i,p=p||u}}if(!p){const r={params:{}};return null===a?a=[r]:a.push(r),i++,o.errors=a,!1}return i=l,null!==a&&(l?a.length=l:a=null),o.errors=a,0===i}function i(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:s=r}={}){let l=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return i.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.type&&(e="type"))return i.errors=[{params:{missingProperty:e}}],!1;{const e=p;for(const t in r)if("amdContainer"!==t&&"auxiliaryComment"!==t&&"export"!==t&&"name"!==t&&"type"!==t&&"umdNamedDefine"!==t)return i.errors=[{params:{additionalProperty:t}}],!1;if(e===p){if(void 0!==r.amdContainer){let t=r.amdContainer;const e=p;if(p==p){if("string"!=typeof t)return i.errors=[{params:{type:"string"}}],!1;if(t.length<1)return i.errors=[{params:{}}],!1}var f=e===p}else f=!0;if(f){if(void 0!==r.auxiliaryComment){const e=p;a(r.auxiliaryComment,{instancePath:t+"/auxiliaryComment",parentData:r,parentDataProperty:"auxiliaryComment",rootData:s})||(l=null===l?a.errors:l.concat(a.errors),p=l.length),f=e===p}else f=!0;if(f){if(void 0!==r.export){let t=r.export;const e=p,n=p;let s=!1;const a=p;if(p===a)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=p;if(p===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}if(n!==p)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),p++}var u=a===p;if(s=s||u,!s){const r=p;if(p===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}u=r===p,s=s||u}if(!s){const r={params:{}};return null===l?l=[r]:l.push(r),p++,i.errors=l,!1}p=n,null!==l&&(n?l.length=n:l=null),f=e===p}else f=!0;if(f){if(void 0!==r.name){const e=p;o(r.name,{instancePath:t+"/name",parentData:r,parentDataProperty:"name",rootData:s})||(l=null===l?o.errors:l.concat(o.errors),p=l.length),f=e===p}else f=!0;if(f){if(void 0!==r.type){let t=r.type;const e=p,n=p;let s=!1;const a=p;if("var"!==t&&"module"!==t&&"assign"!==t&&"assign-properties"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t){const r={params:{}};null===l?l=[r]:l.push(r),p++}var c=a===p;if(s=s||c,!s){const r=p;if("string"!=typeof t){const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}c=r===p,s=s||c}if(!s){const r={params:{}};return null===l?l=[r]:l.push(r),p++,i.errors=l,!1}p=n,null!==l&&(n?l.length=n:l=null),f=e===p}else f=!0;if(f)if(void 0!==r.umdNamedDefine){const t=p;if("boolean"!=typeof r.umdNamedDefine)return i.errors=[{params:{type:"boolean"}}],!1;f=t===p}else f=!0}}}}}}}}return i.errors=l,0===p}function l(t,{instancePath:e="",parentData:n,parentDataProperty:a,rootData:o=t}={}){let p=null,f=0;if(0===f){if(!t||"object"!=typeof t||Array.isArray(t))return l.errors=[{params:{type:"object"}}],!1;{let n;if(void 0===t.name&&(n="name")||void 0===t.exposes&&(n="exposes"))return l.errors=[{params:{missingProperty:n}}],!1;{const n=f;for(const r in t)if("exposes"!==r&&"filename"!==r&&"library"!==r&&"name"!==r&&"runtime"!==r&&"shareScope"!==r)return l.errors=[{params:{additionalProperty:r}}],!1;if(n===f){if(void 0!==t.exposes){const r=f;s(t.exposes,{instancePath:e+"/exposes",parentData:t,parentDataProperty:"exposes",rootData:o})||(p=null===p?s.errors:p.concat(s.errors),f=p.length);var u=r===f}else u=!0;if(u){if(void 0!==t.filename){let e=t.filename;const n=f;if(f===n){if("string"!=typeof e)return l.errors=[{params:{type:"string"}}],!1;if(e.includes("!")||!1!==r.test(e))return l.errors=[{params:{}}],!1;if(e.length<1)return l.errors=[{params:{}}],!1}u=n===f}else u=!0;if(u){if(void 0!==t.library){const r=f;i(t.library,{instancePath:e+"/library",parentData:t,parentDataProperty:"library",rootData:o})||(p=null===p?i.errors:p.concat(i.errors),f=p.length),u=r===f}else u=!0;if(u){if(void 0!==t.name){let r=t.name;const e=f;if(f===e){if("string"!=typeof r)return l.errors=[{params:{type:"string"}}],!1;if(r.length<1)return l.errors=[{params:{}}],!1}u=e===f}else u=!0;if(u){if(void 0!==t.runtime){let r=t.runtime;const e=f,n=f;let s=!1;const a=f;if(!1!==r){const r={params:{}};null===p?p=[r]:p.push(r),f++}var c=a===f;if(s=s||c,!s){const t=f;if(f===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===p?p=[r]:p.push(r),f++}}else{const r={params:{type:"string"}};null===p?p=[r]:p.push(r),f++}c=t===f,s=s||c}if(!s){const r={params:{}};return null===p?p=[r]:p.push(r),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),u=e===f}else u=!0;if(u)if(void 0!==t.shareScope){let r=t.shareScope;const e=f;if(f===e){if("string"!=typeof r)return l.errors=[{params:{type:"string"}}],!1;if(r.length<1)return l.errors=[{params:{}}],!1}u=e===f}else u=!0}}}}}}}}return l.errors=p,0===f}module.exports=l,module.exports.default=l; |
{ | ||
"definitions": { | ||
"AmdContainer": { | ||
"description": "Add a container for define/require functions in the AMD module.", | ||
"type": "string", | ||
"minLength": 1 | ||
}, | ||
"AuxiliaryComment": { | ||
@@ -202,2 +207,5 @@ "description": "Add a comment in the UMD wrapper.", | ||
"properties": { | ||
"amdContainer": { | ||
"$ref": "#/definitions/AmdContainer" | ||
}, | ||
"auxiliaryComment": { | ||
@@ -204,0 +212,0 @@ "$ref": "#/definitions/AuxiliaryComment" |
@@ -6,2 +6,2 @@ /* | ||
*/ | ||
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=d,module.exports.default=d;const t={exposes:{$ref:"#/definitions/Exposes"},filename:{type:"string",absolutePath:!1},library:{$ref:"#/definitions/LibraryOptions"},name:{type:"string"},remoteType:{oneOf:[{$ref:"#/definitions/ExternalsType"}]},remotes:{$ref:"#/definitions/Remotes"},runtime:{$ref:"#/definitions/EntryRuntime"},shareScope:{type:"string",minLength:1},shared:{$ref:"#/definitions/Shared"}},e=Object.prototype.hasOwnProperty;function n(r,{instancePath:t="",parentData:e,parentDataProperty:a,rootData:s=r}={}){if(!Array.isArray(r))return n.errors=[{params:{type:"array"}}],!1;{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const a=0;if("string"!=typeof t)return n.errors=[{params:{type:"string"}}],!1;if(t.length<1)return n.errors=[{params:{}}],!1;if(0!==a)break}}return n.errors=null,!0}function a(r,{instancePath:t="",parentData:e,parentDataProperty:s,rootData:o=r}={}){let l=null,i=0;if(0===i){if(!r||"object"!=typeof r||Array.isArray(r))return a.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.import&&(e="import"))return a.errors=[{params:{missingProperty:e}}],!1;{const e=i;for(const t in r)if("import"!==t&&"name"!==t)return a.errors=[{params:{additionalProperty:t}}],!1;if(e===i){if(void 0!==r.import){let e=r.import;const s=i,c=i;let u=!1;const m=i;if(i==i)if("string"==typeof e){if(e.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var p=m===i;if(u=u||p,!u){const a=i;n(e,{instancePath:t+"/import",parentData:r,parentDataProperty:"import",rootData:o})||(l=null===l?n.errors:l.concat(n.errors),i=l.length),p=a===i,u=u||p}if(!u){const r={params:{}};return null===l?l=[r]:l.push(r),i++,a.errors=l,!1}i=c,null!==l&&(c?l.length=c:l=null);var f=s===i}else f=!0;if(f)if(void 0!==r.name){const t=i;if("string"!=typeof r.name)return a.errors=[{params:{type:"string"}}],!1;f=t===i}else f=!0}}}}return a.errors=l,0===i}function s(r,{instancePath:t="",parentData:e,parentDataProperty:o,rootData:l=r}={}){let i=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return s.errors=[{params:{type:"object"}}],!1;for(const e in r){let o=r[e];const c=p,u=p;let m=!1;const y=p;a(o,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:l})||(i=null===i?a.errors:i.concat(a.errors),p=i.length);var f=y===p;if(m=m||f,!m){const a=p;if(p==p)if("string"==typeof o){if(o.length<1){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}if(f=a===p,m=m||f,!m){const a=p;n(o,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:l})||(i=null===i?n.errors:i.concat(n.errors),p=i.length),f=a===p,m=m||f}}if(!m){const r={params:{}};return null===i?i=[r]:i.push(r),p++,s.errors=i,!1}if(p=u,null!==i&&(u?i.length=u:i=null),c!==p)break}}return s.errors=i,0===p}function o(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let l=null,i=0;const p=i;let f=!1;const c=i;if(i===c)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const o=i,p=i;let f=!1;const c=i;if(i==i)if("string"==typeof e){if(e.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var u=c===i;if(f=f||u,!f){const o=i;s(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(l=null===l?s.errors:l.concat(s.errors),i=l.length),u=o===i,f=f||u}if(f)i=p,null!==l&&(p?l.length=p:l=null);else{const r={params:{}};null===l?l=[r]:l.push(r),i++}if(o!==i)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),i++}var m=c===i;if(f=f||m,!f){const o=i;s(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(l=null===l?s.errors:l.concat(s.errors),i=l.length),m=o===i,f=f||m}if(!f){const r={params:{}};return null===l?l=[r]:l.push(r),i++,o.errors=l,!1}return i=p,null!==l&&(p?l.length=p:l=null),o.errors=l,0===i}function l(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const i=o;let p=!1;const f=o;if("string"!=typeof r){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var c=f===o;if(p=p||c,!p){const t=o;if(o==o)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=o;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===s?s=[r]:s.push(r),o++;break}if(t===o){if(void 0!==r.amd){const t=o;if("string"!=typeof r.amd){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var u=t===o}else u=!0;if(u){if(void 0!==r.commonjs){const t=o;if("string"!=typeof r.commonjs){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0;if(u){if(void 0!==r.commonjs2){const t=o;if("string"!=typeof r.commonjs2){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0;if(u)if(void 0!==r.root){const t=o;if("string"!=typeof r.root){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0}}}}else{const r={params:{type:"object"}};null===s?s=[r]:s.push(r),o++}c=t===o,p=p||c}if(!p){const r={params:{}};return null===s?s=[r]:s.push(r),o++,l.errors=s,!1}return o=i,null!==s&&(i?s.length=i:s=null),l.errors=s,0===o}function i(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let p=!1;const f=o;if(o===f)if(Array.isArray(r))if(r.length<1){const r={params:{limit:1}};null===s?s=[r]:s.push(r),o++}else{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=f===o;if(p=p||c,!p){const t=o;if(o===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(c=t===o,p=p||c,!p){const t=o;if(o==o)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=o;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===s?s=[r]:s.push(r),o++;break}if(t===o){if(void 0!==r.amd){let t=r.amd;const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var u=e===o}else u=!0;if(u){if(void 0!==r.commonjs){let t=r.commonjs;const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=e===o}else u=!0;if(u)if(void 0!==r.root){let t=r.root;const e=o,n=o;let a=!1;const l=o;if(o===l)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=o;if(o===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var m=l===o;if(a=a||m,!a){const r=o;if(o===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}m=r===o,a=a||m}if(a)o=n,null!==s&&(n?s.length=n:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}u=e===o}else u=!0}}}else{const r={params:{type:"object"}};null===s?s=[r]:s.push(r),o++}c=t===o,p=p||c}}if(!p){const r={params:{}};return null===s?s=[r]:s.push(r),o++,i.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),i.errors=s,0===o}function p(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return p.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.type&&(e="type"))return p.errors=[{params:{missingProperty:e}}],!1;{const e=o;for(const t in r)if("auxiliaryComment"!==t&&"export"!==t&&"name"!==t&&"type"!==t&&"umdNamedDefine"!==t)return p.errors=[{params:{additionalProperty:t}}],!1;if(e===o){if(void 0!==r.auxiliaryComment){const e=o;l(r.auxiliaryComment,{instancePath:t+"/auxiliaryComment",parentData:r,parentDataProperty:"auxiliaryComment",rootData:a})||(s=null===s?l.errors:s.concat(l.errors),o=s.length);var f=e===o}else f=!0;if(f){if(void 0!==r.export){let t=r.export;const e=o,n=o;let a=!1;const l=o;if(o===l)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=o;if(o===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=l===o;if(a=a||c,!a){const r=o;if(o===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}c=r===o,a=a||c}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),o++,p.errors=s,!1}o=n,null!==s&&(n?s.length=n:s=null),f=e===o}else f=!0;if(f){if(void 0!==r.name){const e=o;i(r.name,{instancePath:t+"/name",parentData:r,parentDataProperty:"name",rootData:a})||(s=null===s?i.errors:s.concat(i.errors),o=s.length),f=e===o}else f=!0;if(f){if(void 0!==r.type){let t=r.type;const e=o,n=o;let a=!1;const l=o;if("var"!==t&&"module"!==t&&"assign"!==t&&"assign-properties"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t){const r={params:{}};null===s?s=[r]:s.push(r),o++}var u=l===o;if(a=a||u,!a){const r=o;if("string"!=typeof t){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=r===o,a=a||u}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),o++,p.errors=s,!1}o=n,null!==s&&(n?s.length=n:s=null),f=e===o}else f=!0;if(f)if(void 0!==r.umdNamedDefine){const t=o;if("boolean"!=typeof r.umdNamedDefine)return p.errors=[{params:{type:"boolean"}}],!1;f=t===o}else f=!0}}}}}}}return p.errors=s,0===o}function f(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){if(!Array.isArray(r))return f.errors=[{params:{type:"array"}}],!1;{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=0;if("string"!=typeof t)return f.errors=[{params:{type:"string"}}],!1;if(t.length<1)return f.errors=[{params:{}}],!1;if(0!==n)break}}return f.errors=null,!0}function c(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return c.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.external&&(e="external"))return c.errors=[{params:{missingProperty:e}}],!1;{const e=o;for(const t in r)if("external"!==t&&"shareScope"!==t)return c.errors=[{params:{additionalProperty:t}}],!1;if(e===o){if(void 0!==r.external){let e=r.external;const n=o,p=o;let u=!1;const m=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var l=m===o;if(u=u||l,!u){const n=o;f(e,{instancePath:t+"/external",parentData:r,parentDataProperty:"external",rootData:a})||(s=null===s?f.errors:s.concat(f.errors),o=s.length),l=n===o,u=u||l}if(!u){const r={params:{}};return null===s?s=[r]:s.push(r),o++,c.errors=s,!1}o=p,null!==s&&(p?s.length=p:s=null);var i=n===o}else i=!0;if(i)if(void 0!==r.shareScope){let t=r.shareScope;const e=o;if(o===e){if("string"!=typeof t)return c.errors=[{params:{type:"string"}}],!1;if(t.length<1)return c.errors=[{params:{}}],!1}i=e===o}else i=!0}}}}return c.errors=s,0===o}function u(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return u.errors=[{params:{type:"object"}}],!1;for(const e in r){let n=r[e];const i=o,p=o;let m=!1;const y=o;c(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?c.errors:s.concat(c.errors),o=s.length);var l=y===o;if(m=m||l,!m){const i=o;if(o==o)if("string"==typeof n){if(n.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(l=i===o,m=m||l,!m){const i=o;f(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?f.errors:s.concat(f.errors),o=s.length),l=i===o,m=m||l}}if(!m){const r={params:{}};return null===s?s=[r]:s.push(r),o++,u.errors=s,!1}if(o=p,null!==s&&(p?s.length=p:s=null),i!==o)break}}return u.errors=s,0===o}function m(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let i=!1;const p=o;if(o===p)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const l=o,i=o;let p=!1;const c=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var f=c===o;if(p=p||f,!p){const l=o;u(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(s=null===s?u.errors:s.concat(u.errors),o=s.length),f=l===o,p=p||f}if(p)o=i,null!==s&&(i?s.length=i:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}if(l!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=p===o;if(i=i||c,!i){const l=o;u(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(s=null===s?u.errors:s.concat(u.errors),o=s.length),c=l===o,i=i||c}if(!i){const r={params:{}};return null===s?s=[r]:s.push(r),o++,m.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),m.errors=s,0===o}const y={eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}};function h(r,{instancePath:t="",parentData:n,parentDataProperty:a,rootData:s=r}={}){let o=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return h.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if(!e.call(y,t))return h.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.eager){const t=l;if("boolean"!=typeof r.eager)return h.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.import){let t=r.import;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var p=s===l;if(a=a||p,!a){const r=l;if(l==l)if("string"==typeof t){if(t.length<1){const r={params:{}};null===o?o=[r]:o.push(r),l++}}else{const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}p=r===l,a=a||p}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0;if(i){if(void 0!==r.packageName){let t=r.packageName;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.requiredVersion){let t=r.requiredVersion;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var f=s===l;if(a=a||f,!a){const r=l;if("string"!=typeof t){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}f=r===l,a=a||f}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0;if(i){if(void 0!==r.shareKey){let t=r.shareKey;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.shareScope){let t=r.shareScope;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.singleton){const t=l;if("boolean"!=typeof r.singleton)return h.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i){if(void 0!==r.strictVersion){const t=l;if("boolean"!=typeof r.strictVersion)return h.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.version){let t=r.version;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var c=s===l;if(a=a||c,!a){const r=l;if("string"!=typeof t){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}c=r===l,a=a||c}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0}}}}}}}}}}return h.errors=o,0===l}function g(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return g.errors=[{params:{type:"object"}}],!1;for(const e in r){let n=r[e];const i=o,p=o;let f=!1;const c=o;h(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?h.errors:s.concat(h.errors),o=s.length);var l=c===o;if(f=f||l,!f){const r=o;if(o==o)if("string"==typeof n){if(n.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}l=r===o,f=f||l}if(!f){const r={params:{}};return null===s?s=[r]:s.push(r),o++,g.errors=s,!1}if(o=p,null!==s&&(p?s.length=p:s=null),i!==o)break}}return g.errors=s,0===o}function D(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let i=!1;const p=o;if(o===p)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const l=o,i=o;let p=!1;const c=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var f=c===o;if(p=p||f,!p){const l=o;g(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(s=null===s?g.errors:s.concat(g.errors),o=s.length),f=l===o,p=p||f}if(p)o=i,null!==s&&(i?s.length=i:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}if(l!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=p===o;if(i=i||c,!i){const l=o;g(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(s=null===s?g.errors:s.concat(g.errors),o=s.length),c=l===o,i=i||c}if(!i){const r={params:{}};return null===s?s=[r]:s.push(r),o++,D.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),D.errors=s,0===o}function d(n,{instancePath:a="",parentData:s,parentDataProperty:l,rootData:i=n}={}){let f=null,c=0;if(0===c){if(!n||"object"!=typeof n||Array.isArray(n))return d.errors=[{params:{type:"object"}}],!1;{const s=c;for(const r in n)if(!e.call(t,r))return d.errors=[{params:{additionalProperty:r}}],!1;if(s===c){if(void 0!==n.exposes){const r=c;o(n.exposes,{instancePath:a+"/exposes",parentData:n,parentDataProperty:"exposes",rootData:i})||(f=null===f?o.errors:f.concat(o.errors),c=f.length);var u=r===c}else u=!0;if(u){if(void 0!==n.filename){let t=n.filename;const e=c;if(c===e){if("string"!=typeof t)return d.errors=[{params:{type:"string"}}],!1;if(t.includes("!")||!1!==r.test(t))return d.errors=[{params:{}}],!1}u=e===c}else u=!0;if(u){if(void 0!==n.library){const r=c;p(n.library,{instancePath:a+"/library",parentData:n,parentDataProperty:"library",rootData:i})||(f=null===f?p.errors:f.concat(p.errors),c=f.length),u=r===c}else u=!0;if(u){if(void 0!==n.name){const r=c;if("string"!=typeof n.name)return d.errors=[{params:{type:"string"}}],!1;u=r===c}else u=!0;if(u){if(void 0!==n.remoteType){let r=n.remoteType;const t=c,e=c;let a=!1,s=null;const o=c;if("var"!==r&&"module"!==r&&"assign"!==r&&"this"!==r&&"window"!==r&&"self"!==r&&"global"!==r&&"commonjs"!==r&&"commonjs2"!==r&&"commonjs-module"!==r&&"commonjs-static"!==r&&"amd"!==r&&"amd-require"!==r&&"umd"!==r&&"umd2"!==r&&"jsonp"!==r&&"system"!==r&&"promise"!==r&&"import"!==r&&"script"!==r&&"node-commonjs"!==r){const r={params:{}};null===f?f=[r]:f.push(r),c++}if(o===c&&(a=!0,s=0),!a){const r={params:{passingSchemas:s}};return null===f?f=[r]:f.push(r),c++,d.errors=f,!1}c=e,null!==f&&(e?f.length=e:f=null),u=t===c}else u=!0;if(u){if(void 0!==n.remotes){const r=c;m(n.remotes,{instancePath:a+"/remotes",parentData:n,parentDataProperty:"remotes",rootData:i})||(f=null===f?m.errors:f.concat(m.errors),c=f.length),u=r===c}else u=!0;if(u){if(void 0!==n.runtime){let r=n.runtime;const t=c,e=c;let a=!1;const s=c;if(!1!==r){const r={params:{}};null===f?f=[r]:f.push(r),c++}var y=s===c;if(a=a||y,!a){const t=c;if(c===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===f?f=[r]:f.push(r),c++}}else{const r={params:{type:"string"}};null===f?f=[r]:f.push(r),c++}y=t===c,a=a||y}if(!a){const r={params:{}};return null===f?f=[r]:f.push(r),c++,d.errors=f,!1}c=e,null!==f&&(e?f.length=e:f=null),u=t===c}else u=!0;if(u){if(void 0!==n.shareScope){let r=n.shareScope;const t=c;if(c===t){if("string"!=typeof r)return d.errors=[{params:{type:"string"}}],!1;if(r.length<1)return d.errors=[{params:{}}],!1}u=t===c}else u=!0;if(u)if(void 0!==n.shared){const r=c;D(n.shared,{instancePath:a+"/shared",parentData:n,parentDataProperty:"shared",rootData:i})||(f=null===f?D.errors:f.concat(D.errors),c=f.length),u=r===c}else u=!0}}}}}}}}}}return d.errors=f,0===c} | ||
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=d,module.exports.default=d;const t={exposes:{$ref:"#/definitions/Exposes"},filename:{type:"string",absolutePath:!1},library:{$ref:"#/definitions/LibraryOptions"},name:{type:"string"},remoteType:{oneOf:[{$ref:"#/definitions/ExternalsType"}]},remotes:{$ref:"#/definitions/Remotes"},runtime:{$ref:"#/definitions/EntryRuntime"},shareScope:{type:"string",minLength:1},shared:{$ref:"#/definitions/Shared"}},e=Object.prototype.hasOwnProperty;function n(r,{instancePath:t="",parentData:e,parentDataProperty:a,rootData:s=r}={}){if(!Array.isArray(r))return n.errors=[{params:{type:"array"}}],!1;{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const a=0;if("string"!=typeof t)return n.errors=[{params:{type:"string"}}],!1;if(t.length<1)return n.errors=[{params:{}}],!1;if(0!==a)break}}return n.errors=null,!0}function a(r,{instancePath:t="",parentData:e,parentDataProperty:s,rootData:o=r}={}){let l=null,i=0;if(0===i){if(!r||"object"!=typeof r||Array.isArray(r))return a.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.import&&(e="import"))return a.errors=[{params:{missingProperty:e}}],!1;{const e=i;for(const t in r)if("import"!==t&&"name"!==t)return a.errors=[{params:{additionalProperty:t}}],!1;if(e===i){if(void 0!==r.import){let e=r.import;const s=i,c=i;let u=!1;const m=i;if(i==i)if("string"==typeof e){if(e.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var p=m===i;if(u=u||p,!u){const a=i;n(e,{instancePath:t+"/import",parentData:r,parentDataProperty:"import",rootData:o})||(l=null===l?n.errors:l.concat(n.errors),i=l.length),p=a===i,u=u||p}if(!u){const r={params:{}};return null===l?l=[r]:l.push(r),i++,a.errors=l,!1}i=c,null!==l&&(c?l.length=c:l=null);var f=s===i}else f=!0;if(f)if(void 0!==r.name){const t=i;if("string"!=typeof r.name)return a.errors=[{params:{type:"string"}}],!1;f=t===i}else f=!0}}}}return a.errors=l,0===i}function s(r,{instancePath:t="",parentData:e,parentDataProperty:o,rootData:l=r}={}){let i=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return s.errors=[{params:{type:"object"}}],!1;for(const e in r){let o=r[e];const c=p,u=p;let m=!1;const y=p;a(o,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:l})||(i=null===i?a.errors:i.concat(a.errors),p=i.length);var f=y===p;if(m=m||f,!m){const a=p;if(p==p)if("string"==typeof o){if(o.length<1){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}if(f=a===p,m=m||f,!m){const a=p;n(o,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:l})||(i=null===i?n.errors:i.concat(n.errors),p=i.length),f=a===p,m=m||f}}if(!m){const r={params:{}};return null===i?i=[r]:i.push(r),p++,s.errors=i,!1}if(p=u,null!==i&&(u?i.length=u:i=null),c!==p)break}}return s.errors=i,0===p}function o(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let l=null,i=0;const p=i;let f=!1;const c=i;if(i===c)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const o=i,p=i;let f=!1;const c=i;if(i==i)if("string"==typeof e){if(e.length<1){const r={params:{}};null===l?l=[r]:l.push(r),i++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),i++}var u=c===i;if(f=f||u,!f){const o=i;s(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(l=null===l?s.errors:l.concat(s.errors),i=l.length),u=o===i,f=f||u}if(f)i=p,null!==l&&(p?l.length=p:l=null);else{const r={params:{}};null===l?l=[r]:l.push(r),i++}if(o!==i)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),i++}var m=c===i;if(f=f||m,!f){const o=i;s(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(l=null===l?s.errors:l.concat(s.errors),i=l.length),m=o===i,f=f||m}if(!f){const r={params:{}};return null===l?l=[r]:l.push(r),i++,o.errors=l,!1}return i=p,null!==l&&(p?l.length=p:l=null),o.errors=l,0===i}function l(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const i=o;let p=!1;const f=o;if("string"!=typeof r){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var c=f===o;if(p=p||c,!p){const t=o;if(o==o)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=o;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===s?s=[r]:s.push(r),o++;break}if(t===o){if(void 0!==r.amd){const t=o;if("string"!=typeof r.amd){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var u=t===o}else u=!0;if(u){if(void 0!==r.commonjs){const t=o;if("string"!=typeof r.commonjs){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0;if(u){if(void 0!==r.commonjs2){const t=o;if("string"!=typeof r.commonjs2){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0;if(u)if(void 0!==r.root){const t=o;if("string"!=typeof r.root){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=t===o}else u=!0}}}}else{const r={params:{type:"object"}};null===s?s=[r]:s.push(r),o++}c=t===o,p=p||c}if(!p){const r={params:{}};return null===s?s=[r]:s.push(r),o++,l.errors=s,!1}return o=i,null!==s&&(i?s.length=i:s=null),l.errors=s,0===o}function i(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let p=!1;const f=o;if(o===f)if(Array.isArray(r))if(r.length<1){const r={params:{limit:1}};null===s?s=[r]:s.push(r),o++}else{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=f===o;if(p=p||c,!p){const t=o;if(o===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(c=t===o,p=p||c,!p){const t=o;if(o==o)if(r&&"object"==typeof r&&!Array.isArray(r)){const t=o;for(const t in r)if("amd"!==t&&"commonjs"!==t&&"root"!==t){const r={params:{additionalProperty:t}};null===s?s=[r]:s.push(r),o++;break}if(t===o){if(void 0!==r.amd){let t=r.amd;const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var u=e===o}else u=!0;if(u){if(void 0!==r.commonjs){let t=r.commonjs;const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=e===o}else u=!0;if(u)if(void 0!==r.root){let t=r.root;const e=o,n=o;let a=!1;const l=o;if(o===l)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=o;if(o===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var m=l===o;if(a=a||m,!a){const r=o;if(o===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}m=r===o,a=a||m}if(a)o=n,null!==s&&(n?s.length=n:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}u=e===o}else u=!0}}}else{const r={params:{type:"object"}};null===s?s=[r]:s.push(r),o++}c=t===o,p=p||c}}if(!p){const r={params:{}};return null===s?s=[r]:s.push(r),o++,i.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),i.errors=s,0===o}function p(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return p.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.type&&(e="type"))return p.errors=[{params:{missingProperty:e}}],!1;{const e=o;for(const t in r)if("amdContainer"!==t&&"auxiliaryComment"!==t&&"export"!==t&&"name"!==t&&"type"!==t&&"umdNamedDefine"!==t)return p.errors=[{params:{additionalProperty:t}}],!1;if(e===o){if(void 0!==r.amdContainer){let t=r.amdContainer;const e=o;if(o==o){if("string"!=typeof t)return p.errors=[{params:{type:"string"}}],!1;if(t.length<1)return p.errors=[{params:{}}],!1}var f=e===o}else f=!0;if(f){if(void 0!==r.auxiliaryComment){const e=o;l(r.auxiliaryComment,{instancePath:t+"/auxiliaryComment",parentData:r,parentDataProperty:"auxiliaryComment",rootData:a})||(s=null===s?l.errors:s.concat(l.errors),o=s.length),f=e===o}else f=!0;if(f){if(void 0!==r.export){let t=r.export;const e=o,n=o;let a=!1;const l=o;if(o===l)if(Array.isArray(t)){const r=t.length;for(let e=0;e<r;e++){let r=t[e];const n=o;if(o===n)if("string"==typeof r){if(r.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(n!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=l===o;if(a=a||c,!a){const r=o;if(o===r)if("string"==typeof t){if(t.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}c=r===o,a=a||c}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),o++,p.errors=s,!1}o=n,null!==s&&(n?s.length=n:s=null),f=e===o}else f=!0;if(f){if(void 0!==r.name){const e=o;i(r.name,{instancePath:t+"/name",parentData:r,parentDataProperty:"name",rootData:a})||(s=null===s?i.errors:s.concat(i.errors),o=s.length),f=e===o}else f=!0;if(f){if(void 0!==r.type){let t=r.type;const e=o,n=o;let a=!1;const l=o;if("var"!==t&&"module"!==t&&"assign"!==t&&"assign-properties"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t){const r={params:{}};null===s?s=[r]:s.push(r),o++}var u=l===o;if(a=a||u,!a){const r=o;if("string"!=typeof t){const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}u=r===o,a=a||u}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),o++,p.errors=s,!1}o=n,null!==s&&(n?s.length=n:s=null),f=e===o}else f=!0;if(f)if(void 0!==r.umdNamedDefine){const t=o;if("boolean"!=typeof r.umdNamedDefine)return p.errors=[{params:{type:"boolean"}}],!1;f=t===o}else f=!0}}}}}}}}return p.errors=s,0===o}function f(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){if(!Array.isArray(r))return f.errors=[{params:{type:"array"}}],!1;{const t=r.length;for(let e=0;e<t;e++){let t=r[e];const n=0;if("string"!=typeof t)return f.errors=[{params:{type:"string"}}],!1;if(t.length<1)return f.errors=[{params:{}}],!1;if(0!==n)break}}return f.errors=null,!0}function c(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return c.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.external&&(e="external"))return c.errors=[{params:{missingProperty:e}}],!1;{const e=o;for(const t in r)if("external"!==t&&"shareScope"!==t)return c.errors=[{params:{additionalProperty:t}}],!1;if(e===o){if(void 0!==r.external){let e=r.external;const n=o,p=o;let u=!1;const m=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var l=m===o;if(u=u||l,!u){const n=o;f(e,{instancePath:t+"/external",parentData:r,parentDataProperty:"external",rootData:a})||(s=null===s?f.errors:s.concat(f.errors),o=s.length),l=n===o,u=u||l}if(!u){const r={params:{}};return null===s?s=[r]:s.push(r),o++,c.errors=s,!1}o=p,null!==s&&(p?s.length=p:s=null);var i=n===o}else i=!0;if(i)if(void 0!==r.shareScope){let t=r.shareScope;const e=o;if(o===e){if("string"!=typeof t)return c.errors=[{params:{type:"string"}}],!1;if(t.length<1)return c.errors=[{params:{}}],!1}i=e===o}else i=!0}}}}return c.errors=s,0===o}function u(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return u.errors=[{params:{type:"object"}}],!1;for(const e in r){let n=r[e];const i=o,p=o;let m=!1;const y=o;c(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?c.errors:s.concat(c.errors),o=s.length);var l=y===o;if(m=m||l,!m){const i=o;if(o==o)if("string"==typeof n){if(n.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}if(l=i===o,m=m||l,!m){const i=o;f(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?f.errors:s.concat(f.errors),o=s.length),l=i===o,m=m||l}}if(!m){const r={params:{}};return null===s?s=[r]:s.push(r),o++,u.errors=s,!1}if(o=p,null!==s&&(p?s.length=p:s=null),i!==o)break}}return u.errors=s,0===o}function m(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let i=!1;const p=o;if(o===p)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const l=o,i=o;let p=!1;const c=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var f=c===o;if(p=p||f,!p){const l=o;u(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(s=null===s?u.errors:s.concat(u.errors),o=s.length),f=l===o,p=p||f}if(p)o=i,null!==s&&(i?s.length=i:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}if(l!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=p===o;if(i=i||c,!i){const l=o;u(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(s=null===s?u.errors:s.concat(u.errors),o=s.length),c=l===o,i=i||c}if(!i){const r={params:{}};return null===s?s=[r]:s.push(r),o++,m.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),m.errors=s,0===o}const y={eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}};function h(r,{instancePath:t="",parentData:n,parentDataProperty:a,rootData:s=r}={}){let o=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return h.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if(!e.call(y,t))return h.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.eager){const t=l;if("boolean"!=typeof r.eager)return h.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.import){let t=r.import;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var p=s===l;if(a=a||p,!a){const r=l;if(l==l)if("string"==typeof t){if(t.length<1){const r={params:{}};null===o?o=[r]:o.push(r),l++}}else{const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}p=r===l,a=a||p}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0;if(i){if(void 0!==r.packageName){let t=r.packageName;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.requiredVersion){let t=r.requiredVersion;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var f=s===l;if(a=a||f,!a){const r=l;if("string"!=typeof t){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}f=r===l,a=a||f}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0;if(i){if(void 0!==r.shareKey){let t=r.shareKey;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.shareScope){let t=r.shareScope;const e=l;if(l===e){if("string"!=typeof t)return h.errors=[{params:{type:"string"}}],!1;if(t.length<1)return h.errors=[{params:{}}],!1}i=e===l}else i=!0;if(i){if(void 0!==r.singleton){const t=l;if("boolean"!=typeof r.singleton)return h.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i){if(void 0!==r.strictVersion){const t=l;if("boolean"!=typeof r.strictVersion)return h.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.version){let t=r.version;const e=l,n=l;let a=!1;const s=l;if(!1!==t){const r={params:{}};null===o?o=[r]:o.push(r),l++}var c=s===l;if(a=a||c,!a){const r=l;if("string"!=typeof t){const r={params:{type:"string"}};null===o?o=[r]:o.push(r),l++}c=r===l,a=a||c}if(!a){const r={params:{}};return null===o?o=[r]:o.push(r),l++,h.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),i=e===l}else i=!0}}}}}}}}}}return h.errors=o,0===l}function g(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;if(0===o){if(!r||"object"!=typeof r||Array.isArray(r))return g.errors=[{params:{type:"object"}}],!1;for(const e in r){let n=r[e];const i=o,p=o;let f=!1;const c=o;h(n,{instancePath:t+"/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:r,parentDataProperty:e,rootData:a})||(s=null===s?h.errors:s.concat(h.errors),o=s.length);var l=c===o;if(f=f||l,!f){const r=o;if(o==o)if("string"==typeof n){if(n.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}l=r===o,f=f||l}if(!f){const r={params:{}};return null===s?s=[r]:s.push(r),o++,g.errors=s,!1}if(o=p,null!==s&&(p?s.length=p:s=null),i!==o)break}}return g.errors=s,0===o}function D(r,{instancePath:t="",parentData:e,parentDataProperty:n,rootData:a=r}={}){let s=null,o=0;const l=o;let i=!1;const p=o;if(o===p)if(Array.isArray(r)){const e=r.length;for(let n=0;n<e;n++){let e=r[n];const l=o,i=o;let p=!1;const c=o;if(o==o)if("string"==typeof e){if(e.length<1){const r={params:{}};null===s?s=[r]:s.push(r),o++}}else{const r={params:{type:"string"}};null===s?s=[r]:s.push(r),o++}var f=c===o;if(p=p||f,!p){const l=o;g(e,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:a})||(s=null===s?g.errors:s.concat(g.errors),o=s.length),f=l===o,p=p||f}if(p)o=i,null!==s&&(i?s.length=i:s=null);else{const r={params:{}};null===s?s=[r]:s.push(r),o++}if(l!==o)break}}else{const r={params:{type:"array"}};null===s?s=[r]:s.push(r),o++}var c=p===o;if(i=i||c,!i){const l=o;g(r,{instancePath:t,parentData:e,parentDataProperty:n,rootData:a})||(s=null===s?g.errors:s.concat(g.errors),o=s.length),c=l===o,i=i||c}if(!i){const r={params:{}};return null===s?s=[r]:s.push(r),o++,D.errors=s,!1}return o=l,null!==s&&(l?s.length=l:s=null),D.errors=s,0===o}function d(n,{instancePath:a="",parentData:s,parentDataProperty:l,rootData:i=n}={}){let f=null,c=0;if(0===c){if(!n||"object"!=typeof n||Array.isArray(n))return d.errors=[{params:{type:"object"}}],!1;{const s=c;for(const r in n)if(!e.call(t,r))return d.errors=[{params:{additionalProperty:r}}],!1;if(s===c){if(void 0!==n.exposes){const r=c;o(n.exposes,{instancePath:a+"/exposes",parentData:n,parentDataProperty:"exposes",rootData:i})||(f=null===f?o.errors:f.concat(o.errors),c=f.length);var u=r===c}else u=!0;if(u){if(void 0!==n.filename){let t=n.filename;const e=c;if(c===e){if("string"!=typeof t)return d.errors=[{params:{type:"string"}}],!1;if(t.includes("!")||!1!==r.test(t))return d.errors=[{params:{}}],!1}u=e===c}else u=!0;if(u){if(void 0!==n.library){const r=c;p(n.library,{instancePath:a+"/library",parentData:n,parentDataProperty:"library",rootData:i})||(f=null===f?p.errors:f.concat(p.errors),c=f.length),u=r===c}else u=!0;if(u){if(void 0!==n.name){const r=c;if("string"!=typeof n.name)return d.errors=[{params:{type:"string"}}],!1;u=r===c}else u=!0;if(u){if(void 0!==n.remoteType){let r=n.remoteType;const t=c,e=c;let a=!1,s=null;const o=c;if("var"!==r&&"module"!==r&&"assign"!==r&&"this"!==r&&"window"!==r&&"self"!==r&&"global"!==r&&"commonjs"!==r&&"commonjs2"!==r&&"commonjs-module"!==r&&"commonjs-static"!==r&&"amd"!==r&&"amd-require"!==r&&"umd"!==r&&"umd2"!==r&&"jsonp"!==r&&"system"!==r&&"promise"!==r&&"import"!==r&&"script"!==r&&"node-commonjs"!==r){const r={params:{}};null===f?f=[r]:f.push(r),c++}if(o===c&&(a=!0,s=0),!a){const r={params:{passingSchemas:s}};return null===f?f=[r]:f.push(r),c++,d.errors=f,!1}c=e,null!==f&&(e?f.length=e:f=null),u=t===c}else u=!0;if(u){if(void 0!==n.remotes){const r=c;m(n.remotes,{instancePath:a+"/remotes",parentData:n,parentDataProperty:"remotes",rootData:i})||(f=null===f?m.errors:f.concat(m.errors),c=f.length),u=r===c}else u=!0;if(u){if(void 0!==n.runtime){let r=n.runtime;const t=c,e=c;let a=!1;const s=c;if(!1!==r){const r={params:{}};null===f?f=[r]:f.push(r),c++}var y=s===c;if(a=a||y,!a){const t=c;if(c===t)if("string"==typeof r){if(r.length<1){const r={params:{}};null===f?f=[r]:f.push(r),c++}}else{const r={params:{type:"string"}};null===f?f=[r]:f.push(r),c++}y=t===c,a=a||y}if(!a){const r={params:{}};return null===f?f=[r]:f.push(r),c++,d.errors=f,!1}c=e,null!==f&&(e?f.length=e:f=null),u=t===c}else u=!0;if(u){if(void 0!==n.shareScope){let r=n.shareScope;const t=c;if(c===t){if("string"!=typeof r)return d.errors=[{params:{type:"string"}}],!1;if(r.length<1)return d.errors=[{params:{}}],!1}u=t===c}else u=!0;if(u)if(void 0!==n.shared){const r=c;D(n.shared,{instancePath:a+"/shared",parentData:n,parentDataProperty:"shared",rootData:i})||(f=null===f?D.errors:f.concat(D.errors),c=f.length),u=r===c}else u=!0}}}}}}}}}}return d.errors=f,0===c} |
{ | ||
"definitions": { | ||
"AmdContainer": { | ||
"description": "Add a container for define/require functions in the AMD module.", | ||
"type": "string", | ||
"minLength": 1 | ||
}, | ||
"AuxiliaryComment": { | ||
@@ -228,2 +233,5 @@ "description": "Add a comment in the UMD wrapper.", | ||
"properties": { | ||
"amdContainer": { | ||
"$ref": "#/definitions/AmdContainer" | ||
}, | ||
"auxiliaryComment": { | ||
@@ -230,0 +238,0 @@ "$ref": "#/definitions/AuxiliaryComment" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4424527
649
128314