st-bundle
Version:
CLI for watching and bundling SpringType projects.
62 lines (61 loc) • 2.46 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ProductionModule {
constructor(context, module, productionPackage) {
this.context = context;
this.module = module;
this.productionPackage = productionPackage;
this.ctx = module.props.ctx;
this.dependants = [];
this.dynamicDependencies = [];
}
getId() {
if (this.id === undefined) {
this.id = this.context.generateUniqueId();
}
return this.id;
}
findDependantModule(name) {
// a special treatment for tslib
if (name === 'tslib') {
const tslib = this.context.getTsLibModule();
return tslib.productionModule;
}
for (const info of this.module.fastAnalysis.imports) {
if (name === info.statement) {
if (!info.link)
return;
if (info.link.module) {
return info.link.module.productionModule;
}
if (info.link.package && info.link.resolver) {
const packageTargetAbsPath = info.link.resolver.package.targetAbsPath;
const targetProductionPackage = info.link.package.productionPackage;
const targetModule = targetProductionPackage.pkg.modules.find(mod => mod.props.absPath === packageTargetAbsPath);
if (targetModule) {
return targetModule.productionModule;
}
else {
const entries = info.link.package.getAllEntries();
// a very rare edge case where the same version of the same package resides in difference folders
if (entries.length) {
const targetModule = targetProductionPackage.pkg.modules.find(item => {
return (item.props.fuseBoxPath = info.link.resolver.package.targetFuseBoxPath);
});
if (targetModule)
return targetModule.productionModule;
}
}
}
}
}
}
getShortPath() {
return this.module.getShortPath();
}
getSourceText() {
return this.file.getText();
}
treeShake() { }
}
exports.ProductionModule = ProductionModule;