ng-packagr 17.0.0-rc.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/version.command.js +2 -2
- package/lib/commands/version.command.js.map +1 -1
- package/lib/ngc/compile-source-files.js +2 -2
- package/lib/ngc/compile-source-files.js.map +1 -1
- package/lib/styles/stylesheet-processor.js +5 -2
- package/lib/styles/stylesheet-processor.js.map +1 -1
- package/lib/ts/tsconfig.js +3 -3
- package/lib/ts/tsconfig.js.map +1 -1
- package/lib/utils/cache.d.ts +1 -1
- package/lib/utils/cache.js +2 -2
- package/lib/utils/cache.js.map +1 -1
- package/lib/utils/load-esm.d.ts +15 -0
- package/lib/utils/load-esm.js +29 -0
- package/lib/utils/load-esm.js.map +1 -0
- package/package.json +16 -16
- package/lib/utils/ng-compiler-cli.d.ts +0 -1
- package/lib/utils/ng-compiler-cli.js +0 -18
- package/lib/utils/ng-compiler-cli.js.map +0 -1
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.version = void 0;
|
|
4
4
|
const rollup_1 = require("rollup");
|
|
5
5
|
const typescript_1 = require("typescript");
|
|
6
|
+
const load_esm_1 = require("../utils/load-esm");
|
|
6
7
|
const log_1 = require("../utils/log");
|
|
7
|
-
const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
8
8
|
/**
|
|
9
9
|
* Prints version information.
|
|
10
10
|
*
|
|
@@ -12,7 +12,7 @@ const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
|
12
12
|
*/
|
|
13
13
|
const version = async () => {
|
|
14
14
|
(0, log_1.msg)(`ng-packagr: ` + require('../../package.json').version);
|
|
15
|
-
(0, log_1.msg)(`@angular/compiler: ` + (await (0,
|
|
15
|
+
(0, log_1.msg)(`@angular/compiler: ` + (await (0, load_esm_1.ngCompilerCli)()).VERSION.full);
|
|
16
16
|
(0, log_1.msg)(`rollup: ` + rollup_1.VERSION);
|
|
17
17
|
(0, log_1.msg)(`typescript: ` + typescript_1.version);
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../../src/lib/commands/version.command.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AACnD,2CAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../../src/lib/commands/version.command.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AACnD,2CAAmD;AACnD,gDAAkD;AAClD,sCAAmC;AAGnC;;;;GAIG;AACI,MAAM,OAAO,GAAgC,KAAK,IAAI,EAAE;IAC7D,IAAA,SAAG,EAAC,yBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,CAAC;IACvE,IAAA,SAAG,EAAC,yBAAyB,GAAG,CAAC,MAAM,IAAA,wBAAa,GAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,IAAA,SAAG,EAAC,yBAAyB,GAAG,gBAAc,CAAC,CAAC;IAChD,IAAA,SAAG,EAAC,yBAAyB,GAAG,oBAAU,CAAC,CAAC;AAC9C,CAAC,CAAC;AALW,QAAA,OAAO,WAKlB","sourcesContent":["import { VERSION as ROLLUP_VERSION } from 'rollup';\nimport { version as TS_VERSION } from 'typescript';\nimport { ngCompilerCli } from '../utils/load-esm';\nimport { msg } from '../utils/log';\nimport { Command } from './command';\n\n/**\n * Prints version information.\n *\n * @stable\n */\nexport const version: Command<any, Promise<void>> = async () => {\n msg(`ng-packagr: ` + require('../../package.json').version);\n msg(`@angular/compiler: ` + (await ngCompilerCli()).VERSION.full);\n msg(`rollup: ` + ROLLUP_VERSION);\n msg(`typescript: ` + TS_VERSION);\n};\n"]}
|
|
@@ -31,11 +31,11 @@ const node_path_1 = require("node:path");
|
|
|
31
31
|
const typescript_1 = __importDefault(require("typescript"));
|
|
32
32
|
const nodes_1 = require("../ng-package/nodes");
|
|
33
33
|
const cache_compiler_host_1 = require("../ts/cache-compiler-host");
|
|
34
|
+
const load_esm_1 = require("../utils/load-esm");
|
|
34
35
|
const log = __importStar(require("../utils/log"));
|
|
35
|
-
const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
36
36
|
async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, options, extraOptions, stylesheetProcessor) {
|
|
37
37
|
var _a, _b;
|
|
38
|
-
const { NgtscProgram, formatDiagnostics } = await (0,
|
|
38
|
+
const { NgtscProgram, formatDiagnostics } = await (0, load_esm_1.ngCompilerCli)();
|
|
39
39
|
const { cacheDirectory, watch, cacheEnabled } = options;
|
|
40
40
|
const tsConfigOptions = { ...tsConfig.options, ...extraOptions };
|
|
41
41
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAiC;AACjC,4DAA4B;AAE5B,+CAAqG;AAGrG,mEAA4F;AAC5F,kDAAoC;AACpC,8DAAyD;AAElD,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;;IAEzC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAA,+BAAa,GAAE,CAAC;IAClE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iB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AI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;gBACrC,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;aACpF;QACH,CAAC,CAAC,EACF;YACA,QAAQ;SACT;KACF;IAED,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;QACjD,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACjC,SAAS;SACV;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;YACrE,SAAS;SACV;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACxE,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;KACzE;AACH,CAAC;AA/MD,gDA+MC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, PackageNode, isEntryPointInProgress, isPackage } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport * as log from '../utils/log';\nimport { ngCompilerCli } from '../utils/ng-compiler-cli';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await ngCompilerCli();\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(\n ...builder.getDeclarationDiagnostics(sourceFile),\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n\n // Declaration files cannot have template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(sourceFile, angularDiagnostics);\n }\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(errorDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (\n builder.emitNextAffectedFile((fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (fileName.endsWith('.tsbuildinfo')) {\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n })\n ) {\n // empty\n }\n }\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);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AAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;KACzE;AACH,CAAC;AA/MD,gDA+MC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, PackageNode, isEntryPointInProgress, isPackage } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport { ngCompilerCli } from '../utils/load-esm';\nimport * as log from '../utils/log';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await ngCompilerCli();\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(\n ...builder.getDeclarationDiagnostics(sourceFile),\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n\n // Declaration files cannot have template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(sourceFile, angularDiagnostics);\n }\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(errorDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (\n builder.emitNextAffectedFile((fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (fileName.endsWith('.tsbuildinfo')) {\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n })\n ) {\n // empty\n }\n }\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n}\n"]}
|
|
@@ -42,8 +42,11 @@ class StylesheetProcessor {
|
|
|
42
42
|
}
|
|
43
43
|
/** Destory workers in pool. */
|
|
44
44
|
destroy() {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (this.renderWorker) {
|
|
46
|
+
// Workaround piscina bug where a worker thread will be recreated after destroy to meet the minimum.
|
|
47
|
+
this.renderWorker.options.minThreads = 0;
|
|
48
|
+
void this.renderWorker.destroy();
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
51
|
createRenderWorker() {
|
|
49
52
|
if (this.renderWorker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AACxC,2BAAgC;AAChC,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B,CAAC","sourcesContent":["import browserslist from 'browserslist';\nimport { existsSync } from 'fs';\nimport { dirname, join } from 'path';\nimport Piscina from 'piscina';\nimport { colors } from '../utils/color';\n\nconst maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];\nconst maxThreads = typeof maxWorkersVariable === 'string' && maxWorkersVariable !== '' ? +maxWorkersVariable : 4;\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\nexport class StylesheetProcessor {\n private renderWorker: Piscina | undefined;\n\n constructor(\n private readonly projectBasePath: string,\n private readonly basePath: string,\n private readonly cssUrl?: CssUrl,\n private readonly includePaths?: string[],\n private readonly cacheDirectory?: string | false,\n ) {\n // By default, browserslist defaults are too inclusive\n // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522\n // We change the default query to browsers that Angular support.\n // https://angular.io/guide/browser-support\n (browserslist.defaults as string[]) = [\n 'last 2 Chrome versions',\n 'last 1 Firefox version',\n 'last 2 Edge major versions',\n 'last 2 Safari major versions',\n 'last 2 iOS major versions',\n 'Firefox ESR',\n ];\n }\n\n async process({ filePath, content }: { filePath: string; content: string }): Promise<string> {\n this.createRenderWorker();\n\n return this.renderWorker.run({ content, filePath });\n }\n\n /** Destory workers in pool. */\n destroy(): void {\n if (this.renderWorker) {\n // Workaround piscina bug where a worker thread will be recreated after destroy to meet the minimum.\n this.renderWorker.options.minThreads = 0;\n\n void this.renderWorker.destroy();\n }\n }\n\n private createRenderWorker(): void {\n if (this.renderWorker) {\n return;\n }\n\n const styleIncludePaths = [...this.includePaths];\n let prevDir = null;\n let currentDir = this.basePath;\n\n while (currentDir !== prevDir) {\n const p = join(currentDir, 'node_modules');\n if (existsSync(p)) {\n styleIncludePaths.push(p);\n }\n\n prevDir = currentDir;\n currentDir = dirname(prevDir);\n }\n\n const browserslistData = browserslist(undefined, { path: this.basePath });\n\n this.renderWorker = new Piscina({\n filename: require.resolve('./stylesheet-processor-worker'),\n maxThreads,\n env: {\n ...process.env,\n FORCE_COLOR: '' + colors.enabled,\n },\n workerData: {\n tailwindConfigPath: getTailwindConfigPath(this.projectBasePath),\n projectBasePath: this.projectBasePath,\n browserslistData,\n targets: transformSupportedBrowsersToTargets(browserslistData),\n cacheDirectory: this.cacheDirectory,\n cssUrl: this.cssUrl,\n styleIncludePaths,\n },\n });\n }\n}\n\nfunction transformSupportedBrowsersToTargets(supportedBrowsers: string[]): string[] {\n const transformed: string[] = [];\n\n // https://esbuild.github.io/api/#target\n const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);\n\n for (const browser of supportedBrowsers) {\n let [browserName, version] = browser.split(' ');\n\n // browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`\n if (browserName === 'ios_saf') {\n browserName = 'ios';\n }\n\n // browserslist uses ranges `15.2-15.3` versions but only the lowest is required\n // to perform minimum supported feature checks. esbuild also expects a single version.\n [version] = version.split('-');\n\n if (esBuildSupportedBrowsers.has(browserName)) {\n if (browserName === 'safari' && version === 'tp') {\n // esbuild only supports numeric versions so `TP` is converted to a high number (999) since\n // a Technology Preview (TP) of Safari is assumed to support all currently known features.\n version = '999';\n }\n\n transformed.push(browserName + version);\n }\n }\n\n return transformed.length ? transformed : undefined;\n}\n\n/** The list of valid config files can be found https://github.com/tailwindlabs/tailwindcss/blob/ba5454543e74a6d702ce11b410d27672c2ee4b3f/src/util/resolveConfigPath.js#L4-L9*/\nconst tailwindConfigFiles = [\n './tailwind.config.js',\n './tailwind.config.cjs',\n './tailwind.config.mjs',\n './tailwind.config.ts',\n];\n\nfunction getTailwindConfigPath(projectRoot: string): string | undefined {\n // A configuration file can exist in the project or workspace root\n for (const configFile of tailwindConfigFiles) {\n // Irrespective of the name project level configuration should always take precedence.\n const fullPath = join(projectRoot, configFile);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n"]}
|
package/lib/ts/tsconfig.js
CHANGED
|
@@ -29,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.setDependenciesTsConfigPaths = exports.initializeTsConfig = exports.defaultTsConfigPath = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const typescript_1 = __importDefault(require("typescript"));
|
|
32
|
+
const load_esm_1 = require("../utils/load-esm");
|
|
32
33
|
const log = __importStar(require("../utils/log"));
|
|
33
|
-
const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
34
34
|
exports.defaultTsConfigPath = path.join(__dirname, 'conf', 'tsconfig.ngc.json');
|
|
35
35
|
/**
|
|
36
36
|
* Reads the default TypeScript configuration.
|
|
@@ -51,7 +51,7 @@ async function readDefaultTsConfig(fileName = exports.defaultTsConfigPath) {
|
|
|
51
51
|
flatModuleId: 'AUTOGENERATED',
|
|
52
52
|
flatModuleOutFile: 'AUTOGENERATED',
|
|
53
53
|
};
|
|
54
|
-
const { readConfiguration } = await (0,
|
|
54
|
+
const { readConfiguration } = await (0, load_esm_1.ngCompilerCli)();
|
|
55
55
|
return readConfiguration(fileName, extraOptions);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -77,7 +77,7 @@ async function createDefaultTsConfig(values) {
|
|
|
77
77
|
async function initializeTsConfig(defaultTsConfig, entryPoints) {
|
|
78
78
|
const defaultTsConfigParsed = await createDefaultTsConfig(defaultTsConfig);
|
|
79
79
|
if (defaultTsConfigParsed.errors.length > 0) {
|
|
80
|
-
const { formatDiagnostics } = await (0,
|
|
80
|
+
const { formatDiagnostics } = await (0, load_esm_1.ngCompilerCli)();
|
|
81
81
|
throw new Error(formatDiagnostics(defaultTsConfigParsed.errors));
|
|
82
82
|
}
|
|
83
83
|
entryPoints.forEach(currentEntryPoint => {
|
package/lib/ts/tsconfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IAE5D,sCAAsC;IACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE;QAC3B,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;KAC7B;IAED,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;QAC7B,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;YACrC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;SAC/C;aAAM;YACL,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;SACzD;KACF;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"]}
|
package/lib/utils/cache.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function generateKey(...valuesToConsider: string[]): Promise<string>;
|
|
2
|
-
export declare function readCacheEntry(cachePath: string, key: string): Promise<any
|
|
2
|
+
export declare function readCacheEntry(cachePath: string, key: string): Promise<any>;
|
|
3
3
|
export declare function saveCacheEntry(cachePath: string, key: string, content: string): Promise<void>;
|
package/lib/utils/cache.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.saveCacheEntry = exports.readCacheEntry = exports.generateKey = void 0;
|
|
|
27
27
|
const cacache = __importStar(require("cacache"));
|
|
28
28
|
const crypto_1 = require("crypto");
|
|
29
29
|
const fs_1 = require("../utils/fs");
|
|
30
|
-
const
|
|
30
|
+
const load_esm_1 = require("./load-esm");
|
|
31
31
|
let ngPackagrVersion;
|
|
32
32
|
try {
|
|
33
33
|
ngPackagrVersion = require('../../package.json').version;
|
|
@@ -39,7 +39,7 @@ catch {
|
|
|
39
39
|
let compilerCliVersion;
|
|
40
40
|
async function generateKey(...valuesToConsider) {
|
|
41
41
|
if (compilerCliVersion === undefined) {
|
|
42
|
-
compilerCliVersion = (await (0,
|
|
42
|
+
compilerCliVersion = (await (0, load_esm_1.ngCompilerCli)()).VERSION.full;
|
|
43
43
|
}
|
|
44
44
|
return (0, crypto_1.createHash)('sha1')
|
|
45
45
|
.update(ngPackagrVersion)
|
package/lib/utils/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/lib/utils/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,mCAAoC;AACpC,oCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/lib/utils/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,mCAAoC;AACpC,oCAAuC;AACvC,yCAA2C;AAE3C,IAAI,gBAAoC,CAAC;AACzC,IAAI;IACF,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;CAC1D;AAAC,MAAM;IACN,WAAW;IACX,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;CAC7D;AAED,IAAI,kBAAsC,CAAC;AAEpC,KAAK,UAAU,WAAW,CAAC,GAAG,gBAA0B;IAC7D,IAAI,kBAAkB,KAAK,SAAS,EAAE;QACpC,kBAAkB,GAAG,CAAC,MAAM,IAAA,wBAAa,GAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;KAC3D;IAED,OAAO,IAAA,mBAAU,EAAC,MAAM,CAAC;SACtB,MAAM,CAAC,gBAAgB,CAAC;SACxB,MAAM,CAAC,kBAAkB,CAAC;SAC1B,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAVD,kCAUC;AAEM,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,GAAW;IACjE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACrD,IAAI,KAAK,EAAE;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,aAAQ,EAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;KACvD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,wCAOC;AAEM,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,GAAW,EAAE,OAAe;IAClF,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAFD,wCAEC","sourcesContent":["import * as cacache from 'cacache';\nimport { createHash } from 'crypto';\nimport { readFile } from '../utils/fs';\nimport { ngCompilerCli } from './load-esm';\n\nlet ngPackagrVersion: string | undefined;\ntry {\n ngPackagrVersion = require('../../package.json').version;\n} catch {\n // dev path\n ngPackagrVersion = require('../../../package.json').version;\n}\n\nlet compilerCliVersion: string | undefined;\n\nexport async function generateKey(...valuesToConsider: string[]): Promise<string> {\n if (compilerCliVersion === undefined) {\n compilerCliVersion = (await ngCompilerCli()).VERSION.full;\n }\n\n return createHash('sha1')\n .update(ngPackagrVersion)\n .update(compilerCliVersion)\n .update(valuesToConsider.join(':'))\n .digest('hex');\n}\n\nexport async function readCacheEntry(cachePath: string, key: string): Promise<any> {\n const entry = await cacache.get.info(cachePath, key);\n if (entry) {\n return JSON.parse(await readFile(entry.path, 'utf8'));\n }\n\n return undefined;\n}\n\nexport async function saveCacheEntry(cachePath: string, key: string, content: string): Promise<void> {\n await cacache.put(cachePath, key, content);\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function ngCompilerCli(): Promise<typeof import('@angular/compiler-cli')>;
|
|
3
|
+
/**
|
|
4
|
+
* This uses a dynamic import to load a module which may be ESM.
|
|
5
|
+
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
6
|
+
* will currently, unconditionally downlevel dynamic import into a require call.
|
|
7
|
+
* require calls cannot load ESM code and will result in a runtime error. To workaround
|
|
8
|
+
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
9
|
+
* Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
10
|
+
* be dropped.
|
|
11
|
+
*
|
|
12
|
+
* @param modulePath The path of the module to load.
|
|
13
|
+
* @returns A Promise that resolves to the dynamically imported module.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadEsmModule = exports.ngCompilerCli = void 0;
|
|
4
|
+
function ngCompilerCli() {
|
|
5
|
+
return loadEsmModule('@angular/compiler-cli');
|
|
6
|
+
}
|
|
7
|
+
exports.ngCompilerCli = ngCompilerCli;
|
|
8
|
+
/**
|
|
9
|
+
* Lazily compiled dynamic import loader function.
|
|
10
|
+
*/
|
|
11
|
+
let load;
|
|
12
|
+
/**
|
|
13
|
+
* This uses a dynamic import to load a module which may be ESM.
|
|
14
|
+
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
15
|
+
* will currently, unconditionally downlevel dynamic import into a require call.
|
|
16
|
+
* require calls cannot load ESM code and will result in a runtime error. To workaround
|
|
17
|
+
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
18
|
+
* Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
19
|
+
* be dropped.
|
|
20
|
+
*
|
|
21
|
+
* @param modulePath The path of the module to load.
|
|
22
|
+
* @returns A Promise that resolves to the dynamically imported module.
|
|
23
|
+
*/
|
|
24
|
+
function loadEsmModule(modulePath) {
|
|
25
|
+
load !== null && load !== void 0 ? load : (load = new Function('modulePath', `return import(modulePath);`));
|
|
26
|
+
return load(modulePath);
|
|
27
|
+
}
|
|
28
|
+
exports.loadEsmModule = loadEsmModule;
|
|
29
|
+
//# sourceMappingURL=load-esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-esm.js","sourceRoot":"","sources":["../../../src/lib/utils/load-esm.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa;IAC3B,OAAO,aAAa,CAAC,uBAAuB,CAAC,CAAC;AAChD,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,IAAI,IAA+D,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAI,UAAwB;IACvD,IAAI,aAAJ,IAAI,cAAJ,IAAI,IAAJ,IAAI,GAAK,IAAI,QAAQ,CAAC,YAAY,EAAE,4BAA4B,CAAoC,EAAC;IAErG,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC;AAJD,sCAIC","sourcesContent":["export function ngCompilerCli(): Promise<typeof import('@angular/compiler-cli')> {\n return loadEsmModule('@angular/compiler-cli');\n}\n\n/**\n * Lazily compiled dynamic import loader function.\n */\nlet load: (<T>(modulePath: string | URL) => Promise<T>) | undefined;\n\n/**\n * This uses a dynamic import to load a module which may be ESM.\n * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript\n * will currently, unconditionally downlevel dynamic import into a require call.\n * require calls cannot load ESM code and will result in a runtime error. To workaround\n * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.\n * Once TypeScript provides support for keeping the dynamic import this workaround can\n * be dropped.\n *\n * @param modulePath The path of the module to load.\n * @returns A Promise that resolves to the dynamically imported module.\n */\nexport function loadEsmModule<T>(modulePath: string | URL): Promise<T> {\n load ??= new Function('modulePath', `return import(modulePath);`) as Exclude<typeof load, undefined>;\n\n return load(modulePath);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "17.0.0
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scss"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": "^
|
|
17
|
+
"node": "^18.13.0 || >=20.9.0"
|
|
18
18
|
},
|
|
19
19
|
"author": "David Herges <david@spektrakel.de>",
|
|
20
20
|
"license": "MIT",
|
|
@@ -32,30 +32,30 @@
|
|
|
32
32
|
"main": "./public_api.js",
|
|
33
33
|
"typings": "./public_api.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rollup/plugin-json": "^6.0.
|
|
36
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
37
|
-
"ajv": "^8.
|
|
35
|
+
"@rollup/plugin-json": "^6.0.1",
|
|
36
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
37
|
+
"ajv": "^8.12.0",
|
|
38
38
|
"ansi-colors": "^4.1.3",
|
|
39
|
-
"autoprefixer": "^10.4.
|
|
40
|
-
"browserslist": "^4.
|
|
39
|
+
"autoprefixer": "^10.4.16",
|
|
40
|
+
"browserslist": "^4.22.1",
|
|
41
41
|
"cacache": "^18.0.0",
|
|
42
42
|
"chokidar": "^3.5.3",
|
|
43
|
-
"commander": "^11.
|
|
43
|
+
"commander": "^11.1.0",
|
|
44
44
|
"convert-source-map": "^2.0.0",
|
|
45
45
|
"dependency-graph": "^0.11.0",
|
|
46
|
-
"esbuild-wasm": "^0.19.
|
|
47
|
-
"fast-glob": "^3.
|
|
46
|
+
"esbuild-wasm": "^0.19.5",
|
|
47
|
+
"fast-glob": "^3.3.1",
|
|
48
48
|
"find-cache-dir": "^3.3.2",
|
|
49
49
|
"injection-js": "^2.4.0",
|
|
50
50
|
"jsonc-parser": "^3.2.0",
|
|
51
|
-
"less": "^4.
|
|
51
|
+
"less": "^4.2.0",
|
|
52
52
|
"ora": "^5.1.0",
|
|
53
|
-
"piscina": "^4.
|
|
54
|
-
"postcss": "^8.4.
|
|
53
|
+
"piscina": "^4.1.0",
|
|
54
|
+
"postcss": "^8.4.31",
|
|
55
55
|
"postcss-url": "^10.1.3",
|
|
56
|
-
"rollup": "^
|
|
57
|
-
"rxjs": "^7.
|
|
58
|
-
"sass": "^1.
|
|
56
|
+
"rollup": "^4.2.0",
|
|
57
|
+
"rxjs": "^7.8.1",
|
|
58
|
+
"sass": "^1.69.5"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
61
|
"esbuild": "^0.19.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ngCompilerCli(): Promise<typeof import('@angular/compiler-cli')>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ngCompilerCli = void 0;
|
|
4
|
-
async function ngCompilerCli() {
|
|
5
|
-
// This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.
|
|
6
|
-
// CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
7
|
-
// will currently, unconditionally downlevel dynamic import into a require call.
|
|
8
|
-
// require calls cannot load ESM code and will result in a runtime error. To workaround
|
|
9
|
-
// this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
10
|
-
// Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
11
|
-
// be dropped.
|
|
12
|
-
const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
|
|
13
|
-
// If it is not ESM then the functions needed will be stored in the `default` property.
|
|
14
|
-
// This conditional can be removed when `@angular/compiler-cli` is ESM only.
|
|
15
|
-
return compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default;
|
|
16
|
-
}
|
|
17
|
-
exports.ngCompilerCli = ngCompilerCli;
|
|
18
|
-
//# sourceMappingURL=ng-compiler-cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ng-compiler-cli.js","sourceRoot":"","sources":["../../../src/lib/utils/ng-compiler-cli.ts"],"names":[],"mappings":";;;AAAO,KAAK,UAAU,aAAa;IACjC,+EAA+E;IAC/E,kFAAkF;IAClF,gFAAgF;IAChF,uFAAuF;IACvF,+FAA+F;IAC/F,sFAAsF;IACtF,cAAc;IACd,MAAM,iBAAiB,GAAG,MAAM,IAAI,QAAQ,CAAC,yCAAyC,CAAC,EAAE,CAAC;IAE1F,uFAAuF;IACvF,4EAA4E;IAC5E,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;AAC7F,CAAC;AAbD,sCAaC","sourcesContent":["export async function ngCompilerCli(): Promise<typeof import('@angular/compiler-cli')> {\n // This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.\n // CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript\n // will currently, unconditionally downlevel dynamic import into a require call.\n // require calls cannot load ESM code and will result in a runtime error. To workaround\n // this, a Function constructor is used to prevent TypeScript from changing the dynamic import.\n // Once TypeScript provides support for keeping the dynamic import this workaround can\n // be dropped.\n const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();\n\n // If it is not ESM then the functions needed will be stored in the `default` property.\n // This conditional can be removed when `@angular/compiler-cli` is ESM only.\n return compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default;\n}\n"]}
|