UNPKG

durrrrrrrrrjs

Version:

JavaScript Plugin for Nx

47 lines 2.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compileTypeScriptFiles = void 0; const tslib_1 = require("tslib"); const compilation_1 = require("@nrwl/workspace/src/utilities/typescript/compilation"); const create_async_iteratable_1 = require("../create-async-iterable/create-async-iteratable"); const load_ts_transformers_1 = require("./load-ts-transformers"); function compileTypeScriptFiles(normalizedOptions, context, postCompilationCallback) { return (0, tslib_1.__asyncGenerator)(this, arguments, function* compileTypeScriptFiles_1() { const getResult = (success) => ({ success, outfile: normalizedOptions.mainOutputPath, }); const { compilerPluginHooks } = (0, load_ts_transformers_1.loadTsTransformers)(normalizedOptions.transformers); const getCustomTransformers = (program) => ({ before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)), after: compilerPluginHooks.afterHooks.map((hook) => hook(program)), afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)), }); const tscOptions = { outputPath: normalizedOptions.outputPath, projectName: context.projectName, projectRoot: normalizedOptions.projectRoot, tsConfig: normalizedOptions.tsConfig, watch: normalizedOptions.watch, getCustomTransformers, }; return yield (0, tslib_1.__await)(yield (0, tslib_1.__await)(yield* (0, tslib_1.__asyncDelegator)((0, tslib_1.__asyncValues)((0, create_async_iteratable_1.createAsyncIterable)(({ next, done }) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (normalizedOptions.watch) { (0, compilation_1.compileTypeScriptWatcher)(tscOptions, (d) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (d.code === 6194) { yield postCompilationCallback(); next(getResult(true)); } })); } else { const { success } = (0, compilation_1.compileTypeScript)(tscOptions); yield postCompilationCallback(); next(getResult(success)); done(); } })))))); }); } exports.compileTypeScriptFiles = compileTypeScriptFiles; //# sourceMappingURL=compile-typescript-files.js.map