UNPKG

@nx/angular

Version:

The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypre

46 lines (45 loc) 1.98 kB
"use strict"; /** * Adapted from a private function at ng-packagr * https://github.com/ng-packagr/ng-packagr/blob/main/src/lib/ts/tsconfig.ts#L12: * * Changes made: * - Added an extra function that updates the configFilePath in the returned parsed options * to be the original tsconfig file. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.parseRemappedTsConfigAndMergeDefaults = parseRemappedTsConfigAndMergeDefaults; const tslib_1 = require("tslib"); const path_1 = require("path"); const ts = tslib_1.__importStar(require("typescript")); const module_loader_1 = require("./module-loader"); const ng_packagr_version_1 = require("./ng-packagr/ng-packagr-version"); async function readDefaultTsConfig(fileName) { const ngPackagrVersion = (0, ng_packagr_version_1.getNgPackagrVersionInfo)(); // these options are mandatory const extraOptions = { target: ts.ScriptTarget.ES2022, composite: false, // sourcemaps sourceMap: ngPackagrVersion.major < 20 ? false : true, inlineSources: true, inlineSourceMap: ngPackagrVersion.major < 20 ? true : false, outDir: '', declaration: true, // ng compiler enableResourceInlining: true, // these are required to set the appropriate EmitFlags flatModuleId: 'AUTOGENERATED', flatModuleOutFile: 'AUTOGENERATED', }; const { readConfiguration } = await (0, module_loader_1.loadEsmModule)('@angular/compiler-cli'); return readConfiguration(fileName, extraOptions); } /** * Proxy function that ensures the configFilePath option points to the original file path. */ async function parseRemappedTsConfigAndMergeDefaults(workspaceRoot, originalFilePath, remappedFilePath) { const parsedConfiguration = await readDefaultTsConfig(remappedFilePath); parsedConfiguration.options.configFilePath = (0, path_1.resolve)(workspaceRoot, originalFilePath); return parsedConfiguration; }