Skip to content

Commit

Permalink
Optimize; V2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
shrinktofit committed Oct 29, 2020
1 parent f9cc0ee commit dc5d8c3
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 336 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tfig",
"version": "2.0.4",
"version": "2.0.6",
"description": "Yet another tool to generate .d.ts bundle.",
"main": "build/gift.js",
"types": "build/gift.d.ts",
Expand Down
31 changes: 12 additions & 19 deletions source/gift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,35 +185,28 @@ export function rollupTypes(options: IOptions) {

function addAliasExports(moduleDistribution: distributeExports.InternalModuleMeta) {
const rModule = distributionMap.get(moduleDistribution)!;
rModule.aliasExports = moduleDistribution.aliasExports.map((aeDistribution) => {
return {
for (const aeDistribution of moduleDistribution.aliasExports) {
rModule.addAliasExport({
module: distributionMap.get(aeDistribution.module)!,
importName: aeDistribution.module.mainExports[aeDistribution.mainExportIndex].exportSymbol.name,
exportName: aeDistribution.exportSymbol.name,
};
});
});
}
}

function registerNonExportedSymbol(symbol: ts.Symbol, currentModule: rConcepts.NamespaceTraits) {
let currentExportingModule = currentModule;
while (!currentExportingModule.entity.symbol) {
currentExportingModule = currentExportingModule.entity.parent.entity.namespaceTraits!;
function registerNonExportedSymbol(symbol: ts.Symbol, currentNamespace: rConcepts.NamespaceTraits) {
let currentNamespaceInSource = currentNamespace;
while (!currentNamespaceInSource.entity.symbol) {
currentNamespaceInSource = currentNamespaceInSource.entity.parent.entity.namespaceTraits!;
}

// const neNamespaceParent = currentExportingModule;
const neNamespaceParent = currentExportingModule.entity.ownerModule ?? currentExportingModule;
let neNamespace = neNamespaceParent.neNamespace;
const neNamespaceParent = currentNamespaceInSource.entity.ownerModuleOrThis;
let neNamespace = neNamespaceParent.namespaceTraits.neNamespace;
if (!neNamespace) {
console.log(`Create ne namespace for ${neNamespaceParent.entity.name}`);
const neNs = new rConcepts.Entity(neNamespaceParent, `__private`, null);
const trait = neNs.addNamespaceTraits();
neNamespace = {
trait,
statements: [],
};
neNamespaceParent.neNamespace = neNamespace;
neNamespace = neNamespaceParent.namespaceTraits.createNENamespace();
}
const name = generateUniqueName(symbol, neNamespace.trait, currentExportingModule);
const name = generateUniqueName(symbol, neNamespace.trait, currentNamespaceInSource);
const entity = new rConcepts.Entity(neNamespace.trait, name, symbol);
rEntityMap.set(symbol, entity);
return {
Expand Down
110 changes: 0 additions & 110 deletions source/module-interop.ts

This file was deleted.

2 changes: 1 addition & 1 deletion source/name-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function mayUnambiguousReferenceTo(ref: rConcepts.Entity, from: rConcepts.Namesp
return false;
}
}
if (ns.entity.isModule) {
if (ns.entity.isModule()) {
break;
} else {
ns = ns.entity.parent;
Expand Down
Loading

0 comments on commit dc5d8c3

Please sign in to comment.