@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
30 lines (28 loc) • 1.12 kB
JavaScript
import { tsUtils } from '@neo-one/ts-utils';
import { Concatenator } from '@neo-one/typescript-concatenator';
import ts from 'typescript';
export const transpile = ({ sourceFile, context }) => {
const isExternalFile = (node, _importPath, decl) => {
if (ts.isImportDeclaration(decl) &&
!tsUtils.importExport.hasValueReference(context.program, context.languageService, decl)) {
return true;
}
return context.builtins.isBuiltinFile(node);
};
const concatenator = new Concatenator({
context: {
typeChecker: context.typeChecker,
program: context.program,
languageService: context.languageService,
getSymbol: context.analysis.getSymbol.bind(context.analysis),
isExternalFile,
},
sourceFile,
});
const sourceFiles = concatenator.sourceFiles;
if (sourceFiles.length === 0 || sourceFiles.length === 1) {
return undefined;
}
return tsUtils.printBundle(context.program, sourceFiles, concatenator.substituteNode);
};
//# sourceMappingURL=transpile.js.map