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,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IAE5D,sCAAsC;IACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC5B,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;QAChC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC;QACjE,MAAM,UAAU,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAEnF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzBD,oEAyBC","sourcesContent":["import type { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { EntryPointNode } from '../ng-package/nodes';\nimport { ngCompilerCli } from '../utils/load-esm';\nimport * as log from '../utils/log';\n\nexport const defaultTsConfigPath = path.join(__dirname, 'conf', 'tsconfig.ngc.json');\n/**\n * Reads the default TypeScript configuration.\n */\nasync function readDefaultTsConfig(fileName = defaultTsConfigPath): Promise<ParsedConfiguration> {\n // these options are mandatory\n const extraOptions: CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n\n // sourcemaps\n sourceMap: false,\n inlineSources: true,\n inlineSourceMap: true,\n\n outDir: '',\n declaration: true,\n\n // ng compiler\n enableResourceInlining: true,\n\n // these are required to set the appropriate EmitFlags\n flatModuleId: 'AUTOGENERATED',\n flatModuleOutFile: 'AUTOGENERATED',\n };\n\n const { readConfiguration } = await ngCompilerCli();\n\n return readConfiguration(fileName, extraOptions);\n}\n\n/**\n * Creates a parsed TypeScript configuration object.\n *\n * @param values File path or parsed configuration.\n */\nasync function createDefaultTsConfig(values?: ParsedConfiguration | string): Promise<ParsedConfiguration> {\n if (!values) {\n return readDefaultTsConfig();\n } else if (typeof values === 'string') {\n return readDefaultTsConfig(values);\n } else {\n return values;\n }\n}\n\n/**\n * Initializes TypeScript Compiler options and Angular Compiler options by overriding the\n * default config with entry point-specific values.\n */\nexport async function initializeTsConfig(\n defaultTsConfig: ParsedConfiguration | string | undefined,\n entryPoints: EntryPointNode[],\n): Promise<void> {\n const defaultTsConfigParsed = await createDefaultTsConfig(defaultTsConfig);\n if (defaultTsConfigParsed.errors.length > 0) {\n const { formatDiagnostics } = await ngCompilerCli();\n throw new Error(formatDiagnostics(defaultTsConfigParsed.errors));\n }\n\n entryPoints.forEach(currentEntryPoint => {\n const { entryPoint } = currentEntryPoint.data;\n log.debug(`Initializing tsconfig for ${entryPoint.moduleId}`);\n const basePath = path.dirname(entryPoint.entryFilePath);\n\n // Resolve defaults from DI token and create a deep copy of the defaults\n const tsConfig: ParsedConfiguration = JSON.parse(JSON.stringify(defaultTsConfigParsed));\n const overrideOptions: CompilerOptions = {\n flatModuleId: entryPoint.moduleId,\n flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,\n basePath,\n rootDir: basePath,\n sourceRoot: '',\n };\n\n tsConfig.rootNames = [entryPoint.entryFilePath];\n tsConfig.options = { ...tsConfig.options, ...overrideOptions };\n currentEntryPoint.data.tsConfig = tsConfig;\n });\n}\n\n/**\n * Set the paths for entrypoint dependencies.\n *\n * This doesn't mutate the object.\n *\n * @param parsedTsConfig - A parsed tsconfig\n * @param entryPoints - A list of entryPoints\n * @param pointToSource Point the path mapping to either the source code or emitted declarations.\n * Typically for analysis one should point to the source files while for a compilation once should use the emitted declarations\n */\nexport function setDependenciesTsConfigPaths(\n parsedTsConfig: ParsedConfiguration,\n entryPoints: EntryPointNode[],\n pointToSource = false,\n): ParsedConfiguration {\n const tsConfig = JSON.parse(JSON.stringify(parsedTsConfig));\n\n // Add paths mappings for dependencies\n if (!tsConfig.options.paths) {\n tsConfig.options.paths = {};\n }\n\n for (const dep of entryPoints) {\n const { entryPoint } = dep.data;\n const { moduleId, destinationFiles, entryFilePath } = entryPoint;\n const mappedPath = [pointToSource ? entryFilePath : destinationFiles.declarations];\n\n if (!tsConfig.options.paths[moduleId]) {\n tsConfig.options.paths[moduleId] = mappedPath;\n } else {\n tsConfig.options.paths[moduleId].unshift(...mappedPath);\n }\n }\n\n return tsConfig;\n}\n"]} |