feat: refactoring project
This commit is contained in:
43
node_modules/webpack/lib/dependencies/ContextElementDependency.js
generated
vendored
43
node_modules/webpack/lib/dependencies/ContextElementDependency.js
generated
vendored
@@ -9,7 +9,10 @@ const Dependency = require("../Dependency");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const ModuleDependency = require("./ModuleDependency");
|
||||
|
||||
/** @typedef {import("../ContextModule")} ContextModule */
|
||||
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
@@ -20,9 +23,9 @@ class ContextElementDependency extends ModuleDependency {
|
||||
/**
|
||||
* @param {string} request request
|
||||
* @param {string|undefined} userRequest user request
|
||||
* @param {string} typePrefix type prefix
|
||||
* @param {string | undefined} typePrefix type prefix
|
||||
* @param {string} category category
|
||||
* @param {string[][]=} referencedExports referenced exports
|
||||
* @param {(string[][] | null)=} referencedExports referenced exports
|
||||
* @param {string=} context context
|
||||
* @param {ImportAttributes=} attributes import assertions
|
||||
*/
|
||||
@@ -67,12 +70,36 @@ class ContextElementDependency extends ModuleDependency {
|
||||
* @returns {(string[] | ReferencedExport)[]} referenced exports
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
return this.referencedExports
|
||||
? this.referencedExports.map(e => ({
|
||||
name: e,
|
||||
canMangle: false
|
||||
}))
|
||||
: Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
const refs = [];
|
||||
for (const referencedExport of this.referencedExports) {
|
||||
if (
|
||||
this._typePrefix === "import()" &&
|
||||
referencedExport[0] === "default"
|
||||
) {
|
||||
const selfModule =
|
||||
/** @type {ContextModule} */
|
||||
(moduleGraph.getParentModule(this));
|
||||
const importedModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getModule(this));
|
||||
const exportsType = importedModule.getExportsType(
|
||||
moduleGraph,
|
||||
selfModule.options.namespaceObject === "strict"
|
||||
);
|
||||
if (
|
||||
exportsType === "default-only" ||
|
||||
exportsType === "default-with-named"
|
||||
) {
|
||||
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
}
|
||||
}
|
||||
refs.push({
|
||||
name: referencedExport,
|
||||
canMangle: false
|
||||
});
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user