ng-packagr 12.1.0 → 12.2.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/cli/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const program = require("commander");
4
+ const commander_1 = require("commander");
5
5
  const path = require("path");
6
6
  const log_1 = require("../lib/utils/log");
7
7
  const public_api_1 = require("../public_api");
@@ -9,19 +9,19 @@ const DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');
9
9
  function parseProjectPath(parsed) {
10
10
  return parsed || DEFAULT_PROJECT_PATH;
11
11
  }
12
- program
12
+ commander_1.program
13
13
  .name('ng-packagr')
14
14
  .storeOptionsAsProperties(false)
15
15
  .option('-v, --version', 'Prints version info')
16
16
  .option('-w, --watch', 'Watch for file changes')
17
17
  .option('-p, --project [path]', "Path to the 'ng-package.json' or 'package.json' file.", parseProjectPath, DEFAULT_PROJECT_PATH)
18
18
  .option('-c, --config [config]', 'Path to a tsconfig file.', (value) => value ? path.resolve(value) : undefined);
19
- program.on('option:version', () => {
19
+ commander_1.program.on('option:version', () => {
20
20
  public_api_1.version();
21
21
  process.exit(0);
22
22
  });
23
- program.parse(process.argv);
24
- const { config, project, watch } = program.opts();
23
+ commander_1.program.parse(process.argv);
24
+ const { config, project, watch } = commander_1.program.opts();
25
25
  public_api_1.execute(public_api_1.build, { config, project, watch: !!watch }).catch(err => {
26
26
  log_1.error(err.message);
27
27
  process.exit(1);
package/cli/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";;;AAEA,qCAAqC;AACrC,6BAA6B;AAC7B,0CAAyC;AACzC,8CAAwD;AAExD,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAE5E,SAAS,gBAAgB,CAAC,MAAc;IACtC,OAAO,MAAM,IAAI,oBAAoB,CAAC;AACxC,CAAC;AAED,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,wBAAwB,CAAC,KAAK,CAAC;KAC/B,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,aAAa,EAAE,wBAAwB,CAAC;KAC/C,MAAM,CACL,sBAAsB,EACtB,uDAAuD,EACvD,gBAAgB,EAChB,oBAAoB,CACrB;KACA,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,EAAE,CAAC,KAAyB,EAAE,EAAE,CACzF,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACxC,CAAC;AAEJ,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAChC,oBAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAClD,oBAAO,CAAC,kBAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC9D,WAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport * as program from 'commander';\nimport * as path from 'path';\nimport { error } from '../lib/utils/log';\nimport { build, execute, version } from '../public_api';\n\nconst DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');\n\nfunction parseProjectPath(parsed: string): string {\n return parsed || DEFAULT_PROJECT_PATH;\n}\n\nprogram\n .name('ng-packagr')\n .storeOptionsAsProperties(false)\n .option('-v, --version', 'Prints version info')\n .option('-w, --watch', 'Watch for file changes')\n .option(\n '-p, --project [path]',\n \"Path to the 'ng-package.json' or 'package.json' file.\",\n parseProjectPath,\n DEFAULT_PROJECT_PATH,\n )\n .option('-c, --config [config]', 'Path to a tsconfig file.', (value: string | undefined) =>\n value ? path.resolve(value) : undefined,\n );\n\nprogram.on('option:version', () => {\n version();\n process.exit(0);\n});\n\nprogram.parse(process.argv);\n\nconst { config, project, watch } = program.opts();\nexecute(build, { config, project, watch: !!watch }).catch(err => {\n error(err.message);\n process.exit(1);\n});\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,6BAA6B;AAC7B,0CAAyC;AACzC,8CAAwD;AAExD,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAE5E,SAAS,gBAAgB,CAAC,MAAc;IACtC,OAAO,MAAM,IAAI,oBAAoB,CAAC;AACxC,CAAC;AAED,mBAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,wBAAwB,CAAC,KAAK,CAAC;KAC/B,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,aAAa,EAAE,wBAAwB,CAAC;KAC/C,MAAM,CACL,sBAAsB,EACtB,uDAAuD,EACvD,gBAAgB,EAChB,oBAAoB,CACrB;KACA,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,EAAE,CAAC,KAAyB,EAAE,EAAE,CACzF,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACxC,CAAC;AAEJ,mBAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAChC,oBAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAC;AAClD,oBAAO,CAAC,kBAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC9D,WAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { program } from 'commander';\nimport * as path from 'path';\nimport { error } from '../lib/utils/log';\nimport { build, execute, version } from '../public_api';\n\nconst DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');\n\nfunction parseProjectPath(parsed: string): string {\n return parsed || DEFAULT_PROJECT_PATH;\n}\n\nprogram\n .name('ng-packagr')\n .storeOptionsAsProperties(false)\n .option('-v, --version', 'Prints version info')\n .option('-w, --watch', 'Watch for file changes')\n .option(\n '-p, --project [path]',\n \"Path to the 'ng-package.json' or 'package.json' file.\",\n parseProjectPath,\n DEFAULT_PROJECT_PATH,\n )\n .option('-c, --config [config]', 'Path to a tsconfig file.', (value: string | undefined) =>\n value ? path.resolve(value) : undefined,\n );\n\nprogram.on('option:version', () => {\n version();\n process.exit(0);\n});\n\nprogram.parse(process.argv);\n\nconst { config, project, watch } = program.opts();\nexecute(build, { config, project, watch: !!watch }).catch(err => {\n error(err.message);\n process.exit(1);\n});\n"]}
@@ -63,19 +63,19 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
63
63
  affectedFiles.add(result.affected);
64
64
  }
65
65
  }
66
- // Collect non-semantic diagnostics
66
+ // Collect program level diagnostics
67
67
  const allDiagnostics = [
68
68
  ...angularCompiler.getOptionDiagnostics(),
69
69
  ...builder.getOptionsDiagnostics(),
70
70
  ...builder.getGlobalDiagnostics(),
71
- ...builder.getSyntacticDiagnostics(),
72
71
  ];
73
72
  // Required to support asynchronous resource loading
74
73
  // Must be done before creating transformers or getting template diagnostics
75
74
  await angularCompiler.analyzeAsync();
75
+ // Collect source file specific diagnostics
76
76
  for (const sourceFile of builder.getSourceFiles()) {
77
77
  if (!ignoreForDiagnostics.has(sourceFile)) {
78
- allDiagnostics.push(...builder.getSemanticDiagnostics(sourceFile));
78
+ allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
79
79
  }
80
80
  if (sourceFile.isDeclarationFile) {
81
81
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ivy/compile-source-files.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,uEAA4E;AAC5E,qEAAuE;AACvE,iCAAiC;AACjC,oCAAoC;AAEpC,+DAAwF;AAExF,+CAA6E;AAE7E,qFAA+E;AAExE,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAAgC,EAChC,qBAA+C,EAC/C,YAA0C,EAC1C,mBAA6C,EAC7C,aAA6B,EAC7B,KAAe;IAEf,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAEvC,MAAM,eAAe,GAAuB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IACrF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAC,CAAC;IAExE,MAAM,cAAc,GAAG,wDAAyB,CAC9C,uCAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,q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,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAClC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;aACzE;SACF;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACH,CAAC;AAjJD,gDAiJC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport { OptimizeFor } from '@angular/compiler-cli/src/ngtsc/typecheck/api';\nimport { NgtscProgram } from '@angular/compiler-cli/src/ngtsc/program';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport * as ivy from '../ivy';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from './cache-compiler-host';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from '../ngc/ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n extraOptions?: Partial<ng.CompilerOptions>,\n stylesheetProcessor?: ivy.StylesheetProcessor,\n ngccProcessor?: NgccProcessor,\n watch?: boolean,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n\n const tsCompilerHost = ngccTransformCompilerHost(\n cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor),\n tsConfigOptions,\n ngccProcessor,\n moduleResolutionCache,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\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) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n cache.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 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\n // Collect non-semantic diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ...builder.getSyntacticDiagnostics(),\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 for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForDiagnostics.has(sourceFile)) {\n allDiagnostics.push(...builder.getSemanticDiagnostics(sourceFile));\n }\n\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Collect sources that are required to be emitted\n if (!ignoreForEmit.has(sourceFile) && !angularCompiler.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, OptimizeFor.WholeProgram);\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);\n }\n\n // if we have an error we don't want to transpile.\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode === 0) {\n if (formattedDiagnostics.length) {\n log.msg(formattedDiagnostics);\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForEmit.has(sourceFile)) {\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n }\n }\n } else {\n throw new Error(formattedDiagnostics);\n }\n}\n"]}
1
+ {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ivy/compile-source-files.ts"],"names":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eAAe,CAAC,qBAAqB,CAAC,YAAY,EAAE,iBAAW,CAAC,YAAY,CAAC,CAAC;QAEzG,cAAc,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC;QAC3C,eAAe,CAAC,wBAAwB,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;KAC5E;IAED,kDAAkD;IAClD,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACvD,MAAM,oBAAoB,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClE,IAAI,QAAQ,KAAK,CAAC,EAAE;QAClB,IAAI,oBAAoB,CAAC,MAAM,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;SAC/B;QAED,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC;QAChE,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;YACjD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAClC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;aACzE;SACF;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACH,CAAC;AApJD,gDAoJC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport { OptimizeFor } from '@angular/compiler-cli/src/ngtsc/typecheck/api';\nimport { NgtscProgram } from '@angular/compiler-cli/src/ngtsc/program';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport * as ivy from '../ivy';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from './cache-compiler-host';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from '../ngc/ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n extraOptions?: Partial<ng.CompilerOptions>,\n stylesheetProcessor?: ivy.StylesheetProcessor,\n ngccProcessor?: NgccProcessor,\n watch?: boolean,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n\n const tsCompilerHost = ngccTransformCompilerHost(\n cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor),\n tsConfigOptions,\n ngccProcessor,\n moduleResolutionCache,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\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) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n cache.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 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\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 allDiagnostics.push(\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n }\n\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Collect sources that are required to be emitted\n if (!ignoreForEmit.has(sourceFile) && !angularCompiler.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, OptimizeFor.WholeProgram);\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);\n }\n\n // if we have an error we don't want to transpile.\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode === 0) {\n if (formattedDiagnostics.length) {\n log.msg(formattedDiagnostics);\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForEmit.has(sourceFile)) {\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n }\n }\n } else {\n throw new Error(formattedDiagnostics);\n }\n}\n"]}
@@ -7,7 +7,7 @@ const os_1 = require("os");
7
7
  const cacache = require("cacache");
8
8
  const postcss_1 = require("postcss");
9
9
  const postcssUrl = require("postcss-url");
10
- const cssnano = require("cssnano");
10
+ const esbuild_1 = require("esbuild");
11
11
  const postcssPresetEnv = require("postcss-preset-env");
12
12
  const log = require("../../utils/log");
13
13
  const fs_1 = require("../../utils/fs");
@@ -66,13 +66,21 @@ class StylesheetProcessor {
66
66
  to: filePath.replace(path_1.extname(filePath), '.css'),
67
67
  });
68
68
  const warnings = result.warnings().map(w => w.toString());
69
+ const { code, warnings: esBuildWarnings } = await esbuild_1.transform(result.css, {
70
+ loader: 'css',
71
+ minify: true,
72
+ sourcefile: filePath,
73
+ });
74
+ if (esBuildWarnings.length > 0) {
75
+ warnings.push(...(await esbuild_1.formatMessages(esBuildWarnings, { kind: 'warning' })));
76
+ }
69
77
  // Add to cache
70
78
  await cacache.put(cachePath, key, JSON.stringify({
71
- css: result.css,
79
+ css: code,
72
80
  warnings,
73
81
  }));
74
82
  warnings.forEach(msg => log.warn(msg));
75
- return result.css;
83
+ return code;
76
84
  }
77
85
  createPostCssPlugins() {
78
86
  const postCssPlugins = [];
@@ -83,18 +91,6 @@ class StylesheetProcessor {
83
91
  browsers: this.browserslistData,
84
92
  autoprefixer: true,
85
93
  stage: 3,
86
- }), cssnano({
87
- preset: [
88
- 'default',
89
- {
90
- // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
91
- svgo: false,
92
- // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
93
- calc: false,
94
- // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
95
- cssDeclarationSorter: false,
96
- },
97
- ],
98
94
  }));
99
95
  return postcss_1.default(postCssPlugins);
100
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../../src/lib/ivy/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,qDAAqD;AACrD,2BAA4B;AAC5B,mCAAmC;AACnC,qCAA8B;AAC9B,0CAA0C;AAC1C,mCAAmC;AACnC,uDAAuD;AACvD,uCAAuC;AACvC,uCAA0C;AAC1C,mCAAoC;AACpC,+BAA+B;AAE/B,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB;AAQD,MAAM,SAAS,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,WAAM,EAAE,CAAC;AAChF,IAAI,gBAAoC,CAAC;AACzC,IAAI;IACF,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;CAC7D;AAAC,MAAM;IACN,WAAW;IACX,gBAAgB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC,OAAO,CAAC;CAChE;AAED,MAAa,mBAAmB;IAI9B,YACmB,QAAgB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CacheDirectory from 'find-cache-dir';\nimport { tmpdir } from 'os';\nimport * as cacache from 'cacache';\nimport postcss from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport * as cssnano from 'cssnano';\nimport * as postcssPresetEnv from 'postcss-preset-env';\nimport * as log from '../../utils/log';\nimport { readFile } from '../../utils/fs';\nimport { createHash } from 'crypto';\nimport { extname } from 'path';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\nexport interface Result {\n css: string;\n warnings: string[];\n error?: string;\n}\n\nconst cachePath = findCacheDirectory({ name: 'ng-packagr-styles' }) || tmpdir();\nlet ngPackagrVersion: string | undefined;\ntry {\n ngPackagrVersion = require('../../../package.json').version;\n} catch {\n // dev path\n ngPackagrVersion = require('../../../../package.json').version;\n}\n\nexport class StylesheetProcessor {\n private browserslistData: string[];\n private postCssProcessor: ReturnType<typeof postcss>;\n\n constructor(\n private readonly basePath: string,\n private readonly cssUrl?: CssUrl,\n private readonly styleIncludePaths?: string[],\n ) {\n log.debug(`determine browserslist for ${this.basePath}`);\n this.browserslistData = browserslist(undefined, { path: this.basePath });\n this.postCssProcessor = this.createPostCssPlugins();\n }\n\n async process(filePath: string): Promise<string> {\n const content = await readFile(filePath, 'utf8');\n let key: string | undefined;\n\n if (!content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = generateKey(content, this.browserslistData);\n const result = await readCacheEntry(cachePath, key);\n if (result) {\n result.warnings.forEach(msg => log.warn(msg));\n return result.css;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n const renderedCss = await this.renderCss(filePath, content);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = generateKey(renderedCss, this.browserslistData);\n }\n\n const cachedResult = await readCacheEntry(cachePath, key);\n if (cachedResult) {\n cachedResult.warnings.forEach(msg => log.warn(msg));\n return cachedResult.css;\n }\n\n // Render postcss (autoprefixing and friends)\n const result = await this.postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(extname(filePath), '.css'),\n });\n\n const warnings = result.warnings().map(w => w.toString());\n // Add to cache\n await cacache.put(\n cachePath,\n key,\n JSON.stringify({\n css: result.css,\n warnings,\n }),\n );\n\n warnings.forEach(msg => log.warn(msg));\n return result.css;\n }\n\n private createPostCssPlugins(): ReturnType<typeof postcss> {\n const postCssPlugins = [];\n if (this.cssUrl !== CssUrl.none) {\n postCssPlugins.push(postcssUrl({ url: this.cssUrl }));\n }\n\n postCssPlugins.push(\n postcssPresetEnv({\n browsers: this.browserslistData,\n autoprefixer: true,\n stage: 3,\n }),\n cssnano({\n preset: [\n 'default',\n {\n // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.\n svgo: false,\n // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890\n calc: false,\n // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054\n cssDeclarationSorter: false,\n },\n ],\n }),\n );\n\n return postcss(postCssPlugins);\n }\n\n private async renderCss(filePath: string, css: string): Promise<string> {\n const ext = extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n /*\n * Please be aware of the few differences in behaviour https://github.com/sass/dart-sass/blob/master/README.md#behavioral-differences-from-ruby-sass\n * By default `npm install` will install sass.\n * To use node-sass you need to use:\n * Npm:\n * `npm install node-sass --save-dev`\n * Yarn:\n * `yarn add node-sass --dev`\n */\n let sassCompiler: any | undefined;\n try {\n sassCompiler = require('node-sass'); // Check if node-sass is explicitly included.\n } catch {\n sassCompiler = await import('sass');\n }\n\n return sassCompiler\n .renderSync({\n file: filePath,\n data: css,\n indentedSyntax: '.sass' === ext,\n importer: await import('node-sass-tilde-importer'),\n includePaths: this.styleIncludePaths,\n })\n .css.toString();\n }\n case '.less': {\n const { css: content } = await (\n await import('less')\n ).render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: this.styleIncludePaths,\n });\n\n return content;\n }\n case '.styl':\n case '.stylus': {\n const stylus = await import('stylus');\n\n return (\n stylus(css)\n // add paths for resolve\n .set('paths', [this.basePath, '.', ...this.styleIncludePaths, 'node_modules'])\n // add support for resolving plugins from node_modules\n .set('filename', filePath)\n // turn on url resolver in stylus, same as flag --resolve-url\n .set('resolve url', true)\n .define('url', stylus.resolver(undefined))\n .render()\n );\n }\n case '.css':\n default:\n return css;\n }\n }\n}\n\nfunction generateKey(content: string, browserslistData: string[]): string {\n return createHash('sha1').update(ngPackagrVersion).update(content).update(browserslistData.join('')).digest('base64');\n}\n\nasync function readCacheEntry(cachePath: string, key: string): Promise<Result | undefined> {\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"]}
1
+ {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../../src/lib/ivy/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,qDAAqD;AACrD,2BAA4B;AAC5B,mCAAmC;AACnC,qCAA8B;AAC9B,0CAA0C;AAC1C,qCAAoD;AACpD,uDAAuD;AACvD,uCAAuC;AACvC,uCAA0C;AAC1C,mCAAoC;AACpC,+BAA+B;AAE/B,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB;AAQD,MAAM,SAAS,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,WAAM,EAAE,CAAC;AAChF,IAAI,gBAAoC,CAAC;AACzC,IAAI;IACF,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;CAC7D;AAAC,MAAM;IACN,WAAW;IACX,gBAAgB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC,OAAO,CAAC;CAChE;AAED,MAAa,mBAAmB;IAI9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,IAAI,CAAC,KAAK,CAAC,MAAM,aAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;KACvD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import * as browserslist from 'browserslist';\nimport * as findCacheDirectory from 'find-cache-dir';\nimport { tmpdir } from 'os';\nimport * as cacache from 'cacache';\nimport postcss from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport { transform, formatMessages } from 'esbuild';\nimport * as postcssPresetEnv from 'postcss-preset-env';\nimport * as log from '../../utils/log';\nimport { readFile } from '../../utils/fs';\nimport { createHash } from 'crypto';\nimport { extname } from 'path';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\nexport interface Result {\n css: string;\n warnings: string[];\n error?: string;\n}\n\nconst cachePath = findCacheDirectory({ name: 'ng-packagr-styles' }) || tmpdir();\nlet ngPackagrVersion: string | undefined;\ntry {\n ngPackagrVersion = require('../../../package.json').version;\n} catch {\n // dev path\n ngPackagrVersion = require('../../../../package.json').version;\n}\n\nexport class StylesheetProcessor {\n private browserslistData: string[];\n private postCssProcessor: ReturnType<typeof postcss>;\n\n constructor(\n private readonly basePath: string,\n private readonly cssUrl?: CssUrl,\n private readonly styleIncludePaths?: string[],\n ) {\n log.debug(`determine browserslist for ${this.basePath}`);\n this.browserslistData = browserslist(undefined, { path: this.basePath });\n this.postCssProcessor = this.createPostCssPlugins();\n }\n\n async process(filePath: string): Promise<string> {\n const content = await readFile(filePath, 'utf8');\n let key: string | undefined;\n\n if (!content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = generateKey(content, this.browserslistData);\n const result = await readCacheEntry(cachePath, key);\n if (result) {\n result.warnings.forEach(msg => log.warn(msg));\n return result.css;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n const renderedCss = await this.renderCss(filePath, content);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = generateKey(renderedCss, this.browserslistData);\n }\n\n const cachedResult = await readCacheEntry(cachePath, key);\n if (cachedResult) {\n cachedResult.warnings.forEach(msg => log.warn(msg));\n return cachedResult.css;\n }\n\n // Render postcss (autoprefixing and friends)\n const result = await this.postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(extname(filePath), '.css'),\n });\n\n const warnings = result.warnings().map(w => w.toString());\n const { code, warnings: esBuildWarnings } = await transform(result.css, {\n loader: 'css',\n minify: true,\n sourcefile: filePath,\n });\n\n if (esBuildWarnings.length > 0) {\n warnings.push(...(await formatMessages(esBuildWarnings, { kind: 'warning' })));\n }\n\n // Add to cache\n await cacache.put(\n cachePath,\n key,\n JSON.stringify({\n css: code,\n warnings,\n }),\n );\n\n warnings.forEach(msg => log.warn(msg));\n\n return code;\n }\n\n private createPostCssPlugins(): ReturnType<typeof postcss> {\n const postCssPlugins = [];\n if (this.cssUrl !== CssUrl.none) {\n postCssPlugins.push(postcssUrl({ url: this.cssUrl }));\n }\n\n postCssPlugins.push(\n postcssPresetEnv({\n browsers: this.browserslistData,\n autoprefixer: true,\n stage: 3,\n }),\n );\n\n return postcss(postCssPlugins);\n }\n\n private async renderCss(filePath: string, css: string): Promise<string> {\n const ext = extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n /*\n * Please be aware of the few differences in behaviour https://github.com/sass/dart-sass/blob/master/README.md#behavioral-differences-from-ruby-sass\n * By default `npm install` will install sass.\n * To use node-sass you need to use:\n * Npm:\n * `npm install node-sass --save-dev`\n * Yarn:\n * `yarn add node-sass --dev`\n */\n let sassCompiler: any | undefined;\n try {\n sassCompiler = require('node-sass'); // Check if node-sass is explicitly included.\n } catch {\n sassCompiler = await import('sass');\n }\n\n return sassCompiler\n .renderSync({\n file: filePath,\n data: css,\n indentedSyntax: '.sass' === ext,\n importer: await import('node-sass-tilde-importer'),\n includePaths: this.styleIncludePaths,\n })\n .css.toString();\n }\n case '.less': {\n const { css: content } = await (\n await import('less')\n ).render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: this.styleIncludePaths,\n });\n\n return content;\n }\n case '.styl':\n case '.stylus': {\n const stylus = await import('stylus');\n\n return (\n stylus(css)\n // add paths for resolve\n .set('paths', [this.basePath, '.', ...this.styleIncludePaths, 'node_modules'])\n // add support for resolving plugins from node_modules\n .set('filename', filePath)\n // turn on url resolver in stylus, same as flag --resolve-url\n .set('resolve url', true)\n .define('url', stylus.resolver(undefined))\n .render()\n );\n }\n case '.css':\n default:\n return css;\n }\n }\n}\n\nfunction generateKey(content: string, browserslistData: string[]): string {\n return createHash('sha1').update(ngPackagrVersion).update(content).update(browserslistData.join('')).digest('base64');\n}\n\nasync function readCacheEntry(cachePath: string, key: string): Promise<Result | undefined> {\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,2CAA8C;AAC9C,+CAAkD;AAClD,qDAAwE;AACxE,uCAAuC;AACvC,oCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,MAAM,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,WAAI;AACF,+DAA+D;AAE/D,gCAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACnC,4CAA4C;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,GAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,GAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,gCAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAC,CAGH,CAAC;AA1BS,QAAA,0BAA0B,8BA0BnC","sourcesContent":["import { pipe } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { isInProgress } from '../../graph/select';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport * as log from '../../utils/log';\nimport { byEntryPoint } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - bundleToUmd\n * - bundleToUmdMin\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, metadata, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2015 modules.\n * @param writeBundles Transformation flattening ES2015 modules to ESM2015, UMD, and minified UMD.\n * @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).\n */\nexport const entryPointTransformFactory = (\n compileTs: Transform,\n writeBundles: Transform,\n writePackage: Transform,\n): Transform =>\n pipe(\n //tap(() => log.info(`Building from sources for entry point`)),\n\n transformFromPromise(async (graph) => {\n // Peek the first entry point from the graph\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n log.msg('\\n------------------------------------------------------------------------------');\n log.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);\n log.msg('------------------------------------------------------------------------------');\n }),\n // TypeScript sources compilation\n compileTs,\n // After TypeScript: bundling and write package\n writeBundles,\n writePackage,\n transformFromPromise(async (graph) => {\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n entryPoint.state = STATE_DONE;\n }),\n\n //tap(() => log.info(`Built.`))\n );\n"]}
1
+ {"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,2CAA8C;AAC9C,+CAAkD;AAClD,qDAAwE;AACxE,uCAAuC;AACvC,oCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,MAAM,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,WAAI;AACF,+DAA+D;AAE/D,gCAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACnC,4CAA4C;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,GAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,GAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,gCAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAC,CAEH,CAAC;AAzBS,QAAA,0BAA0B,8BAyBnC","sourcesContent":["import { pipe } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { isInProgress } from '../../graph/select';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport * as log from '../../utils/log';\nimport { byEntryPoint } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - bundleToUmd\n * - bundleToUmdMin\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, metadata, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2015 modules.\n * @param writeBundles Transformation flattening ES2015 modules to ESM2015, UMD, and minified UMD.\n * @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).\n */\nexport const entryPointTransformFactory = (\n compileTs: Transform,\n writeBundles: Transform,\n writePackage: Transform,\n): Transform =>\n pipe(\n //tap(() => log.info(`Building from sources for entry point`)),\n\n transformFromPromise(async (graph) => {\n // Peek the first entry point from the graph\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n log.msg('\\n------------------------------------------------------------------------------');\n log.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);\n log.msg('------------------------------------------------------------------------------');\n }),\n // TypeScript sources compilation\n compileTs,\n // After TypeScript: bundling and write package\n writeBundles,\n writePackage,\n transformFromPromise(async (graph) => {\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n entryPoint.state = STATE_DONE;\n }),\n //tap(() => log.info(`Built.`))\n );\n"]}
@@ -5,7 +5,7 @@ const crypto_1 = require("crypto");
5
5
  const path = require("path");
6
6
  const postcss_1 = require("postcss");
7
7
  const postcssUrl = require("postcss-url");
8
- const cssnano = require("cssnano");
8
+ const esbuild_1 = require("esbuild");
9
9
  const worker_threads_1 = require("worker_threads");
10
10
  const postcssPresetEnv = require("postcss-preset-env");
11
11
  const stylesheet_processor_1 = require("./stylesheet-processor");
@@ -35,11 +35,23 @@ async function processCss({ filePath, browserslistData, cssUrl, styleIncludePath
35
35
  }
36
36
  // Render postcss (autoprefixing and friends)
37
37
  const result = await optimizeCss(filePath, renderedCss, browserslistData, cssUrl);
38
+ const warnings = result.warnings().map(w => w.toString());
39
+ const { code, warnings: esBuildWarnings } = await esbuild_1.transform(result.css, {
40
+ loader: 'css',
41
+ minify: true,
42
+ sourcefile: filePath,
43
+ });
44
+ if (esBuildWarnings.length > 0) {
45
+ warnings.push(...(await esbuild_1.formatMessages(esBuildWarnings, { kind: 'warning' })));
46
+ }
38
47
  // Add to cache
39
- await cacache.put(cachePath, key, result.css);
48
+ await cacache.put(cachePath, key, JSON.stringify({
49
+ css: code,
50
+ warnings,
51
+ }));
40
52
  return {
41
- css: result.css,
42
- warnings: result.warnings().map(w => w.toString()),
53
+ css: code,
54
+ warnings,
43
55
  };
44
56
  }
45
57
  async function renderCss(filePath, css, basePath, styleIncludePaths) {
@@ -108,18 +120,6 @@ function optimizeCss(filePath, css, browsers, cssUrl) {
108
120
  browsers,
109
121
  autoprefixer: true,
110
122
  stage: 3,
111
- }), cssnano({
112
- preset: [
113
- 'default',
114
- {
115
- // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
116
- svgo: false,
117
- // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
118
- calc: false,
119
- // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
120
- cssDeclarationSorter: false,
121
- },
122
- ],
123
123
  }));
124
124
  return postcss_1.default(postCssPlugins).process(css, {
125
125
  from: filePath,
@@ -132,10 +132,7 @@ function generateKey(content, browserslistData) {
132
132
  async function readCacheEntry(cachePath, key) {
133
133
  const entry = await cacache.get.info(cachePath, key);
134
134
  if (entry) {
135
- return {
136
- css: await fs_1.readFile(entry.path, 'utf8'),
137
- warnings: [],
138
- };
135
+ return JSON.parse(await fs_1.readFile(entry.path, 'utf8'));
139
136
  }
140
137
  return undefined;
141
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,mCAAoC;AACpC,6BAA6B;AAC7B,qCAA8C;AAC9C,0CAA0C;AAC1C,mCAAmC;AACnC,mDAA4C;AAC5C,uDAAuD;AAEvD,iEAA6E;AAC7E,oCAAuC;AAEvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAE/D,KAAK,UAAU,UAAU,CAAC,EACxB,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACK;IACd,MAAM,OAAO,GAAG,MAAM,aAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjD,IAAI,GAAuB,CAAC;IAE5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC7D,sDAAsD;QACtD,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACpD,IAAI,MAAM,EAAE;YACV,OAAO,MAAM,CAAC;SACf;KACF;IAED,mDAAmD;IACnD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,QAAQ,E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ACF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;KACjC;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KAC5C;YAAS;QACR,qCAAqC;QACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,yBAAyB;QACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;KACd;AACH,CAAC,CAAC,CAAC","sourcesContent":["import * as cacache from 'cacache';\nimport { createHash } from 'crypto';\nimport * as path from 'path';\nimport postcss, { LazyResult } from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport * as cssnano from 'cssnano';\nimport { parentPort } from 'worker_threads';\nimport * as postcssPresetEnv from 'postcss-preset-env';\n\nimport { CssUrl, WorkerOptions, WorkerResult } from './stylesheet-processor';\nimport { readFile } from '../utils/fs';\n\nconst ngPackagrVersion = require('../../package.json').version;\n\nasync function processCss({\n filePath,\n browserslistData,\n cssUrl,\n styleIncludePaths,\n basePath,\n cachePath,\n}: WorkerOptions): Promise<WorkerResult> {\n const content = await readFile(filePath, 'utf8');\n let key: string | undefined;\n\n if (!content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = generateKey(content, browserslistData);\n const result = await readCacheEntry(cachePath, key);\n if (result) {\n return result;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n const renderedCss = await renderCss(filePath, content, basePath, styleIncludePaths);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = generateKey(renderedCss, browserslistData);\n\n const cachedResult = await readCacheEntry(cachePath, key);\n if (cachedResult) {\n return cachedResult;\n }\n }\n\n // Render postcss (autoprefixing and friends)\n const result = await optimizeCss(filePath, renderedCss, browserslistData, cssUrl);\n\n // Add to cache\n await cacache.put(cachePath, key, result.css);\n\n return {\n css: result.css,\n warnings: result.warnings().map(w => w.toString()),\n };\n}\n\nasync function renderCss(\n filePath: string,\n css: string,\n basePath: string,\n styleIncludePaths?: string[],\n): Promise<string> {\n const ext = path.extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n /*\n * Please be aware of the few differences in behaviour https://github.com/sass/dart-sass/blob/master/README.md#behavioral-differences-from-ruby-sass\n * By default `npm install` will install sass.\n * To use node-sass you need to use:\n * Npm:\n * `npm install node-sass --save-dev`\n * Yarn:\n * `yarn add node-sass --dev`\n */\n let sassCompiler: any | undefined;\n try {\n sassCompiler = require('node-sass'); // Check if node-sass is explicitly included.\n } catch {\n sassCompiler = await import('sass');\n }\n\n return sassCompiler\n .renderSync({\n file: filePath,\n data: css,\n indentedSyntax: '.sass' === ext,\n importer: await import('node-sass-tilde-importer'),\n includePaths: styleIncludePaths,\n })\n .css.toString();\n }\n case '.less': {\n const { css: content } = await (await import('less')).render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: styleIncludePaths,\n });\n\n return content;\n }\n case '.styl':\n case '.stylus': {\n const stylus = await import('stylus');\n\n return (\n stylus(css)\n // add paths for resolve\n .set('paths', [basePath, '.', ...styleIncludePaths, 'node_modules'])\n // add support for resolving plugins from node_modules\n .set('filename', filePath)\n // turn on url resolver in stylus, same as flag --resolve-url\n .set('resolve url', true)\n .define('url', stylus.resolver(undefined))\n .render()\n );\n }\n case '.css':\n default:\n return css;\n }\n}\n\nfunction optimizeCss(filePath: string, css: string, browsers: string[], cssUrl?: CssUrl): LazyResult {\n const postCssPlugins = [];\n\n if (cssUrl !== CssUrl.none) {\n postCssPlugins.push(postcssUrl({ url: cssUrl }));\n }\n\n postCssPlugins.push(\n postcssPresetEnv({\n browsers,\n autoprefixer: true,\n stage: 3,\n }),\n cssnano({\n preset: [\n 'default',\n {\n // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.\n svgo: false,\n // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890\n calc: false,\n // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054\n cssDeclarationSorter: false,\n },\n ],\n }),\n );\n\n return postcss(postCssPlugins).process(css, {\n from: filePath,\n to: filePath.replace(path.extname(filePath), '.css'),\n });\n}\n\nfunction generateKey(content: string, browserslistData: string[]): string {\n return createHash('sha1').update(ngPackagrVersion).update(content).update(browserslistData.join('')).digest('base64');\n}\n\nasync function readCacheEntry(cachePath: string, key: string): Promise<WorkerResult | undefined> {\n const entry = await cacache.get.info(cachePath, key);\n if (entry) {\n return {\n css: await readFile(entry.path, 'utf8'),\n warnings: [],\n };\n }\n\n return undefined;\n}\n\nparentPort.on('message', async ({ signal, port, workerOptions }) => {\n try {\n const result = await processCss(workerOptions);\n port.postMessage({ ...result });\n } catch (error) {\n port.postMessage({ error: error.message });\n } finally {\n // Change the value of signal[0] to 1\n Atomics.add(signal, 0, 1);\n // Unlock the main thread\n Atomics.notify(signal, 0);\n port.close();\n }\n});\n"]}
1
+ {"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,mCAAoC;AACpC,6BAA6B;AAC7B,qCAA8C;AAC9C,0CAA0C;AAC1C,qCAAoD;AACpD,mDAA4C;AAC5C,uDAAuD;AAEvD,iEAA6E;AAC7E,oCAAuC;AAEvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAE/D,KAAK,UAAU,UAAU,CAAC,EACxB,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACK;IACd,MAAM,OAA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\nimport postcss, { LazyResult } from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport { formatMessages, transform } from 'esbuild';\nimport { parentPort } from 'worker_threads';\nimport * as postcssPresetEnv from 'postcss-preset-env';\n\nimport { CssUrl, WorkerOptions, WorkerResult } from './stylesheet-processor';\nimport { readFile } from '../utils/fs';\n\nconst ngPackagrVersion = require('../../package.json').version;\n\nasync function processCss({\n filePath,\n browserslistData,\n cssUrl,\n styleIncludePaths,\n basePath,\n cachePath,\n}: WorkerOptions): Promise<WorkerResult> {\n const content = await readFile(filePath, 'utf8');\n let key: string | undefined;\n\n if (!content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = generateKey(content, browserslistData);\n const result = await readCacheEntry(cachePath, key);\n if (result) {\n return result;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n const renderedCss = await renderCss(filePath, content, basePath, styleIncludePaths);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = generateKey(renderedCss, browserslistData);\n\n const cachedResult = await readCacheEntry(cachePath, key);\n if (cachedResult) {\n return cachedResult;\n }\n }\n\n // Render postcss (autoprefixing and friends)\n const result = await optimizeCss(filePath, renderedCss, browserslistData, cssUrl);\n const warnings = result.warnings().map(w => w.toString());\n\n const { code, warnings: esBuildWarnings } = await transform(result.css, {\n loader: 'css',\n minify: true,\n sourcefile: filePath,\n });\n\n if (esBuildWarnings.length > 0) {\n warnings.push(...(await formatMessages(esBuildWarnings, { kind: 'warning' })));\n }\n\n // Add to cache\n await cacache.put(\n cachePath,\n key,\n JSON.stringify({\n css: code,\n warnings,\n }),\n );\n\n return {\n css: code,\n warnings,\n };\n}\n\nasync function renderCss(\n filePath: string,\n css: string,\n basePath: string,\n styleIncludePaths?: string[],\n): Promise<string> {\n const ext = path.extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n /*\n * Please be aware of the few differences in behaviour https://github.com/sass/dart-sass/blob/master/README.md#behavioral-differences-from-ruby-sass\n * By default `npm install` will install sass.\n * To use node-sass you need to use:\n * Npm:\n * `npm install node-sass --save-dev`\n * Yarn:\n * `yarn add node-sass --dev`\n */\n let sassCompiler: any | undefined;\n try {\n sassCompiler = require('node-sass'); // Check if node-sass is explicitly included.\n } catch {\n sassCompiler = await import('sass');\n }\n\n return sassCompiler\n .renderSync({\n file: filePath,\n data: css,\n indentedSyntax: '.sass' === ext,\n importer: await import('node-sass-tilde-importer'),\n includePaths: styleIncludePaths,\n })\n .css.toString();\n }\n case '.less': {\n const { css: content } = await (\n await import('less')\n ).render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: styleIncludePaths,\n });\n\n return content;\n }\n case '.styl':\n case '.stylus': {\n const stylus = await import('stylus');\n\n return (\n stylus(css)\n // add paths for resolve\n .set('paths', [basePath, '.', ...styleIncludePaths, 'node_modules'])\n // add support for resolving plugins from node_modules\n .set('filename', filePath)\n // turn on url resolver in stylus, same as flag --resolve-url\n .set('resolve url', true)\n .define('url', stylus.resolver(undefined))\n .render()\n );\n }\n case '.css':\n default:\n return css;\n }\n}\n\nfunction optimizeCss(filePath: string, css: string, browsers: string[], cssUrl?: CssUrl): LazyResult {\n const postCssPlugins = [];\n\n if (cssUrl !== CssUrl.none) {\n postCssPlugins.push(postcssUrl({ url: cssUrl }));\n }\n\n postCssPlugins.push(\n postcssPresetEnv({\n browsers,\n autoprefixer: true,\n stage: 3,\n }),\n );\n\n return postcss(postCssPlugins).process(css, {\n from: filePath,\n to: filePath.replace(path.extname(filePath), '.css'),\n });\n}\n\nfunction generateKey(content: string, browserslistData: string[]): string {\n return createHash('sha1').update(ngPackagrVersion).update(content).update(browserslistData.join('')).digest('base64');\n}\n\nasync function readCacheEntry(cachePath: string, key: string): Promise<WorkerResult | undefined> {\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\nparentPort.on('message', async ({ signal, port, workerOptions }) => {\n try {\n const result = await processCss(workerOptions);\n port.postMessage({ ...result });\n } catch (error) {\n port.postMessage({ error: error.message });\n } finally {\n // Change the value of signal[0] to 1\n Atomics.add(signal, 0, 1);\n // Unlock the main thread\n Atomics.notify(signal, 0);\n port.close();\n }\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -29,7 +29,7 @@
29
29
  "main": "./public_api.js",
30
30
  "typings": "./public_api.d.ts",
31
31
  "dependencies": {
32
- "@rollup/plugin-commonjs": "^19.0.0",
32
+ "@rollup/plugin-commonjs": "^20.0.0",
33
33
  "@rollup/plugin-json": "^4.1.0",
34
34
  "@rollup/plugin-node-resolve": "^13.0.0",
35
35
  "ajv": "^8.0.0",
@@ -37,9 +37,9 @@
37
37
  "browserslist": "^4.16.1",
38
38
  "cacache": "^15.0.6",
39
39
  "chokidar": "^3.5.1",
40
- "commander": "^7.0.0",
41
- "cssnano": "^5.0.0",
40
+ "commander": "^8.0.0",
42
41
  "dependency-graph": "^0.11.0",
42
+ "esbuild": "^0.12.15",
43
43
  "find-cache-dir": "^3.3.1",
44
44
  "glob": "^7.1.6",
45
45
  "injection-js": "^2.4.0",
@@ -57,7 +57,7 @@
57
57
  "stylus": "^0.54.8"
58
58
  },
59
59
  "peerDependencies": {
60
- "@angular/compiler-cli": "^12.0.0 || ^12.1.0-next.0",
60
+ "@angular/compiler-cli": "^12.0.0 || ^12.2.0-next.0",
61
61
  "tslib": "^2.1.0",
62
62
  "typescript": "~4.2.3 || ~4.3.2"
63
63
  }