@nx/angular
Version:
43 lines (42 loc) • 1.72 kB
JavaScript
;
/**
* 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");
async function readDefaultTsConfig(fileName) {
// these options are mandatory
const extraOptions = {
target: ts.ScriptTarget.ES2022,
// sourcemaps
sourceMap: false,
inlineSources: true,
inlineSourceMap: true,
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;
}