feat: refactoring project
This commit is contained in:
51
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
51
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
@@ -45,15 +45,14 @@ const WorkerDependency = require("./WorkerDependency");
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
||||
|
||||
/**
|
||||
* @param {NormalModule} module module
|
||||
* @returns {string} url
|
||||
*/
|
||||
const getUrl = module => {
|
||||
return pathToFileURL(module.resource).toString();
|
||||
};
|
||||
const getUrl = module => pathToFileURL(module.resource).toString();
|
||||
|
||||
const WorkerSpecifierTag = Symbol("worker specifier tag");
|
||||
|
||||
@@ -82,6 +81,7 @@ class WorkerPlugin {
|
||||
this._module = module;
|
||||
this._workerPublicPath = workerPublicPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
@@ -251,14 +251,14 @@ class WorkerPlugin {
|
||||
parser.state.module.addWarning(
|
||||
new CommentCompilationWarning(
|
||||
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
|
||||
comment.loc
|
||||
/** @type {DependencyLocation} */ (comment.loc)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {EntryOptions} */
|
||||
let entryOptions = {};
|
||||
const entryOptions = {};
|
||||
|
||||
if (importOptions) {
|
||||
if (importOptions.webpackIgnore !== undefined) {
|
||||
@@ -269,10 +269,8 @@ class WorkerPlugin {
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if (importOptions.webpackIgnore) {
|
||||
return false;
|
||||
}
|
||||
} else if (importOptions.webpackIgnore) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (importOptions.webpackEntryOptions !== undefined) {
|
||||
@@ -316,16 +314,19 @@ class WorkerPlugin {
|
||||
}
|
||||
|
||||
if (entryOptions.runtime === undefined) {
|
||||
let i = workerIndexMap.get(parser.state) || 0;
|
||||
const i = workerIndexMap.get(parser.state) || 0;
|
||||
workerIndexMap.set(parser.state, i + 1);
|
||||
let name = `${cachedContextify(
|
||||
const name = `${cachedContextify(
|
||||
parser.state.module.identifier()
|
||||
)}|${i}`;
|
||||
const hash = createHash(compilation.outputOptions.hashFunction);
|
||||
hash.update(name);
|
||||
const digest = /** @type {string} */ (
|
||||
hash.digest(compilation.outputOptions.hashDigest)
|
||||
const hash = createHash(
|
||||
/** @type {Algorithm} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
);
|
||||
hash.update(name);
|
||||
const digest =
|
||||
/** @type {string} */
|
||||
(hash.digest(compilation.outputOptions.hashDigest));
|
||||
entryOptions.runtime = digest.slice(
|
||||
0,
|
||||
compilation.outputOptions.hashDigestLength
|
||||
@@ -394,15 +395,13 @@ class WorkerPlugin {
|
||||
dep2.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep1);
|
||||
parser.state.module.addPresentationalDependency(dep2);
|
||||
} else if (insertType === "argument") {
|
||||
if (this._module) {
|
||||
const dep = new ConstDependency(
|
||||
', { type: "module" }',
|
||||
insertLocation
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
}
|
||||
} else if (insertType === "argument" && this._module) {
|
||||
const dep = new ConstDependency(
|
||||
', { type: "module" }',
|
||||
insertLocation
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
}
|
||||
|
||||
parser.walkExpression(expr.callee);
|
||||
@@ -482,7 +481,9 @@ class WorkerPlugin {
|
||||
};
|
||||
for (const item of options) {
|
||||
if (item === "...") {
|
||||
DEFAULT_SYNTAX.forEach(processItem);
|
||||
for (const itemFromDefault of DEFAULT_SYNTAX) {
|
||||
processItem(itemFromDefault);
|
||||
}
|
||||
} else processItem(item);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user