in src/assembler.ts [576:624]
symbolId: symbolIdentifier(this._typeChecker, symbol),
locationInModule: this.declarationLocation(declaration),
});
this._addToSubmodule(symbol, symbol, packageRoot);
return;
}
if (!ts.isNamespaceExport(declaration)) {
// Nothing to do here...
return;
}
const moduleSpecifier = declaration.parent.moduleSpecifier;
if (moduleSpecifier == null || !ts.isStringLiteral(moduleSpecifier)) {
// There is a grammar error here, so we'll let tsc report this for us.
return;
}
const resolution = ts.resolveModuleName(
moduleSpecifier.text,
declaration.getSourceFile().fileName,
this.program.getCompilerOptions(),
this.system,
);
if (resolution.resolvedModule == null) {
// Unresolvable module... We'll let tsc report this for us.
return;
}
if (
// We're not looking into a dependency's namespace exports, and the resolution says it's external
(packageRoot === this.projectInfo.projectRoot && resolution.resolvedModule.isExternalLibraryImport) ||
// Or the module resolves outside of the current dependency's tree entirely
!isUnder(resolution.resolvedModule.resolvedFileName, packageRoot) ||
// Or the module is under one the current dependency's node_modules subtree
resolution.resolvedModule.resolvedFileName
.split('/') // Separator is always '/', even on Windows
.filter((entry) => entry === 'node_modules').length !==
packageRoot.split('/').filter((entry) => entry === 'node_modules').length
) {
// External re-exports are "pure-javascript" sugar; they need not be
// represented in the jsii Assembly since the types in there will be
// resolved through dependencies.
return;
}
const sourceFile = this.program.getSourceFile(resolution.resolvedModule.resolvedFileName)!;
const sourceModule = this._typeChecker.getSymbolAtLocation(sourceFile);
// If there's no module, it's a syntax error, and tsc will have reported it for us.
if (sourceModule) {
if (symbol.name !== Case.camel(symbol.name) && symbol.name !== Case.snake(symbol.name)) {