feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -96,14 +96,13 @@ class CommonJsExportRequireDependency extends ModuleDependency {
const getFullResult = () => {
if (ids.length === 0) {
return Dependency.EXPORTS_OBJECT_REFERENCED;
} else {
return [
{
name: ids,
canMangle: false
}
];
}
return [
{
name: ids,
canMangle: false
}
];
};
if (this.resultUsed) return getFullResult();
/** @type {ExportsInfo | undefined} */
@@ -146,8 +145,8 @@ class CommonJsExportRequireDependency extends ModuleDependency {
* @returns {ExportsSpec | undefined} export names
*/
getExports(moduleGraph) {
const ids = this.getIds(moduleGraph);
if (this.names.length === 1) {
const ids = this.getIds(moduleGraph);
const name = this.names[0];
const from = moduleGraph.getConnection(this);
if (!from) return;
@@ -179,39 +178,36 @@ class CommonJsExportRequireDependency extends ModuleDependency {
],
dependencies: undefined
};
} else {
const from = moduleGraph.getConnection(this);
if (!from) return;
const reexportInfo = this.getStarReexports(
moduleGraph,
undefined,
from.module
);
if (reexportInfo) {
return {
exports: Array.from(
/** @type {TODO} */ (reexportInfo).exports,
name => {
return {
name,
from,
export: ids.concat(name),
canMangle: !(name in EMPTY_OBJECT) && false
};
}
),
// TODO handle deep reexports
dependencies: [from.module]
};
} else {
return {
exports: true,
from: ids.length === 0 ? from : undefined,
canMangle: false,
dependencies: [from.module]
};
}
}
const from = moduleGraph.getConnection(this);
if (!from) return;
const reexportInfo = this.getStarReexports(
moduleGraph,
undefined,
from.module
);
const ids = this.getIds(moduleGraph);
if (reexportInfo) {
return {
exports: Array.from(
/** @type {TODO} */ (reexportInfo).exports,
name => ({
name,
from,
export: ids.concat(name),
canMangle: !(name in EMPTY_OBJECT) && false
})
),
// TODO handle deep reexports
dependencies: [from.module]
};
}
return {
exports: true,
from: ids.length === 0 ? from : undefined,
canMangle: false,
dependencies: [from.module]
};
}
/**
@@ -382,7 +378,7 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
if (usedImported) {
const comment = equals(usedImported, ids)
? ""
: Template.toNormalComment(propertyAccess(ids)) + " ";
: `${Template.toNormalComment(propertyAccess(ids))} `;
requireExpr += `${comment}${propertyAccess(usedImported)}`;
}
}