ng-packagr
Version:
Compile and package a TypeScript library to Angular Package Format
44 lines • 2.6 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.compileNgcTransform = void 0;
const path = require("path");
const ts = require("typescript");
const transform_1 = require("../../graph/transform");
const compile_source_files_1 = require("../../ngc/compile-source-files");
const ngcc_processor_1 = require("../../ngc/ngcc-processor");
const tsconfig_1 = require("../../ts/tsconfig");
const log = require("../../utils/log");
const nodes_1 = require("../nodes");
const stylesheet_processor_1 = require("../../styles/stylesheet-processor");
exports.compileNgcTransform = transform_1.transformFromPromise((graph) => __awaiter(void 0, void 0, void 0, function* () {
log.info(`Compiling TypeScript sources through ngc`);
const entryPoint = graph.find(nodes_1.isEntryPointInProgress());
const entryPoints = graph.filter(nodes_1.isEntryPoint);
// Add paths mappings for dependencies
const tsConfig = tsconfig_1.setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);
// Compile TypeScript sources
const { esm2015, declarations } = entryPoint.data.destinationFiles;
const { moduleResolutionCache } = entryPoint.cache;
const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;
const stylesheetProcessor = new stylesheet_processor_1.StylesheetProcessor(basePath, cssUrl, styleIncludePaths);
const ngccProcessor = tsConfig.options.enableIvy
? new ngcc_processor_1.NgccProcessor(tsConfig.project, tsConfig.options, entryPoints)
: undefined;
yield compile_source_files_1.compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetProcessor, {
outDir: path.dirname(esm2015),
declarationDir: path.dirname(declarations),
declaration: true,
target: ts.ScriptTarget.ES2015,
}, ngccProcessor);
return graph;
}));
//# sourceMappingURL=compile-ngc.transform.js.map