ng-packagr 10.0.0-next.2 → 10.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/CHANGELOG.md CHANGED
@@ -2,6 +2,40 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [10.0.0](https://github.com/ng-packagr/ng-packagr/compare/v10.0.0-rc.2...v10.0.0) (2020-06-24)
6
+
7
+ ## [10.0.0-rc.2](https://github.com/ng-packagr/ng-packagr/compare/v10.0.0-rc.1...v10.0.0-rc.2) (2020-06-12)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * issues with emitting declarationMap ([38ad52b](https://github.com/ng-packagr/ng-packagr/commit/38ad52b0980428a300126c4d8b83c5d06d552f29)), closes [#1464](https://github.com/ng-packagr/ng-packagr/issues/1464)
13
+
14
+ ## [10.0.0-rc.1](https://github.com/ng-packagr/ng-packagr/compare/v10.0.0-rc.0...v10.0.0-rc.1) (2020-06-10)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * disable CSS `calc` optimizations ([bdcc938](https://github.com/ng-packagr/ng-packagr/commit/bdcc938f765f3d58a79b395dcf7a749efddd3e94))
20
+ * release commit message formatting ([300b4bf](https://github.com/ng-packagr/ng-packagr/commit/300b4bff0534d5fe1591063488b8ade3ef396900))
21
+ * update @rollup/plugin-commonjs to version ^13.0.0 ([9413dbd](https://github.com/ng-packagr/ng-packagr/commit/9413dbd34f8d6a57abbfb9d71a72e97ecac47e1c))
22
+ * watch assets files and re-copy on changes ([e7465c3](https://github.com/ng-packagr/ng-packagr/commit/e7465c3cbd5b0094af4739ec9250b34c4f3aad27)), closes [#1545](https://github.com/ng-packagr/ng-packagr/issues/1545)
23
+
24
+ ## [10.0.0-rc.0](https://github.com/ng-packagr/ng-packagr/compare/v10.0.0-next.2...v10.0.0-rc.0) (2020-05-28)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * remove custom namespaced sourceRoot in sourcemaps ([481dd8f](https://github.com/ng-packagr/ng-packagr/commit/481dd8f77c927b564e3d3eb8c79e6cecdc580b52)), closes [#1622](https://github.com/ng-packagr/ng-packagr/issues/1622)
30
+ * remove tslib from peerDependencies when adding it to dependencies ([2981f73](https://github.com/ng-packagr/ng-packagr/commit/2981f73ff264caca66886f4a62027d26e69e410b))
31
+ * update @rollup/plugin-commonjs to version ^12.0.0 ([e89c5b1](https://github.com/ng-packagr/ng-packagr/commit/e89c5b1d325a83230428b1d8874d4a46fb6a0514))
32
+ * update @rollup/plugin-node-resolve to version ^8.0.0 ([b2ac9a2](https://github.com/ng-packagr/ng-packagr/commit/b2ac9a291a1ce7bcdb33f00b04408ccc6c76e71c))
33
+
34
+
35
+ ### Performance
36
+
37
+ * don't set setParentNodes for analyse sourcefiles ([d0ce240](https://github.com/ng-packagr/ng-packagr/commit/d0ce240130548b6633499f0685d6bbbff0cbb186))
38
+
5
39
  ## [10.0.0-next.2](https://github.com/ng-packagr/ng-packagr/compare/v10.0.0-next.1...v10.0.0-next.2) (2020-05-19)
6
40
 
7
41
 
package/README.md CHANGED
@@ -128,7 +128,7 @@ To orchestrate the different tools, ng-packagr features a [custom transformation
128
128
 
129
129
  ## Knowledge
130
130
 
131
- [Angular Package Format v9.0](https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview), design document at Google Docs
131
+ [Angular Package Format v10.0](https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview), design document at Google Docs
132
132
 
133
133
  Packaging Angular Libraries - Jason Aden at Angular Mountain View Meetup ([Jan 2018, 45min talk](https://www.youtube.com/watch?v=QfvwQEJVOig&t=3612s))
134
134
 
@@ -11,14 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.rollupBundleFile = void 0;
13
13
  const rollup = require("rollup");
14
- const nodeResolve = require("@rollup/plugin-node-resolve");
14
+ const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
15
15
  const sourcemaps = require("rollup-plugin-sourcemaps");
16
16
  const commonJs = require("@rollup/plugin-commonjs");
17
17
  const rollupJson = require("@rollup/plugin-json");
18
18
  const log = require("../utils/log");
19
19
  const external_module_id_strategy_1 = require("./external-module-id-strategy");
20
20
  const umd_module_id_strategy_1 = require("./umd-module-id-strategy");
21
- const path_1 = require("../utils/path");
22
21
  /** Runs rollup over the given entry file, writes a bundle file. */
23
22
  function rollupBundleFile(opts) {
24
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -34,7 +33,7 @@ function rollupBundleFile(opts) {
34
33
  // @ts-ignore
35
34
  rollupJson(),
36
35
  // @ts-ignore
37
- nodeResolve(),
36
+ plugin_node_resolve_1.default(),
38
37
  // @ts-ignore
39
38
  commonJs(),
40
39
  // @ts-ignore
@@ -66,25 +65,6 @@ function rollupBundleFile(opts) {
66
65
  banner: '',
67
66
  globals: moduleId => umd_module_id_strategy_1.umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),
68
67
  sourcemap: true,
69
- sourcemapPathTransform: (sourcePath) => {
70
- sourcePath = path_1.ensureUnixPath(sourcePath);
71
- // relocate sourcemaps
72
- if (!sourcePath) {
73
- return sourcePath;
74
- }
75
- // the replace here is because during the compilation one of the `/` gets lost sometimes
76
- const sourceRoot = path_1.ensureUnixPath(opts.sourceRoot);
77
- const mapRootUrl = sourceRoot.replace('//', '/');
78
- if (sourcePath.indexOf(mapRootUrl) >= 0) {
79
- return `${sourceRoot}${sourcePath.substr(sourcePath.indexOf(mapRootUrl) + mapRootUrl.length)}`;
80
- }
81
- else if (sourcePath.indexOf(sourceRoot) >= 0) {
82
- return sourcePath.substr(sourcePath.indexOf(mapRootUrl));
83
- }
84
- else {
85
- return sourcePath;
86
- }
87
- },
88
68
  });
89
69
  });
90
70
  }
@@ -1 +1 @@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CAAC,CAAC;IACL,CAAC;CAAA;AAnED,4CAmEC","sourcesContent":["import * as rollup from 'rollup';\nimport * as nodeResolve from '@rollup/plugin-node-resolve';\nimport * as sourcemaps from 'rollup-plugin-sourcemaps';\nimport * as commonJs from '@rollup/plugin-commonjs';\nimport * as rollupJson from '@rollup/plugin-json';\nimport * as log from '../utils/log';\nimport { ExternalModuleIdStrategy, DependencyList } from './external-module-id-strategy';\nimport { umdModuleIdStrategy } from './umd-module-id-strategy';\nimport { TransformHook } from 'rollup';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n format: rollup.ModuleFormat;\n dest: string;\n sourceRoot: string;\n umdModuleIds?: { [key: string]: string };\n amd?: { id: string };\n transform?: TransformHook;\n dependencyList?: DependencyList;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(opts: RollupOptions): Promise<void> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`);\n\n const externalModuleIdStrategy = new ExternalModuleIdStrategy(opts.format, opts.dependencyList);\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => externalModuleIdStrategy.isExternalDependency(moduleId),\n inlineDynamicImports: false,\n input: opts.entry,\n plugins: [\n // @ts-ignore\n rollupJson(),\n // @ts-ignore\n nodeResolve(),\n // @ts-ignore\n commonJs(),\n // @ts-ignore\n sourcemaps(),\n { transform: opts.transform },\n ],\n onwarn: warning => {\n if (typeof warning === 'string') {\n log.warn(warning);\n } else {\n if (warning.code === 'THIS_IS_UNDEFINED') {\n return;\n }\n\n log.warn(warning.message);\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n await bundle.write({\n name: opts.moduleName,\n format: opts.format,\n amd: opts.amd,\n file: opts.dest,\n banner: '',\n globals: moduleId => umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),\n sourcemap: true,\n sourcemapPathTransform: (sourcePath: string) => {\n sourcePath = ensureUnixPath(sourcePath);\n // relocate sourcemaps\n if (!sourcePath) {\n return sourcePath;\n }\n\n // the replace here is because during the compilation one of the `/` gets lost sometimes\n const sourceRoot = ensureUnixPath(opts.sourceRoot);\n const mapRootUrl = sourceRoot.replace('//', '/');\n if (sourcePath.indexOf(mapRootUrl) >= 0) {\n return `${sourceRoot}${sourcePath.substr(sourcePath.indexOf(mapRootUrl) + mapRootUrl.length)}`;\n } else if (sourcePath.indexOf(sourceRoot) >= 0) {\n return sourcePath.substr(sourcePath.indexOf(mapRootUrl));\n } else {\n return sourcePath;\n }\n },\n });\n}\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,qEAAsD;AACtD,uDAAuD;AACvD,oDAAoD;AACpD,kDAAkD;AAClD,oCAAoC;AACpC,+EAAyF;AACzF,qEAA+D;AAoB/D,mEAAmE;AACnE,SAAsB,gBAAgB,CAAC,IAAmB;;QACxD,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAExF,MAAM,wBAAwB,GAAG,IAAI,sDAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAEhG,oBAAoB;QACpB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACjC,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YAC7E,oBAAoB,EAAE,KAAK;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE;gBACP,aAAa;gBACb,UAAU,EAAE;gBACZ,aAAa;gBACb,6BAAW,EAAE;gBACb,aAAa;gBACb,QAAQ,EAAE;gBACV,aAAa;gBACb,UAAU,EAAE;gBACZ,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;aAC9B;YACD,MAAM,EAAE,OAAO,CAAC,EAAE;gBAChB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;oBAC/B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACnB;qBAAM;oBACL,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAmB,EAAE;wBACxC,OAAO;qBACR;oBAED,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;iBAC3B;YACH,CAAC;YACD,gBAAgB,EAAE,IAAI;YACtB,8CAA8C;YAC9C,qDAAqD;YACrD,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,IAAI,EAAE,IAAI,CAAC,UAAU;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,4CAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;YAC3E,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CAAA;AAjDD,4CAiDC","sourcesContent":["import * as rollup from 'rollup';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as sourcemaps from 'rollup-plugin-sourcemaps';\nimport * as commonJs from '@rollup/plugin-commonjs';\nimport * as rollupJson from '@rollup/plugin-json';\nimport * as log from '../utils/log';\nimport { ExternalModuleIdStrategy, DependencyList } from './external-module-id-strategy';\nimport { umdModuleIdStrategy } from './umd-module-id-strategy';\nimport { TransformHook } from 'rollup';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n format: rollup.ModuleFormat;\n dest: string;\n sourceRoot: string;\n umdModuleIds?: { [key: string]: string };\n amd?: { id: string };\n transform?: TransformHook;\n dependencyList?: DependencyList;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(opts: RollupOptions): Promise<void> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`);\n\n const externalModuleIdStrategy = new ExternalModuleIdStrategy(opts.format, opts.dependencyList);\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => externalModuleIdStrategy.isExternalDependency(moduleId),\n inlineDynamicImports: false,\n input: opts.entry,\n plugins: [\n // @ts-ignore\n rollupJson(),\n // @ts-ignore\n nodeResolve(),\n // @ts-ignore\n commonJs(),\n // @ts-ignore\n sourcemaps(),\n { transform: opts.transform },\n ],\n onwarn: warning => {\n if (typeof warning === 'string') {\n log.warn(warning);\n } else {\n if (warning.code === 'THIS_IS_UNDEFINED') {\n return;\n }\n\n log.warn(warning.message);\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n await bundle.write({\n name: opts.moduleName,\n format: opts.format,\n amd: opts.amd,\n file: opts.dest,\n banner: '',\n globals: moduleId => umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),\n sourcemap: true,\n });\n}\n"]}
@@ -31,7 +31,7 @@ function analyseEntryPoint(graph, entryPoint, entryPoints) {
31
31
  const primaryModuleId = packageNode.data.primary.moduleId;
32
32
  log_1.debug(`Analysing sources for ${moduleId}`);
33
33
  const tsConfigOptions = Object.assign(Object.assign({}, entryPoint.data.tsConfig.options), { skipLibCheck: true, noLib: true, types: [] });
34
- const compilerHost = cache_compiler_host_1.cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, analysesSourcesFileCache);
34
+ const compilerHost = cache_compiler_host_1.cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, analysesSourcesFileCache, false);
35
35
  compilerHost.resolveModuleNames = (moduleNames, containingFile) => {
36
36
  return moduleNames.map(moduleName => {
37
37
  if (!moduleName.startsWith('.')) {
@@ -1 +1 @@
1
- {"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,+BAA4B;AAC5B,8CAAqC;AACrC,oCAAgF;AAChF,sEAAiE;AAGjE,yCAAwC;AACxC,2CAAkD;AAErC,QAAA,uBAAuB,GAAc,WAAI,CACpD,eAAG,CAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAqB,CAAC;IACnE,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAqB,CAAC;IAEzF,KAAK,MAAM,UAAU,IAAI,gBAAgB,EAAE;QACzC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;KACnD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC,CACH,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,KAAiB,EAAE,UAA0B,EAAE,WAA6B;IACrG,MAAM,EAAE,WAAW,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IAC1F,MAAM,UAAU,GAAG,WAAW,IAAK,WAAW,CAAC,UAAU,CAA4B,CAAC;IACtF,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC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AAE,CAAC,CAAC;YAEpE,IAAI,QAAQ,KAAK,UAAU,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;aACnF;YAED,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,KAAK,CAAC,CAAC,EAAE;gBACnC,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,iCAAiC,QAAQ,GAAG,CAAC,CAAC;aACxF;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC3B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,yBAAyB,QAAQ,kBAAkB,CAAC,CAAC;SAC/F;KACF;AACH,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { isEntryPoint, EntryPointNode, isPackage, PackageNode } from '../nodes';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Transform } from '../../graph/transform';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];\n const dirtyEntryPoints = entryPoints.filter(x => x.state !== 'done') as EntryPointNode[];\n\n for (const entryPoint of dirtyEntryPoints) {\n analyseEntryPoint(graph, entryPoint, entryPoints);\n }\n\n return graph;\n }),\n);\n\n/**\n * Analyses an entrypoint, searching for TypeScript dependencies and additional resources (Templates and Stylesheets).\n *\n * @param graph Build graph\n * @param entryPoint Current entry point that should be analysed.\n * @param entryPoints List of all entry points.\n */\nfunction analyseEntryPoint(graph: BuildGraph, entryPoint: EntryPointNode, entryPoints: EntryPointNode[]) {\n const { oldPrograms, analysesSourcesFileCache, moduleResolutionCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n const packageNode = graph.find(isPackage) as PackageNode;\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n debug(`Analysing sources for ${moduleId}`);\n const tsConfigOptions: ts.CompilerOptions = {\n ...entryPoint.data.tsConfig.options,\n skipLibCheck: true,\n noLib: true,\n types: [],\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n undefined,\n analysesSourcesFileCache,\n );\n\n compilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n if (!moduleName.startsWith('.')) {\n return undefined;\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n tsConfigOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n };\n\n const program: ts.Program = ts.createProgram(\n entryPoint.data.tsConfig.rootNames,\n tsConfigOptions,\n compilerHost,\n oldProgram,\n );\n\n // this is a workaround due to the below\n // https://github.com/angular/angular/issues/24010\n const potentialDependencies = new Set<string>();\n program\n .getSourceFiles()\n .filter(x => !x.fileName.endsWith('.d.ts'))\n .forEach(sourceFile => {\n sourceFile.statements\n .filter(x => ts.isImportDeclaration(x) || ts.isExportDeclaration(x))\n .forEach((node: ts.ImportDeclaration | ts.ExportDeclaration) => {\n const { moduleSpecifier } = node;\n if (!moduleSpecifier || !ts.isStringLiteral(moduleSpecifier)) {\n return;\n }\n\n const moduleName = moduleSpecifier.text;\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n });\n });\n\n debug(`tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`);\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n const entryPointsMapped: Record<string, EntryPointNode> = {};\n for (const dep of entryPoints) {\n entryPointsMapped[dep.data.entryPoint.moduleId] = dep;\n }\n\n for (const moduleName of potentialDependencies) {\n const dep = entryPointsMapped[moduleName];\n\n if (dep) {\n debug(`Found entry point dependency: ${moduleId} -> ${moduleName}`);\n\n if (moduleId === moduleName) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);\n }\n\n if (dep.some(n => entryPoint === n)) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);\n }\n\n entryPoint.dependsOn(dep);\n } else {\n throw new Error(`Entry point ${moduleName} which is required by ${moduleId} doesn't exists.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,+BAA4B;AAC5B,8CAAqC;AACrC,oCAAgF;AAChF,sEAAiE;AAGjE,yCAAwC;AACxC,2CAAkD;AAErC,QAAA,uBAAuB,GAAc,WAAI,CACpD,eAAG,CAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAqB,CAAC;IACnE,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAqB,CAAC;IAEzF,KAAK,MAAM,UAAU,IAAI,gBAAgB,EAAE;QACzC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;KACnD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC,CACH,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,KAAiB,EAAE,UAA0B,EAAE,WAA6B;IACrG,MAAM,EAAE,WAAW,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IAC1F,MAAM,UAAU,GAAG,WAAW,IAAK,WAAW,CAAC,UAAU,CAA4B,CAAC;IACtF,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CA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K,CAAC,iCAAiC,QAAQ,OAAO,UAAU,EAAE,CAAC,CAAC;YAEpE,IAAI,QAAQ,KAAK,UAAU,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;aACnF;YAED,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,KAAK,CAAC,CAAC,EAAE;gBACnC,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,iCAAiC,QAAQ,GAAG,CAAC,CAAC;aACxF;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC3B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,yBAAyB,QAAQ,kBAAkB,CAAC,CAAC;SAC/F;KACF;AACH,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { isEntryPoint, EntryPointNode, isPackage, PackageNode } from '../nodes';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Transform } from '../../graph/transform';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];\n const dirtyEntryPoints = entryPoints.filter(x => x.state !== 'done') as EntryPointNode[];\n\n for (const entryPoint of dirtyEntryPoints) {\n analyseEntryPoint(graph, entryPoint, entryPoints);\n }\n\n return graph;\n }),\n);\n\n/**\n * Analyses an entrypoint, searching for TypeScript dependencies and additional resources (Templates and Stylesheets).\n *\n * @param graph Build graph\n * @param entryPoint Current entry point that should be analysed.\n * @param entryPoints List of all entry points.\n */\nfunction analyseEntryPoint(graph: BuildGraph, entryPoint: EntryPointNode, entryPoints: EntryPointNode[]) {\n const { oldPrograms, analysesSourcesFileCache, moduleResolutionCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n const packageNode = graph.find(isPackage) as PackageNode;\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n debug(`Analysing sources for ${moduleId}`);\n const tsConfigOptions: ts.CompilerOptions = {\n ...entryPoint.data.tsConfig.options,\n skipLibCheck: true,\n noLib: true,\n types: [],\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n undefined,\n analysesSourcesFileCache,\n false,\n );\n\n compilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n if (!moduleName.startsWith('.')) {\n return undefined;\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n tsConfigOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n };\n\n const program: ts.Program = ts.createProgram(\n entryPoint.data.tsConfig.rootNames,\n tsConfigOptions,\n compilerHost,\n oldProgram,\n );\n\n // this is a workaround due to the below\n // https://github.com/angular/angular/issues/24010\n const potentialDependencies = new Set<string>();\n program\n .getSourceFiles()\n .filter(x => !x.fileName.endsWith('.d.ts'))\n .forEach(sourceFile => {\n sourceFile.statements\n .filter(x => ts.isImportDeclaration(x) || ts.isExportDeclaration(x))\n .forEach((node: ts.ImportDeclaration | ts.ExportDeclaration) => {\n const { moduleSpecifier } = node;\n if (!moduleSpecifier || !ts.isStringLiteral(moduleSpecifier)) {\n return;\n }\n\n const moduleName = moduleSpecifier.text;\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n });\n });\n\n debug(`tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`);\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n const entryPointsMapped: Record<string, EntryPointNode> = {};\n for (const dep of entryPoints) {\n entryPointsMapped[dep.data.entryPoint.moduleId] = dep;\n }\n\n for (const moduleName of potentialDependencies) {\n const dep = entryPointsMapped[moduleName];\n\n if (dep) {\n debug(`Found entry point dependency: ${moduleId} -> ${moduleName}`);\n\n if (moduleId === moduleName) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);\n }\n\n if (dep.some(n => entryPoint === n)) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);\n }\n\n entryPoint.dependsOn(dep);\n } else {\n throw new Error(`Entry point ${moduleName} which is required by ${moduleId} doesn't exists.`);\n }\n }\n}\n"]}
@@ -33,9 +33,10 @@ exports.compileNgcTransform = transform_1.transformFromPromise((graph) => __awai
33
33
  const ngccProcessor = tsConfig.options.enableIvy ? new ngcc_processor_1.NgccProcessor(tsConfig.options, entryPoints) : undefined;
34
34
  yield compile_source_files_1.compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetProcessor, {
35
35
  outDir: path.dirname(esm2015),
36
+ declarationDir: path.dirname(declarations),
36
37
  declaration: true,
37
38
  target: ts.ScriptTarget.ES2015,
38
- }, path.dirname(declarations), ngccProcessor);
39
+ }, ngccProcessor);
39
40
  return graph;
40
41
  }));
41
42
  //# sourceMappingURL=compile-ngc.transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iCAAiC;AACjC,qDAAwE;AACxE,yEAAoE;AACpE,6DAAyD;AACzD,gDAAiE;AACjE,uCAAuC;AACvC,oCAAgF;AAChF,4EAAwE;AAE3D,QAAA,mBAAmB,GAAc,gCAAoB,CAAC,CAAO,KAAK,EAAE,EAAE;IACjF,GAAG,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAmB,CAAC;IAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAqB,CAAC;IACnE,sCAAsC;IACtC,MAAM,QAAQ,GAAG,uCAA4B,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAErF,6BAA6B;IAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACnE,MAAM,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IACnD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC3E,MAAM,mBAAmB,GAAG,IAAI,0CAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAEzF,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,8BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhH,MAAM,yCAAkB,CACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB;QACE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7B,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;KAC/B,EACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAC1B,aAAa,CACd,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport * as ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { NgccProcessor } from '../../ngc/ngcc-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport * as log from '../../utils/log';\nimport { isEntryPointInProgress, EntryPointNode, isEntryPoint } from '../nodes';\nimport { StylesheetProcessor } from '../../styles/stylesheet-processor';\n\nexport const compileNgcTransform: Transform = transformFromPromise(async (graph) => {\n log.info(`Compiling TypeScript sources through ngc`);\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2015, declarations } = entryPoint.data.destinationFiles;\n const { moduleResolutionCache } = entryPoint.cache;\n const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;\n const stylesheetProcessor = new StylesheetProcessor(basePath, cssUrl, styleIncludePaths);\n\n const ngccProcessor = tsConfig.options.enableIvy ? new NgccProcessor(tsConfig.options, entryPoints) : undefined;\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n stylesheetProcessor,\n {\n outDir: path.dirname(esm2015),\n declaration: true,\n target: ts.ScriptTarget.ES2015,\n },\n path.dirname(declarations),\n ngccProcessor,\n );\n\n return graph;\n});\n"]}
1
+ {"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iCAAiC;AACjC,qDAAwE;AACxE,yEAAoE;AACpE,6DAAyD;AACzD,gDAAiE;AACjE,uCAAuC;AACvC,oCAAgF;AAChF,4EAAwE;AAE3D,QAAA,mBAAmB,GAAc,gCAAoB,CAAC,CAAM,KAAK,EAAC,EAAE;IAC/E,GAAG,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAmB,CAAC;IAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAqB,CAAC;IACnE,sCAAsC;IACtC,MAAM,QAAQ,GAAG,uCAA4B,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAErF,6BAA6B;IAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACnE,MAAM,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IACnD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC3E,MAAM,mBAAmB,GAAG,IAAI,0CAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAEzF,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,8BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhH,MAAM,yCAAkB,CACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB;QACE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1C,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;KAC/B,EACD,aAAa,CACd,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport * as ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { NgccProcessor } from '../../ngc/ngcc-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport * as log from '../../utils/log';\nimport { isEntryPointInProgress, EntryPointNode, isEntryPoint } from '../nodes';\nimport { StylesheetProcessor } from '../../styles/stylesheet-processor';\n\nexport const compileNgcTransform: Transform = transformFromPromise(async graph => {\n log.info(`Compiling TypeScript sources through ngc`);\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2015, declarations } = entryPoint.data.destinationFiles;\n const { moduleResolutionCache } = entryPoint.cache;\n const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;\n const stylesheetProcessor = new StylesheetProcessor(basePath, cssUrl, styleIncludePaths);\n\n const ngccProcessor = tsConfig.options.enableIvy ? new NgccProcessor(tsConfig.options, entryPoints) : undefined;\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n stylesheetProcessor,\n {\n outDir: path.dirname(esm2015),\n declarationDir: path.dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2015,\n },\n ngccProcessor,\n );\n\n return graph;\n});\n"]}
@@ -19,6 +19,7 @@ const log = require("../../utils/log");
19
19
  const glob_1 = require("../../utils/glob");
20
20
  const nodes_1 = require("../nodes");
21
21
  const copy_1 = require("../../utils/copy");
22
+ const node_1 = require("../../graph/node");
22
23
  exports.writePackageTransform = transform_1.transformFromPromise((graph) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  const entryPoint = graph.find(nodes_1.isEntryPointInProgress());
24
25
  const ngEntryPoint = entryPoint.data.entryPoint;
@@ -43,6 +44,7 @@ exports.writePackageTransform = transform_1.transformFromPromise((graph) => __aw
43
44
  yield Promise.all(declarationFiles.map(value => {
44
45
  const relativePath = path.relative(ngEntryPoint.entryFilePath, value);
45
46
  const destination = path.resolve(destinationFiles.declarations, relativePath);
47
+ entryPoint.dependsOn(new node_1.Node(nodes_1.fileUrl(path_1.ensureUnixPath(relativePath))));
46
48
  return copy_1.copyFile(value, destination, { overwrite: true, dereference: true });
47
49
  }));
48
50
  }
@@ -58,6 +60,7 @@ exports.writePackageTransform = transform_1.transformFromPromise((graph) => __aw
58
60
  yield Promise.all(assetFiles.map(value => {
59
61
  const relativePath = path.relative(ngPackage.src, value);
60
62
  const destination = path.resolve(ngPackage.dest, relativePath);
63
+ entryPoint.dependsOn(new node_1.Node(nodes_1.fileUrl(path_1.ensureUnixPath(relativePath))));
61
64
  return copy_1.copyFile(value, destination, { overwrite: true, dereference: true });
62
65
  }));
63
66
  }
@@ -117,6 +120,7 @@ function writePackageJson(entryPoint, pkg, additionalProperties, isIvy) {
117
120
  else if ((_c = packageJson.peerDependencies) === null || _c === void 0 ? void 0 : _c.tslib) {
118
121
  log.warn(`'tslib' is no longer recommanded to be used as a 'peerDependencies'. Moving it to 'dependencies'.`);
119
122
  packageJson.dependencies = Object.assign(Object.assign({}, (packageJson.dependencies || {})), { tslib: packageJson.peerDependencies.tslib });
123
+ delete packageJson.peerDependencies.tslib;
120
124
  }
121
125
  }
122
126
  // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts
@@ -1 +1 @@
1
- {"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,qDAAwE;AAGxE,2CAAkD;AAClD,+CAA4C;AAC5C,uCAAuC;AACvC,2CAA6C;AAC7C,oCAA0F;AAC1F,2CAA4C;AAE/B,QAAA,qBAAqB,GAAc,gCAAoB,CAAC,CAAM,KAAK,EAAC,EAAE;IACjF,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAmB,CAAC;IAC1E,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAgB,CAAC;IAC3D,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,C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;YACd,iBAAiB;YACjB,MAAM;YACN,YAAY;YACZ,OAAO;SACR,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,6BAA6B,EAAE;YAChD,IAAI,IAAI,IAAI,WAAW,EAAE;gBACvB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;gBACzB,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,2BAA2B,CAAC,CAAC;aACvD;SACF;QAED,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;QAEvC,wEAAwE;QACxE,kFAAkF;QAClF,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,WAAW,EAAE;YACtF,MAAM,EAAE,CAAC;SACV,CAAC,CAAC;;CACJ;AAED,SAAS,wBAAwB,CAAC,WAAoC,EAAE,QAAgB,EAAE,SAAmB;IAC3G,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO;KACR;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE;QACpD,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5C,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,uBAAuB,QAAQ,GAAG,CAAC,CAAC;SAChE;aAAM;YACL,GAAG,CAAC,IAAI,CACN,mCAAmC,QAAQ,gDAAgD,GAAG,6CAA6C,QAAQ,IAAI,CACxJ,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,kCAAkC,CAAC,CAAC;SACtE;KACF;AACH,CAAC","sourcesContent":["import * as fs from 'fs-extra';\nimport * as path from 'path';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { NgEntryPoint } from './entry-point';\nimport { NgPackage } from '../package';\nimport { ensureUnixPath } from '../../utils/path';\nimport { rimraf } from '../../utils/rimraf';\nimport * as log from '../../utils/log';\nimport { globFiles } from '../../utils/glob';\nimport { EntryPointNode, isEntryPointInProgress, isPackage, PackageNode } from '../nodes';\nimport { copyFile } from '../../utils/copy';\n\nexport const writePackageTransform: Transform = transformFromPromise(async graph => {\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode = graph.find(isPackage) as PackageNode;\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n // we don't want to copy `dist` and 'node_modules' declaration files but only files in source\n const declarationFiles = await globFiles(`${path.dirname(ngEntryPoint.entryFilePath)}/**/*.d.ts`, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n });\n\n if (declarationFiles.length) {\n // COPY SOURCE FILES TO DESTINATION\n log.info('Copying declaration files');\n await Promise.all(\n declarationFiles.map(value => {\n const relativePath = path.relative(ngEntryPoint.entryFilePath, value);\n const destination = path.resolve(destinationFiles.declarations, relativePath);\n return copyFile(value, destination, { overwrite: true, dereference: true });\n }),\n );\n }\n if (ngPackage.assets.length && !ngEntryPoint.isSecondaryEntryPoint) {\n const assets = ngPackage.assets.map(x => path.join(ngPackage.src, x));\n const assetFiles = await globFiles(assets, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n });\n\n if (assetFiles.length) {\n // COPY ASSET FILES TO DESTINATION\n log.info('Copying assets');\n await Promise.all(\n assetFiles.map(value => {\n const relativePath = path.relative(ngPackage.src, value);\n const destination = path.resolve(ngPackage.dest, relativePath);\n return copyFile(value, destination, { overwrite: true, dereference: true });\n }),\n );\n }\n }\n\n // 6. WRITE PACKAGE.JSON\n log.info('Writing package metadata');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const isIvy = !!entryPoint.data.tsConfig.options.enableIvy;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n main: relativeUnixFromDestPath(destinationFiles.umd),\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n esm2015: relativeUnixFromDestPath(destinationFiles.esm2015),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n // Ivy doesn't generate metadata files\n metadata: isIvy ? undefined : relativeUnixFromDestPath(destinationFiles.metadata),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.sideEffects,\n },\n isIvy,\n );\n\n log.success(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n});\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] },\n isIvy: boolean,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n log.warn(`'tslib' is no longer recommanded to be used as a 'peerDependencies'. Moving it to 'dependencies'.`);\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const whitelist = pkg.whitelistedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', whitelist);\n } catch (e) {\n await rimraf(entryPoint.destinationPath);\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n log.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n log.warn(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n );\n }\n }\n\n if (isIvy && !entryPoint.isSecondaryEntryPoint) {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n log.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n\n // `outputJson()` creates intermediate directories, if they do not exist\n // -- https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputJson.md\n await fs.outputJson(path.join(entryPoint.destinationPath, 'package.json'), packageJson, {\n spaces: 2,\n });\n}\n\nfunction checkNonPeerDependencies(packageJson: Record<string, unknown>, property: string, whitelist: RegExp[]) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (whitelist.find(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is whitelisted in '${property}'`);\n } else {\n log.warn(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} to 'peerDependencies' or remove it from '${property}'.`,\n );\n throw new Error(`Dependency ${dep} must be explicitly whitelisted.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,qDAAwE;AAGxE,2CAAkD;AAClD,+CAA4C;AAC5C,uCAAuC;AACvC,2CAA6C;AAC7C,oCAAmG;AACnG,2CAA4C;AAC5C,2CAAwC;AAE3B,QAAA,qBAAqB,GAAc,gCAAoB,CAAC,CAAM,KAAK,EAAC,EAAE;IACjF,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAmB,CAAC;IAC1E,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAgB,CAAC;IAC3D,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACrC,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IAC7C,MAAM,WAAW,GAAa;QAC5B,UAAU;QACV,cAAc;QACd,cAAc;QACd,oBAAoB;QACpB,GAAG,SAAS,CAAC,IAAI,KAAK;KACvB,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port { Transform, transformFromPromise } from '../../graph/transform';\nimport { NgEntryPoint } from './entry-point';\nimport { NgPackage } from '../package';\nimport { ensureUnixPath } from '../../utils/path';\nimport { rimraf } from '../../utils/rimraf';\nimport * as log from '../../utils/log';\nimport { globFiles } from '../../utils/glob';\nimport { EntryPointNode, isEntryPointInProgress, isPackage, PackageNode, fileUrl } from '../nodes';\nimport { copyFile } from '../../utils/copy';\nimport { Node } from '../../graph/node';\n\nexport const writePackageTransform: Transform = transformFromPromise(async graph => {\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode = graph.find(isPackage) as PackageNode;\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n // we don't want to copy `dist` and 'node_modules' declaration files but only files in source\n const declarationFiles = await globFiles(`${path.dirname(ngEntryPoint.entryFilePath)}/**/*.d.ts`, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n });\n\n if (declarationFiles.length) {\n // COPY SOURCE FILES TO DESTINATION\n log.info('Copying declaration files');\n await Promise.all(\n declarationFiles.map(value => {\n const relativePath = path.relative(ngEntryPoint.entryFilePath, value);\n const destination = path.resolve(destinationFiles.declarations, relativePath);\n entryPoint.dependsOn(new Node(fileUrl(ensureUnixPath(relativePath))));\n return copyFile(value, destination, { overwrite: true, dereference: true });\n }),\n );\n }\n if (ngPackage.assets.length && !ngEntryPoint.isSecondaryEntryPoint) {\n const assets = ngPackage.assets.map(x => path.join(ngPackage.src, x));\n const assetFiles = await globFiles(assets, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n });\n\n if (assetFiles.length) {\n // COPY ASSET FILES TO DESTINATION\n log.info('Copying assets');\n await Promise.all(\n assetFiles.map(value => {\n const relativePath = path.relative(ngPackage.src, value);\n const destination = path.resolve(ngPackage.dest, relativePath);\n entryPoint.dependsOn(new Node(fileUrl(ensureUnixPath(relativePath))));\n return copyFile(value, destination, { overwrite: true, dereference: true });\n }),\n );\n }\n }\n\n // 6. WRITE PACKAGE.JSON\n log.info('Writing package metadata');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const isIvy = !!entryPoint.data.tsConfig.options.enableIvy;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n main: relativeUnixFromDestPath(destinationFiles.umd),\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n esm2015: relativeUnixFromDestPath(destinationFiles.esm2015),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n // Ivy doesn't generate metadata files\n metadata: isIvy ? undefined : relativeUnixFromDestPath(destinationFiles.metadata),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.sideEffects,\n },\n isIvy,\n );\n\n log.success(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n});\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] },\n isIvy: boolean,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n log.warn(`'tslib' is no longer recommanded to be used as a 'peerDependencies'. Moving it to 'dependencies'.`);\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n\n delete packageJson.peerDependencies.tslib;\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const whitelist = pkg.whitelistedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', whitelist);\n } catch (e) {\n await rimraf(entryPoint.destinationPath);\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n log.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n log.warn(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n );\n }\n }\n\n if (isIvy && !entryPoint.isSecondaryEntryPoint) {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n log.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n\n // `outputJson()` creates intermediate directories, if they do not exist\n // -- https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputJson.md\n await fs.outputJson(path.join(entryPoint.destinationPath, 'package.json'), packageJson, {\n spaces: 2,\n });\n}\n\nfunction checkNonPeerDependencies(packageJson: Record<string, unknown>, property: string, whitelist: RegExp[]) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (whitelist.find(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is whitelisted in '${property}'`);\n } else {\n log.warn(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} to 'peerDependencies' or remove it from '${property}'.`,\n );\n throw new Error(`Dependency ${dep} must be explicitly whitelisted.`);\n }\n }\n}\n"]}
@@ -3,4 +3,4 @@ import * as ts from 'typescript';
3
3
  import { StylesheetProcessor } from '../styles/stylesheet-processor';
4
4
  import { BuildGraph } from '../graph/build-graph';
5
5
  import { NgccProcessor } from './ngcc-processor';
6
- export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ng.ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor: StylesheetProcessor, extraOptions?: Partial<ng.CompilerOptions>, declarationDir?: string, ngccProcessor?: NgccProcessor): Promise<void>;
6
+ export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ng.ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor: StylesheetProcessor, extraOptions?: Partial<ng.CompilerOptions>, ngccProcessor?: NgccProcessor): Promise<void>;
@@ -12,21 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.compileSourceFiles = void 0;
13
13
  const ng = require("@angular/compiler-cli");
14
14
  const log = require("../utils/log");
15
- const redirect_write_file_compiler_host_1 = require("../ts/redirect-write-file-compiler-host");
16
15
  const cache_compiler_host_1 = require("../ts/cache-compiler-host");
17
16
  const nodes_1 = require("../ng-package/nodes");
18
17
  const ngcc_transform_compiler_host_1 = require("../ts/ngcc-transform-compiler-host");
19
18
  const create_emit_callback_1 = require("./create-emit-callback");
20
- const ctor_parameters_1 = require("../ts/ctor-parameters");
21
- function compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetProcessor, extraOptions, declarationDir, ngccProcessor) {
19
+ function compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetProcessor, extraOptions, ngccProcessor) {
22
20
  return __awaiter(this, void 0, void 0, function* () {
23
21
  log.debug(`ngc (v${ng.VERSION.full})`);
24
22
  const tsConfigOptions = Object.assign(Object.assign({}, tsConfig.options), extraOptions);
25
23
  const entryPoint = graph.find(nodes_1.isEntryPointInProgress());
26
24
  let tsCompilerHost = cache_compiler_host_1.cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor);
27
- if (declarationDir) {
28
- tsCompilerHost = redirect_write_file_compiler_host_1.redirectWriteFileCompilerHost(tsCompilerHost, tsConfigOptions.basePath, declarationDir);
29
- }
30
25
  if (tsConfigOptions.enableIvy && ngccProcessor) {
31
26
  tsCompilerHost = ngcc_transform_compiler_host_1.ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);
32
27
  }
@@ -55,10 +50,6 @@ function compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetPr
55
50
  ...ngProgram.getNgSemanticDiagnostics(),
56
51
  ...ngProgram.getNgStructuralDiagnostics(),
57
52
  ];
58
- const beforeTs = [];
59
- if (!tsConfigOptions.annotateForClosureCompiler) {
60
- beforeTs.push(ctor_parameters_1.downlevelConstructorParameters(() => ngProgram.getTsProgram().getTypeChecker()));
61
- }
62
53
  // if we have an error we don't want to transpile.
63
54
  const hasError = ng.exitCodeFromResult(allDiagnostics) > 0;
64
55
  if (!hasError) {
@@ -68,9 +59,6 @@ function compileSourceFiles(graph, tsConfig, moduleResolutionCache, stylesheetPr
68
59
  emitFlags,
69
60
  // For Ivy we don't need a custom emitCallback to have tsickle transforms
70
61
  emitCallback: tsConfigOptions.enableIvy ? undefined : create_emit_callback_1.createEmitCallback(tsConfigOptions),
71
- customTransformers: {
72
- beforeTs,
73
- },
74
62
  });
75
63
  allDiagnostics.push(...diagnostics);
76
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA4C;AAE5C,oCAAoC;AACpC,+FAAwF;AACxF,mEAA8D;AAG9D,+CAA6E;AAE7E,qFAA+E;AAC/E,iEAA4D;AAC5D,2DAAuE;AAEvE,SAAsB,kBAAkB,CACtC,KAAiB,EACjB,QAAgC,EAChC,qBAA+C,EAC/C,mBAAwC,EACxC,YAA0C,EAC1C,cAAuB,EACvB,aAA6B;;QAE7B,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAEvC,MAAM,eAAe,mCAA4B,QAAQ,CAAC,OAAO,GAAK,YAAY,CAAE,CAAC;QACrF,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAmB,CAAC;QAE1E,IAAI,cAAc,GAAG,uCAAiB,CACpC,KAAK,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,CACpB,CAAC;QACF,IAAI,cAAc,EAAE;YAClB,cAAc,GAAG,iEAA6B,CAAC,cAAc,EAAE,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;SAC1G;QAED,IAAI,eAAe,CAAC,SAAS,IAAI,aAAa,EAAE;YAC9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C,IAAI,CAAC,gDAA8B,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;SAChG;QAED,kDAAkD;QAClD,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACrF,wFAAwF;YACxF,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC;gBACrC,SAAS;gBACT,yEAAyE;gBACzE,YAAY,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,yCAAkB,CAAC,eAAe,CAAC;gBACzF,kBAAkB,EAAE;oBAClB,QAAQ;iBACT;aACF,CAAC,CAAC;YAEH,cAAc,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;SACrC;QAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO;SACR;QAED,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACvD,MAAM,oBAAoB,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,QAAQ,KAAK,CAAC,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACvC;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;SAC/B;IACH,CAAC;CAAA;AAlGD,gDAkGC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport { redirectWriteFileCompilerHost } from '../ts/redirect-write-file-compiler-host';\nimport { cacheCompilerHost } from '../ts/cache-compiler-host';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from './ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\nimport { createEmitCallback } from './create-emit-callback';\nimport { downlevelConstructorParameters } from '../ts/ctor-parameters';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor: StylesheetProcessor,\n extraOptions?: Partial<ng.CompilerOptions>,\n declarationDir?: string,\n ngccProcessor?: NgccProcessor,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n\n let tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n );\n if (declarationDir) {\n tsCompilerHost = redirectWriteFileCompilerHost(tsCompilerHost, tsConfigOptions.basePath, declarationDir);\n }\n\n if (tsConfigOptions.enableIvy && ngccProcessor) {\n tsCompilerHost = ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);\n }\n\n // ng.CompilerHost\n const ngCompilerHost = ng.createCompilerHost({\n options: tsConfigOptions,\n tsHost: tsCompilerHost,\n });\n\n const scriptTarget = tsConfigOptions.target;\n const cache = entryPoint.cache;\n const oldProgram = cache.oldPrograms && (cache.oldPrograms[scriptTarget] as ng.Program | undefined);\n\n const ngProgram = ng.createProgram({\n rootNames: tsConfig.rootNames,\n options: tsConfigOptions,\n host: ngCompilerHost,\n oldProgram,\n });\n\n await ngProgram.loadNgStructureAsync();\n\n log.debug(\n `ngc program structure is reused: ${\n oldProgram ? (oldProgram.getTsProgram() as any).structureIsReused : 'No old program'\n }`,\n );\n\n cache.oldPrograms = { ...cache.oldPrograms, [scriptTarget]: ngProgram };\n\n const allDiagnostics = [\n ...ngProgram.getTsOptionDiagnostics(),\n ...ngProgram.getNgOptionDiagnostics(),\n ...ngProgram.getTsSyntacticDiagnostics(),\n ...ngProgram.getTsSemanticDiagnostics(),\n ...ngProgram.getNgSemanticDiagnostics(),\n ...ngProgram.getNgStructuralDiagnostics(),\n ];\n\n const beforeTs: ts.TransformerFactory<ts.SourceFile>[] = [];\n if (!tsConfigOptions.annotateForClosureCompiler) {\n beforeTs.push(downlevelConstructorParameters(() => ngProgram.getTsProgram().getTypeChecker()));\n }\n\n // if we have an error we don't want to transpile.\n const hasError = ng.exitCodeFromResult(allDiagnostics) > 0;\n if (!hasError) {\n const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;\n // certain errors are only emitted by a compilation hence append to previous diagnostics\n const { diagnostics } = ngProgram.emit({\n emitFlags,\n // For Ivy we don't need a custom emitCallback to have tsickle transforms\n emitCallback: tsConfigOptions.enableIvy ? undefined : createEmitCallback(tsConfigOptions),\n customTransformers: {\n beforeTs,\n },\n });\n\n allDiagnostics.push(...diagnostics);\n }\n\n if (allDiagnostics.length === 0) {\n return;\n }\n\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode !== 0) {\n throw new Error(formattedDiagnostics);\n } else {\n log.msg(formattedDiagnostics);\n }\n}\n"]}
1
+ {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA4C;AAE5C,oCAAoC;AACpC,mEAA8D;AAG9D,+CAA6E;AAE7E,qFAA+E;AAC/E,iEAA4D;AAE5D,SAAsB,kBAAkB,CACtC,KAAiB,EACjB,QAAgC,EAChC,qBAA+C,EAC/C,mBAAwC,EACxC,YAA0C,EAC1C,aAA6B;;QA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cesContent":["import * as ng from '@angular/compiler-cli';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport { cacheCompilerHost } from '../ts/cache-compiler-host';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from './ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\nimport { createEmitCallback } from './create-emit-callback';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor: StylesheetProcessor,\n extraOptions?: Partial<ng.CompilerOptions>,\n ngccProcessor?: NgccProcessor,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;\n\n let tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n );\n\n if (tsConfigOptions.enableIvy && ngccProcessor) {\n tsCompilerHost = ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);\n }\n\n // ng.CompilerHost\n const ngCompilerHost = ng.createCompilerHost({\n options: tsConfigOptions,\n tsHost: tsCompilerHost,\n });\n\n const scriptTarget = tsConfigOptions.target;\n const cache = entryPoint.cache;\n const oldProgram = cache.oldPrograms && (cache.oldPrograms[scriptTarget] as ng.Program | undefined);\n\n const ngProgram = ng.createProgram({\n rootNames: tsConfig.rootNames,\n options: tsConfigOptions,\n host: ngCompilerHost,\n oldProgram,\n });\n\n await ngProgram.loadNgStructureAsync();\n\n log.debug(\n `ngc program structure is reused: ${\n oldProgram ? (oldProgram.getTsProgram() as any).structureIsReused : 'No old program'\n }`,\n );\n\n cache.oldPrograms = { ...cache.oldPrograms, [scriptTarget]: ngProgram };\n\n const allDiagnostics = [\n ...ngProgram.getTsOptionDiagnostics(),\n ...ngProgram.getNgOptionDiagnostics(),\n ...ngProgram.getTsSyntacticDiagnostics(),\n ...ngProgram.getTsSemanticDiagnostics(),\n ...ngProgram.getNgSemanticDiagnostics(),\n ...ngProgram.getNgStructuralDiagnostics(),\n ];\n\n // if we have an error we don't want to transpile.\n const hasError = ng.exitCodeFromResult(allDiagnostics) > 0;\n if (!hasError) {\n const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;\n // certain errors are only emitted by a compilation hence append to previous diagnostics\n const { diagnostics } = ngProgram.emit({\n emitFlags,\n // For Ivy we don't need a custom emitCallback to have tsickle transforms\n emitCallback: tsConfigOptions.enableIvy ? undefined : createEmitCallback(tsConfigOptions),\n });\n\n allDiagnostics.push(...diagnostics);\n }\n\n if (allDiagnostics.length === 0) {\n return;\n }\n\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode !== 0) {\n throw new Error(formattedDiagnostics);\n } else {\n log.msg(formattedDiagnostics);\n }\n}\n"]}
@@ -102,6 +102,8 @@ class StylesheetProcessor {
102
102
  postCssPlugins.push(autoprefixer({ overrideBrowserslist, grid: true }));
103
103
  const preset = cssnanoPresetDefault({
104
104
  svgo: false,
105
+ // Disable calc optimizations due to several issues.
106
+ calc: false,
105
107
  });
106
108
  const asyncPlugins = ['postcss-svgo'];
107
109
  const cssNanoPlugins = preset.plugins
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,oCAAoC;AACpC,iDAAyC;AAEzC,YAAY;AACZ,6CAA6C;AAC7C,6CAA6C;AAC7C,kEAAkE;AAClE,mCAAmC;AACnC,0CAA0C;AAC1C,+DAA+D;AAC/D,iCAAiC;AAEjC,I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,CAAC;YACZ;gBACE,OAAO,OAAO,CAAC;SAClB;IACH,CAAC;IAEO,sBAAsB,CAAC,QAAgB,EAAE,MAAe;QAC9D,GAAG,CAAC,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEzE,MAAM,cAAc,GAAG,EAAE,CAAC;QAE1B,IAAI,MAAM,KAAK,MAAM,CAAC,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC;YACnC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;SAClD;QAED,6DAA6D;QAC7D,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAExE,MAAM,MAAM,GAAG,oBAAoB,CAAC;YAClC,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,CAAC,cAAc,CAAC,CAAC;QACtC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO;YACnC,kIAAkI;aACjI,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;aACvD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;QAEpE,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QAEvC,OAAO,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC;CACF;AAlGD,kDAkGC","sourcesContent":["import * as path from 'path';\nimport * as log from '../utils/log';\nimport { execSync } from 'child_process';\n\n// CSS Tools\nimport * as autoprefixer from 'autoprefixer';\nimport * as browserslist from 'browserslist';\nimport * as nodeSassTildeImporter from 'node-sass-tilde-importer';\nimport * as postcss from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport * as cssnanoPresetDefault from 'cssnano-preset-default';\nimport * as stylus from 'stylus';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\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 */\nlet sassComplier: any | undefined;\ntry {\n sassComplier = require('node-sass'); // Check if node-sass is explicitly included.\n} catch {\n sassComplier = require('sass');\n}\n\nexport class StylesheetProcessor {\n private postCssProcessor: postcss.Processor;\n\n constructor(readonly basePath: string, readonly cssUrl?: CssUrl, readonly styleIncludePaths?: string[]) {\n this.postCssProcessor = this.createPostCssProcessor(basePath, cssUrl);\n }\n\n process(filePath: string, content: string) {\n // Render pre-processor language (sass, styl, less)\n const renderedCss: string = this.renderPreProcessor(filePath, content);\n\n // Render postcss (autoprefixing and friends)\n const result = this.postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(path.extname(filePath), '.css'),\n });\n\n // Log warnings from postcss\n result.warnings().forEach((msg) => log.warn(msg.toString()));\n\n return result.css;\n }\n\n private renderPreProcessor(filePath: string, content: string): string {\n const ext = path.extname(filePath);\n\n log.debug(`rendering ${ext} from ${filePath}`);\n\n switch (ext) {\n case '.sass':\n case '.scss':\n return sassComplier\n .renderSync({\n file: filePath,\n data: content,\n indentedSyntax: '.sass' === ext,\n importer: nodeSassTildeImporter,\n includePaths: this.styleIncludePaths,\n })\n .css.toString();\n\n case '.less':\n // this is the only way I found to make LESS sync\n let cmd = `node \"${require.resolve('less/bin/lessc')}\" \"${filePath}\" --js`;\n if (this.styleIncludePaths.length) {\n cmd += ` --include-path=\"${this.styleIncludePaths.join(':')}\"`;\n }\n\n return execSync(cmd).toString();\n\n case '.styl':\n case '.stylus':\n return (\n stylus(content)\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 content;\n }\n }\n\n private createPostCssProcessor(basePath: string, cssUrl?: CssUrl): postcss.Processor {\n log.debug(`determine browserslist for ${basePath}`);\n const overrideBrowserslist = browserslist(undefined, { path: basePath });\n\n const postCssPlugins = [];\n\n if (cssUrl !== CssUrl.none) {\n log.debug(`postcssUrl: ${cssUrl}`);\n postCssPlugins.push(postcssUrl({ url: cssUrl }));\n }\n\n // this is important to be executed post running `postcssUrl`\n postCssPlugins.push(autoprefixer({ overrideBrowserslist, grid: true }));\n\n const preset = cssnanoPresetDefault({\n svgo: false,\n });\n\n const asyncPlugins = ['postcss-svgo'];\n const cssNanoPlugins = preset.plugins\n // replicate the `initializePlugin` behavior from https://github.com/cssnano/cssnano/blob/a566cc5/packages/cssnano/src/index.js#L8\n .map(([creator, pluginConfig]) => creator(pluginConfig))\n .filter((plugin) => !asyncPlugins.includes(plugin.postcssPlugin));\n\n postCssPlugins.push(...cssNanoPlugins);\n\n return postcss(postCssPlugins);\n }\n}\n"]}
1
+ {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,oCAAoC;AACpC,iDAAyC;AAEzC,YAAY;AACZ,6CAA6C;AAC7C,6CAA6C;AAC7C,kEAAkE;AAClE,mCAAmC;AACnC,0CAA0C;AAC1C,+DAA+D;AAC/D,iCAAiC;AAEjC,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,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9D,GAAG,CAAC,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEzE,MAAM,cAAc,GAAG,EAAE,CAAC;QAE1B,IAAI,MAAM,KAAK,MAAM,CAAC,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC;YACnC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;SAClD;QAED,6DAA6D;QAC7D,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAExE,MAAM,MAAM,GAAG,oBAAoB,CAAC;YAClC,IAAI,EAAE,KAAK;YACX,oDAAoD;YACpD,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,CAAC,cAAc,CAAC,CAAC;QACtC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO;YACnC,kIAAkI;aACjI,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;aACvD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;QAEpE,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QAEvC,OAAO,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC;CACF;AApGD,kDAoGC","sourcesContent":["import * as path from 'path';\nimport * as log from '../utils/log';\nimport { execSync } from 'child_process';\n\n// CSS Tools\nimport * as autoprefixer from 'autoprefixer';\nimport * as browserslist from 'browserslist';\nimport * as nodeSassTildeImporter from 'node-sass-tilde-importer';\nimport * as postcss from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport * as cssnanoPresetDefault from 'cssnano-preset-default';\nimport * as stylus from 'stylus';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\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 */\nlet sassComplier: any | undefined;\ntry {\n sassComplier = require('node-sass'); // Check if node-sass is explicitly included.\n} catch {\n sassComplier = require('sass');\n}\n\nexport class StylesheetProcessor {\n private postCssProcessor: postcss.Processor;\n\n constructor(readonly basePath: string, readonly cssUrl?: CssUrl, readonly styleIncludePaths?: string[]) {\n this.postCssProcessor = this.createPostCssProcessor(basePath, cssUrl);\n }\n\n process(filePath: string, content: string) {\n // Render pre-processor language (sass, styl, less)\n const renderedCss: string = this.renderPreProcessor(filePath, content);\n\n // Render postcss (autoprefixing and friends)\n const result = this.postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(path.extname(filePath), '.css'),\n });\n\n // Log warnings from postcss\n result.warnings().forEach((msg) => log.warn(msg.toString()));\n\n return result.css;\n }\n\n private renderPreProcessor(filePath: string, content: string): string {\n const ext = path.extname(filePath);\n\n log.debug(`rendering ${ext} from ${filePath}`);\n\n switch (ext) {\n case '.sass':\n case '.scss':\n return sassComplier\n .renderSync({\n file: filePath,\n data: content,\n indentedSyntax: '.sass' === ext,\n importer: nodeSassTildeImporter,\n includePaths: this.styleIncludePaths,\n })\n .css.toString();\n\n case '.less':\n // this is the only way I found to make LESS sync\n let cmd = `node \"${require.resolve('less/bin/lessc')}\" \"${filePath}\" --js`;\n if (this.styleIncludePaths.length) {\n cmd += ` --include-path=\"${this.styleIncludePaths.join(':')}\"`;\n }\n\n return execSync(cmd).toString();\n\n case '.styl':\n case '.stylus':\n return (\n stylus(content)\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 content;\n }\n }\n\n private createPostCssProcessor(basePath: string, cssUrl?: CssUrl): postcss.Processor {\n log.debug(`determine browserslist for ${basePath}`);\n const overrideBrowserslist = browserslist(undefined, { path: basePath });\n\n const postCssPlugins = [];\n\n if (cssUrl !== CssUrl.none) {\n log.debug(`postcssUrl: ${cssUrl}`);\n postCssPlugins.push(postcssUrl({ url: cssUrl }));\n }\n\n // this is important to be executed post running `postcssUrl`\n postCssPlugins.push(autoprefixer({ overrideBrowserslist, grid: true }));\n\n const preset = cssnanoPresetDefault({\n svgo: false,\n // Disable calc optimizations due to several issues.\n calc: false,\n });\n\n const asyncPlugins = ['postcss-svgo'];\n const cssNanoPlugins = preset.plugins\n // replicate the `initializePlugin` behavior from https://github.com/cssnano/cssnano/blob/a566cc5/packages/cssnano/src/index.js#L8\n .map(([creator, pluginConfig]) => creator(pluginConfig))\n .filter((plugin) => !asyncPlugins.includes(plugin.postcssPlugin));\n\n postCssPlugins.push(...cssNanoPlugins);\n\n return postcss(postCssPlugins);\n }\n}\n"]}
@@ -4,4 +4,4 @@ import { StylesheetProcessor } from '../styles/stylesheet-processor';
4
4
  import { EntryPointNode } from '../ng-package/nodes';
5
5
  import { BuildGraph } from '../graph/build-graph';
6
6
  import { FileCache } from '../file-system/file-cache';
7
- export declare function cacheCompilerHost(graph: BuildGraph, entryPoint: EntryPointNode, compilerOptions: ng.CompilerOptions, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor?: StylesheetProcessor, sourcesFileCache?: FileCache): ng.CompilerHost;
7
+ export declare function cacheCompilerHost(graph: BuildGraph, entryPoint: EntryPointNode, compilerOptions: ng.CompilerOptions, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor?: StylesheetProcessor, sourcesFileCache?: FileCache, setParentNodes?: boolean): ng.CompilerHost;
@@ -7,8 +7,9 @@ const path = require("path");
7
7
  const path_1 = require("../utils/path");
8
8
  const nodes_1 = require("../ng-package/nodes");
9
9
  const node_1 = require("../graph/node");
10
- function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, stylesheetProcessor, sourcesFileCache = entryPoint.cache.sourcesFileCache) {
11
- const compilerHost = ng.createCompilerHost({ options: compilerOptions });
10
+ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, stylesheetProcessor, sourcesFileCache = entryPoint.cache.sourcesFileCache, setParentNodes = true) {
11
+ const tsHost = ts.createCompilerHost(compilerOptions, setParentNodes);
12
+ const compilerHost = ng.createCompilerHost({ options: compilerOptions, tsHost });
12
13
  const getNode = (fileName) => {
13
14
  const nodeUri = nodes_1.fileUrl(path_1.ensureUnixPath(fileName));
14
15
  let node = graph.get(nodeUri);
@@ -1 +1 @@
1
- {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,4CAA4C;AAC5C,6BAA6B;AAC7B,wCAA+C;AAE/C,+CAA8D;AAG9D,wCAAqC;AAErC,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAmC,EACnC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAEzE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,eAAO,CAAC,qBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAA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,UAAU,EACV,qBAAc,CAAC,cAAc,CAAC,EAC9B,eAAe,EACf,YAAY,EACZ,qBAAqB,CACtB,CAAC;gBAEF,OAAO,cAAc,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC,EAED,sBAAsB,EAAE,CAAC,YAAoB,EAAE,kBAA0B,EAAE,EAAE;YAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,YAAY,CAAC,CAAC;YAClF,MAAM,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;YACnD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;YAC3C,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YAEvC,OAAO,YAAY,CAAC;QACtB,CAAC,EAED,YAAY,EAAE,CAAC,QAAgB,EAAE,EAAE;YACjC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAEtB,MAAM,KAAK,GAAG,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACrD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC/B,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC3D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACnD,KAAK,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACtE;gBACD,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;aACrB;YAED,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC,IACD;AACJ,CAAC;AAjID,8CAiIC","sourcesContent":["import * as ts from 'typescript';\nimport * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport { ensureUnixPath } from '../utils/path';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { BuildGraph } from '../graph/build-graph';\nimport { FileCache } from '../file-system/file-cache';\nimport { Node } from '../graph/node';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: ng.CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): ng.CompilerHost {\n const compilerHost = ng.createCompilerHost({ options: compilerOptions });\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.endsWith('.d.ts')) {\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n return cache.content;\n },\n\n // ng specific\n moduleNameToFileName: (moduleName: string, containingFile: string) => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule && resolvedModule.resolvedFileName;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n if (!/(html|htm|svg)$/.test(path.extname(fileName))) {\n cache.content = stylesheetProcessor.process(fileName, cache.content);\n }\n cache.exists = true;\n }\n\n return cache.content;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,4CAA4C;AAC5C,6BAA6B;AAC7B,wCAA+C;AAE/C,+CAA8D;AAG9D,wCAAqC;AAErC,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAmC,EACnC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB,EAC/D,cAAc,GAAG,IAAI;IAErB,MAAM,MAAM,GAAG,EAAE,CAA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,CAAC,EAAE;oBACnD,KAAK,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACtE;gBACD,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;aACrB;YAED,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC,IACD;AACJ,CAAC;AAlID,8CAkIC","sourcesContent":["import * as ts from 'typescript';\nimport * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport { ensureUnixPath } from '../utils/path';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { BuildGraph } from '../graph/build-graph';\nimport { FileCache } from '../file-system/file-cache';\nimport { Node } from '../graph/node';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: ng.CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n setParentNodes = true,\n): ng.CompilerHost {\n const tsHost = ts.createCompilerHost(compilerOptions, setParentNodes);\n const compilerHost = ng.createCompilerHost({ options: compilerOptions, tsHost });\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.endsWith('.d.ts')) {\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n return cache.content;\n },\n\n // ng specific\n moduleNameToFileName: (moduleName: string, containingFile: string) => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule && resolvedModule.resolvedFileName;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n if (!/(html|htm|svg)$/.test(path.extname(fileName))) {\n cache.content = stylesheetProcessor.process(fileName, cache.content);\n }\n cache.exists = true;\n }\n\n return cache.content;\n },\n };\n}\n"]}
@@ -68,7 +68,7 @@ exports.initializeTsConfig = (defaultTsConfig, entryPoints) => {
68
68
  if (defaultTsConfig.errors.length > 0) {
69
69
  throw ng.formatDiagnostics(defaultTsConfig.errors);
70
70
  }
71
- entryPoints.forEach((currentEntryPoint) => {
71
+ entryPoints.forEach(currentEntryPoint => {
72
72
  const { entryPoint } = currentEntryPoint.data;
73
73
  log.debug(`Initializing tsconfig for ${entryPoint.moduleId}`);
74
74
  const basePath = path.dirname(entryPoint.entryFilePath);
@@ -79,8 +79,6 @@ exports.initializeTsConfig = (defaultTsConfig, entryPoints) => {
79
79
  flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,
80
80
  basePath,
81
81
  rootDir: basePath,
82
- declarationDir: basePath,
83
- sourceRoot: `ng://${entryPoint.moduleId}`,
84
82
  };
85
83
  tsConfig.rootNames = [entryPoint.entryFilePath];
86
84
  tsConfig.options = Object.assign(Object.assign({}, tsConfig.options), overrideOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,6BAA6B;AAC7B,iCAAiC;AAEjC,oCAAoC;AAEpC;;GAEG;AACH,SAAgB,mBAAmB,CAAC,QAAiB;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;KACjE;IAED,8BAA8B;IAC9B,MAAM,YAAY,GAAuB;QACvC,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM;QAChD,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,sBAAsB,EAAE,IAAI;QAE5B,aAAa;QACb,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QAErB,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,IAAI;QAEjB,y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,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 * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { EntryPointNode } from '../ng-package/nodes';\nimport * as log from '../utils/log';\n\n/**\n * Reads the default TypeScript configuration.\n */\nexport function readDefaultTsConfig(fileName?: string): ng.ParsedConfiguration {\n if (!fileName) {\n fileName = path.resolve(__dirname, 'conf', 'tsconfig.ngc.json');\n }\n\n // these options are mandatory\n const extraOptions: ng.CompilerOptions = {\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n target: ts.ScriptTarget.ES2015,\n experimentalDecorators: true,\n\n // sourcemaps\n sourceMap: false,\n inlineSources: true,\n inlineSourceMap: true,\n\n outDir: '',\n declaration: true,\n\n // ng compiler to options\n enableResourceInlining: true,\n\n // these are required to set the appropriate EmitFlags\n flatModuleId: 'AUTOGENERATED',\n flatModuleOutFile: 'AUTOGENERATED',\n };\n\n const config = ng.readConfiguration(fileName, extraOptions);\n const options = config.options;\n\n // todo: alanagius4 - the below shouldn't be needed but it seems that setting it only in create-emit-callback.ts\n // is not working correctly\n const transformDecorators = !options.enableIvy && options.annotationsAs !== 'decorators';\n if ((options.annotateForClosureCompiler || options.annotationsAs === 'static fields') && transformDecorators) {\n // This is needed as a workaround for https://github.com/angular/tsickle/issues/635\n // Otherwise tsickle might emit references to non imported values\n // as TypeScript elided the import.\n options.emitDecoratorMetadata = true;\n }\n\n return config;\n}\n\n/**\n * Creates a parsed TypeScript configuration object.\n *\n * @param values File path or parsed configuration.\n */\nexport function createDefaultTsConfig(values?: ng.ParsedConfiguration | string): ng.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 const initializeTsConfig = (defaultTsConfig: ng.ParsedConfiguration, entryPoints: EntryPointNode[]) => {\n if (defaultTsConfig.errors.length > 0) {\n throw ng.formatDiagnostics(defaultTsConfig.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 let tsConfig: ng.ParsedConfiguration = JSON.parse(JSON.stringify(defaultTsConfig));\n\n const overrideOptions: ng.CompilerOptions = {\n flatModuleId: entryPoint.moduleId,\n flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,\n basePath,\n rootDir: basePath,\n declarationDir: basePath,\n sourceRoot: `ng://${entryPoint.moduleId}`,\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: ng.ParsedConfiguration,\n entryPoints: EntryPointNode[],\n pointToSource = false,\n): ng.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 (let 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"]}
1
+ {"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,6BAA6B;AAC7B,iCAAiC;AAEjC,oCAAoC;AAEpC;;GAEG;AACH,SAAgB,mBAAmB,CAAC,QAAiB;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;KACjE;IAED,8BAA8B;IAC9B,MAAM,YAAY,GAAuB;QACvC,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM;QAChD,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,sBAAsB,EAAE,IAAI;QAE5B,aAAa;QACb,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QAErB,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,IAAI;QAEjB,yBAAyB;QACzB,sBAAsB,EAAE,IAAI;QAE5B,sDAAsD;QACtD,YAAY,EAAE,eAAe;QAC7B,iBAAiB,EAAE,eAAe;KACnC,CAAC;IAEF,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,OAA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AAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;SACzD;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzBD,oEAyBC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { EntryPointNode } from '../ng-package/nodes';\nimport * as log from '../utils/log';\n\n/**\n * Reads the default TypeScript configuration.\n */\nexport function readDefaultTsConfig(fileName?: string): ng.ParsedConfiguration {\n if (!fileName) {\n fileName = path.resolve(__dirname, 'conf', 'tsconfig.ngc.json');\n }\n\n // these options are mandatory\n const extraOptions: ng.CompilerOptions = {\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n target: ts.ScriptTarget.ES2015,\n experimentalDecorators: true,\n\n // sourcemaps\n sourceMap: false,\n inlineSources: true,\n inlineSourceMap: true,\n\n outDir: '',\n declaration: true,\n\n // ng compiler to options\n enableResourceInlining: true,\n\n // these are required to set the appropriate EmitFlags\n flatModuleId: 'AUTOGENERATED',\n flatModuleOutFile: 'AUTOGENERATED',\n };\n\n const config = ng.readConfiguration(fileName, extraOptions);\n const options = config.options;\n\n // todo: alanagius4 - the below shouldn't be needed but it seems that setting it only in create-emit-callback.ts\n // is not working correctly\n const transformDecorators = !options.enableIvy && options.annotationsAs !== 'decorators';\n if ((options.annotateForClosureCompiler || options.annotationsAs === 'static fields') && transformDecorators) {\n // This is needed as a workaround for https://github.com/angular/tsickle/issues/635\n // Otherwise tsickle might emit references to non imported values\n // as TypeScript elided the import.\n options.emitDecoratorMetadata = true;\n }\n\n return config;\n}\n\n/**\n * Creates a parsed TypeScript configuration object.\n *\n * @param values File path or parsed configuration.\n */\nexport function createDefaultTsConfig(values?: ng.ParsedConfiguration | string): ng.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 const initializeTsConfig = (defaultTsConfig: ng.ParsedConfiguration, entryPoints: EntryPointNode[]) => {\n if (defaultTsConfig.errors.length > 0) {\n throw ng.formatDiagnostics(defaultTsConfig.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 let tsConfig: ng.ParsedConfiguration = JSON.parse(JSON.stringify(defaultTsConfig));\n\n const overrideOptions: ng.CompilerOptions = {\n flatModuleId: entryPoint.moduleId,\n flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,\n basePath,\n rootDir: basePath,\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: ng.ParsedConfiguration,\n entryPoints: EntryPointNode[],\n pointToSource = false,\n): ng.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 (let 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "10.0.0-next.2",
3
+ "version": "10.0.0",
4
4
  "description": "Compile and package a TypeScript library to Angular Package Format",
5
5
  "keywords": [
6
6
  "angular",
@@ -27,9 +27,9 @@
27
27
  "main": "./public_api.js",
28
28
  "typings": "./public_api.d.ts",
29
29
  "dependencies": {
30
- "@rollup/plugin-commonjs": "^11.0.2",
30
+ "@rollup/plugin-commonjs": "^13.0.0",
31
31
  "@rollup/plugin-json": "^4.0.0",
32
- "@rollup/plugin-node-resolve": "^7.1.0",
32
+ "@rollup/plugin-node-resolve": "^8.0.0",
33
33
  "ajv": "^6.10.2",
34
34
  "autoprefixer": "^9.6.5",
35
35
  "browserslist": "^4.7.0",
@@ -55,8 +55,8 @@
55
55
  "update-notifier": "^4.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@angular/compiler": "^10.0.0-next.8",
59
- "@angular/compiler-cli": "^10.0.0-next.8",
58
+ "@angular/compiler": "^10.0.0-rc.3",
59
+ "@angular/compiler-cli": "^10.0.0-rc.3",
60
60
  "tslib": "^2.0.0",
61
61
  "typescript": ">=3.9 < 3.10"
62
62
  },
package/public_api.js CHANGED
@@ -8,7 +8,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
11
+ };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  /**
14
14
  * Commands API
@@ -1,13 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import * as ts from 'typescript';
9
- export declare function downlevelConstructorParameters(getTypeChecker: () => ts.TypeChecker): ts.TransformerFactory<ts.SourceFile>;
10
- /**
11
- * Transformer factory for the decorator downlevel transformer. See fileoverview for details.
12
- */
13
- export declare function decoratorDownlevelTransformer(typeChecker: ts.TypeChecker, diagnostics: ts.Diagnostic[]): (context: ts.TransformationContext) => ts.Transformer<ts.SourceFile>;
@@ -1,245 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decoratorDownlevelTransformer = exports.downlevelConstructorParameters = void 0;
4
- /**
5
- * @license
6
- * Copyright Google Inc. All Rights Reserved.
7
- *
8
- * Use of this source code is governed by an MIT-style license that can be
9
- * found in the LICENSE file at https://angular.io/license
10
- */
11
- const ts = require("typescript");
12
- function downlevelConstructorParameters(getTypeChecker) {
13
- return (context) => {
14
- const transformer = decoratorDownlevelTransformer(getTypeChecker(), []);
15
- return transformer(context);
16
- };
17
- }
18
- exports.downlevelConstructorParameters = downlevelConstructorParameters;
19
- // The following is sourced from tsickle with local modifications
20
- // Only the creation of `ctorParameters` is retained
21
- // https://github.com/angular/tsickle/blob/0ceb7d6bc47f6945a6c4c09689f1388eb48f5c07/src/decorator_downlevel_transformer.ts
22
- //
23
- /**
24
- * Extracts the type of the decorator (the function or expression invoked), as well as all the
25
- * arguments passed to the decorator. Returns an AST with the form:
26
- *
27
- * // For @decorator(arg1, arg2)
28
- * { type: decorator, args: [arg1, arg2] }
29
- */
30
- function extractMetadataFromSingleDecorator(decorator, diagnostics) {
31
- const metadataProperties = [];
32
- const expr = decorator.expression;
33
- switch (expr.kind) {
34
- case ts.SyntaxKind.Identifier:
35
- // The decorator was a plain @Foo.
36
- metadataProperties.push(ts.createPropertyAssignment('type', expr));
37
- break;
38
- case ts.SyntaxKind.CallExpression:
39
- // The decorator was a call, like @Foo(bar).
40
- const call = expr;
41
- metadataProperties.push(ts.createPropertyAssignment('type', call.expression));
42
- if (call.arguments.length) {
43
- const args = [];
44
- for (const arg of call.arguments) {
45
- args.push(arg);
46
- }
47
- const argsArrayLiteral = ts.createArrayLiteral(args);
48
- argsArrayLiteral.elements.hasTrailingComma = true;
49
- metadataProperties.push(ts.createPropertyAssignment('args', argsArrayLiteral));
50
- }
51
- break;
52
- default:
53
- diagnostics.push({
54
- file: decorator.getSourceFile(),
55
- start: decorator.getStart(),
56
- length: decorator.getEnd() - decorator.getStart(),
57
- messageText: `${ts.SyntaxKind[decorator.kind]} not implemented in gathering decorator metadata`,
58
- category: ts.DiagnosticCategory.Error,
59
- code: 0,
60
- });
61
- break;
62
- }
63
- return ts.createObjectLiteral(metadataProperties);
64
- }
65
- /**
66
- * createCtorParametersClassProperty creates a static 'ctorParameters' property containing
67
- * downleveled decorator information.
68
- *
69
- * The property contains an arrow function that returns an array of object literals of the shape:
70
- * static ctorParameters = () => [{
71
- * type: SomeClass|undefined, // the type of the param that's decorated, if it's a value.
72
- * decorators: [{
73
- * type: DecoratorFn, // the type of the decorator that's invoked.
74
- * args: [ARGS], // the arguments passed to the decorator.
75
- * }]
76
- * }];
77
- */
78
- function createCtorParametersClassProperty(diagnostics, entityNameToExpression, ctorParameters, typeChecker) {
79
- const params = [];
80
- for (const ctorParam of ctorParameters) {
81
- if (!ctorParam.type && ctorParam.decorators.length === 0) {
82
- params.push(ts.createNull());
83
- continue;
84
- }
85
- const paramType = ctorParam.type
86
- ? typeReferenceToExpression(entityNameToExpression, ctorParam.type, typeChecker)
87
- : undefined;
88
- const members = [ts.createPropertyAssignment('type', paramType || ts.createIdentifier('undefined'))];
89
- const decorators = [];
90
- for (const deco of ctorParam.decorators) {
91
- decorators.push(extractMetadataFromSingleDecorator(deco, diagnostics));
92
- }
93
- if (decorators.length) {
94
- members.push(ts.createPropertyAssignment('decorators', ts.createArrayLiteral(decorators)));
95
- }
96
- params.push(ts.createObjectLiteral(members));
97
- }
98
- const initializer = ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.createArrayLiteral(params, true));
99
- const ctorProp = ts.createProperty(undefined, [ts.createToken(ts.SyntaxKind.StaticKeyword)], 'ctorParameters', undefined, undefined, initializer);
100
- return ctorProp;
101
- }
102
- /**
103
- * Returns an expression representing the (potentially) value part for the given node.
104
- *
105
- * This is a partial re-implementation of TypeScript's serializeTypeReferenceNode. This is a
106
- * workaround for https://github.com/Microsoft/TypeScript/issues/17516 (serializeTypeReferenceNode
107
- * not being exposed). In practice this implementation is sufficient for Angular's use of type
108
- * metadata.
109
- */
110
- function typeReferenceToExpression(entityNameToExpression, node, typeChecker) {
111
- let kind = node.kind;
112
- if (ts.isLiteralTypeNode(node)) {
113
- // Treat literal types like their base type (boolean, string, number).
114
- kind = node.literal.kind;
115
- }
116
- switch (kind) {
117
- case ts.SyntaxKind.FunctionType:
118
- case ts.SyntaxKind.ConstructorType:
119
- return ts.createIdentifier('Function');
120
- case ts.SyntaxKind.ArrayType:
121
- case ts.SyntaxKind.TupleType:
122
- return ts.createIdentifier('Array');
123
- case ts.SyntaxKind.TypePredicate:
124
- case ts.SyntaxKind.TrueKeyword:
125
- case ts.SyntaxKind.FalseKeyword:
126
- case ts.SyntaxKind.BooleanKeyword:
127
- return ts.createIdentifier('Boolean');
128
- case ts.SyntaxKind.StringLiteral:
129
- case ts.SyntaxKind.StringKeyword:
130
- return ts.createIdentifier('String');
131
- case ts.SyntaxKind.ObjectKeyword:
132
- return ts.createIdentifier('Object');
133
- case ts.SyntaxKind.NumberKeyword:
134
- case ts.SyntaxKind.NumericLiteral:
135
- return ts.createIdentifier('Number');
136
- case ts.SyntaxKind.UnionType:
137
- const childTypeNodes = node.types.filter(t => t.kind !== ts.SyntaxKind.NullKeyword);
138
- return childTypeNodes.length === 1
139
- ? typeReferenceToExpression(entityNameToExpression, childTypeNodes[0], typeChecker)
140
- : undefined;
141
- case ts.SyntaxKind.TypeReference:
142
- const typeRef = node;
143
- let typeSymbol = typeChecker.getSymbolAtLocation(typeRef.typeName);
144
- if (typeSymbol && typeSymbol.flags & ts.SymbolFlags.Alias) {
145
- typeSymbol = typeChecker.getAliasedSymbol(typeSymbol);
146
- }
147
- if (!typeSymbol || !(typeSymbol.flags & ts.SymbolFlags.Value)) {
148
- return undefined;
149
- }
150
- const type = typeChecker.getTypeOfSymbolAtLocation(typeSymbol, typeRef);
151
- if (!type || typeChecker.getSignaturesOfType(type, ts.SignatureKind.Construct).length === 0) {
152
- return undefined;
153
- }
154
- // Ignore any generic types, just return the base type.
155
- return entityNameToExpression(typeRef.typeName);
156
- default:
157
- return undefined;
158
- }
159
- }
160
- /**
161
- * Transformer factory for the decorator downlevel transformer. See fileoverview for details.
162
- */
163
- function decoratorDownlevelTransformer(typeChecker, diagnostics) {
164
- return (context) => {
165
- const parameterTypeSymbols = new Set();
166
- /**
167
- * Converts an EntityName (from a type annotation) to an expression (accessing a value).
168
- *
169
- * For a given ts.EntityName, this walks depth first to find the leftmost ts.Identifier, then
170
- * converts the path into property accesses.
171
- *
172
- */
173
- function entityNameToExpression(name) {
174
- if (ts.isIdentifier(name)) {
175
- const typeSymbol = typeChecker.getSymbolAtLocation(name);
176
- if (typeSymbol) {
177
- parameterTypeSymbols.add(typeSymbol);
178
- }
179
- // Based on TS's strategy to allow the checker to reach this identifier
180
- // tslint:disable-next-line:max-line-length
181
- // https://github.com/microsoft/TypeScript/blob/7f47a08a5e9874f0f97a667bd81eebddec61247c/src/compiler/transformers/ts.ts#L2093
182
- const exp = ts.getMutableClone(name);
183
- exp.flags &= ~ts.NodeFlags.Synthesized;
184
- exp.original = undefined;
185
- exp.parent = ts.getParseTreeNode(name.getSourceFile());
186
- return exp;
187
- }
188
- const ref = entityNameToExpression(name.left);
189
- if (!ref) {
190
- return undefined;
191
- }
192
- return ts.createPropertyAccess(ref, name.right);
193
- }
194
- function classMemberVisitor(node) {
195
- if (!ts.isConstructorDeclaration(node) || !node.body) {
196
- return visitor(node);
197
- }
198
- const parametersInfo = [];
199
- for (const param of node.parameters) {
200
- const paramInfo = { decorators: [], type: null };
201
- for (const decorator of param.decorators || []) {
202
- paramInfo.decorators.push(decorator);
203
- }
204
- if (param.type) {
205
- // param has a type provided, e.g. "foo: Bar".
206
- // The type will be emitted as a value expression in entityNameToExpression, which takes
207
- // care not to emit anything for types that cannot be expressed as a value (e.g.
208
- // interfaces).
209
- paramInfo.type = param.type;
210
- }
211
- parametersInfo.push(paramInfo);
212
- }
213
- if (parametersInfo.length > 0) {
214
- const ctorProperty = createCtorParametersClassProperty(diagnostics, entityNameToExpression, parametersInfo, typeChecker);
215
- return [node, ctorProperty];
216
- }
217
- else {
218
- return node;
219
- }
220
- }
221
- function visitor(node) {
222
- if (ts.isClassDeclaration(node) && node.decorators && node.decorators.length > 0) {
223
- return ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.visitNodes(node.members, classMemberVisitor));
224
- }
225
- else {
226
- return ts.visitEachChild(node, visitor, context);
227
- }
228
- }
229
- return (sf) => {
230
- parameterTypeSymbols.clear();
231
- return ts.visitEachChild(visitor(sf), function visitImports(node) {
232
- if ((ts.isImportSpecifier(node) || ts.isNamespaceImport(node) || ts.isImportClause(node)) && node.name) {
233
- const importSymbol = typeChecker.getSymbolAtLocation(node.name);
234
- if (importSymbol && parameterTypeSymbols.has(importSymbol)) {
235
- // Using a clone prevents TS from removing the import specifier
236
- return ts.getMutableClone(node);
237
- }
238
- }
239
- return ts.visitEachChild(node, visitImports, context);
240
- }, context);
241
- };
242
- };
243
- }
244
- exports.decoratorDownlevelTransformer = decoratorDownlevelTransformer;
245
- //# sourceMappingURL=ctor-parameters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ctor-parameters.js","sourceRoot":"","sources":["../../../src/lib/ts/ctor-parameters.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,iCAAiC;AAEjC,SAAgB,8BAA8B,CAC5C,cAAoC;IAEpC,OAAO,CAAC,OAAiC,EAAE,EAAE;QAC3C,MAAM,WAAW,GAAG,6BAA6B,CAAC,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QAExE,OAAO,WAAW,CAAC,OAAO,CAA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AC;YACxD,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA/GD,sEA+GC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport * as ts from 'typescript';\n\nexport function downlevelConstructorParameters(\n getTypeChecker: () => ts.TypeChecker,\n): ts.TransformerFactory<ts.SourceFile> {\n return (context: ts.TransformationContext) => {\n const transformer = decoratorDownlevelTransformer(getTypeChecker(), []);\n\n return transformer(context);\n };\n}\n\n// The following is sourced from tsickle with local modifications\n// Only the creation of `ctorParameters` is retained\n// https://github.com/angular/tsickle/blob/0ceb7d6bc47f6945a6c4c09689f1388eb48f5c07/src/decorator_downlevel_transformer.ts\n//\n\n/**\n * Extracts the type of the decorator (the function or expression invoked), as well as all the\n * arguments passed to the decorator. Returns an AST with the form:\n *\n * // For @decorator(arg1, arg2)\n * { type: decorator, args: [arg1, arg2] }\n */\nfunction extractMetadataFromSingleDecorator(\n decorator: ts.Decorator,\n diagnostics: ts.Diagnostic[],\n): ts.ObjectLiteralExpression {\n const metadataProperties: ts.ObjectLiteralElementLike[] = [];\n const expr = decorator.expression;\n switch (expr.kind) {\n case ts.SyntaxKind.Identifier:\n // The decorator was a plain @Foo.\n metadataProperties.push(ts.createPropertyAssignment('type', expr));\n break;\n case ts.SyntaxKind.CallExpression:\n // The decorator was a call, like @Foo(bar).\n const call = expr as ts.CallExpression;\n metadataProperties.push(ts.createPropertyAssignment('type', call.expression));\n if (call.arguments.length) {\n const args: ts.Expression[] = [];\n for (const arg of call.arguments) {\n args.push(arg);\n }\n const argsArrayLiteral = ts.createArrayLiteral(args);\n argsArrayLiteral.elements.hasTrailingComma = true;\n metadataProperties.push(ts.createPropertyAssignment('args', argsArrayLiteral));\n }\n break;\n default:\n diagnostics.push({\n file: decorator.getSourceFile(),\n start: decorator.getStart(),\n length: decorator.getEnd() - decorator.getStart(),\n messageText: `${ts.SyntaxKind[decorator.kind]} not implemented in gathering decorator metadata`,\n category: ts.DiagnosticCategory.Error,\n code: 0,\n });\n break;\n }\n return ts.createObjectLiteral(metadataProperties);\n}\n\n/**\n * createCtorParametersClassProperty creates a static 'ctorParameters' property containing\n * downleveled decorator information.\n *\n * The property contains an arrow function that returns an array of object literals of the shape:\n * static ctorParameters = () => [{\n * type: SomeClass|undefined, // the type of the param that's decorated, if it's a value.\n * decorators: [{\n * type: DecoratorFn, // the type of the decorator that's invoked.\n * args: [ARGS], // the arguments passed to the decorator.\n * }]\n * }];\n */\nfunction createCtorParametersClassProperty(\n diagnostics: ts.Diagnostic[],\n entityNameToExpression: (n: ts.EntityName) => ts.Expression | undefined,\n ctorParameters: ParameterDecorationInfo[],\n typeChecker: ts.TypeChecker,\n): ts.PropertyDeclaration {\n const params: ts.Expression[] = [];\n\n for (const ctorParam of ctorParameters) {\n if (!ctorParam.type && ctorParam.decorators.length === 0) {\n params.push(ts.createNull());\n continue;\n }\n\n const paramType = ctorParam.type\n ? typeReferenceToExpression(entityNameToExpression, ctorParam.type, typeChecker)\n : undefined;\n const members = [ts.createPropertyAssignment('type', paramType || ts.createIdentifier('undefined'))];\n\n const decorators: ts.ObjectLiteralExpression[] = [];\n for (const deco of ctorParam.decorators) {\n decorators.push(extractMetadataFromSingleDecorator(deco, diagnostics));\n }\n if (decorators.length) {\n members.push(ts.createPropertyAssignment('decorators', ts.createArrayLiteral(decorators)));\n }\n params.push(ts.createObjectLiteral(members));\n }\n\n const initializer = ts.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.createArrayLiteral(params, true),\n );\n\n const ctorProp = ts.createProperty(\n undefined,\n [ts.createToken(ts.SyntaxKind.StaticKeyword)],\n 'ctorParameters',\n undefined,\n undefined,\n initializer,\n );\n\n return ctorProp;\n}\n\n/**\n * Returns an expression representing the (potentially) value part for the given node.\n *\n * This is a partial re-implementation of TypeScript's serializeTypeReferenceNode. This is a\n * workaround for https://github.com/Microsoft/TypeScript/issues/17516 (serializeTypeReferenceNode\n * not being exposed). In practice this implementation is sufficient for Angular's use of type\n * metadata.\n */\nfunction typeReferenceToExpression(\n entityNameToExpression: (n: ts.EntityName) => ts.Expression | undefined,\n node: ts.TypeNode,\n typeChecker: ts.TypeChecker,\n): ts.Expression | undefined {\n let kind = node.kind;\n if (ts.isLiteralTypeNode(node)) {\n // Treat literal types like their base type (boolean, string, number).\n kind = node.literal.kind;\n }\n switch (kind) {\n case ts.SyntaxKind.FunctionType:\n case ts.SyntaxKind.ConstructorType:\n return ts.createIdentifier('Function');\n case ts.SyntaxKind.ArrayType:\n case ts.SyntaxKind.TupleType:\n return ts.createIdentifier('Array');\n case ts.SyntaxKind.TypePredicate:\n case ts.SyntaxKind.TrueKeyword:\n case ts.SyntaxKind.FalseKeyword:\n case ts.SyntaxKind.BooleanKeyword:\n return ts.createIdentifier('Boolean');\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.StringKeyword:\n return ts.createIdentifier('String');\n case ts.SyntaxKind.ObjectKeyword:\n return ts.createIdentifier('Object');\n case ts.SyntaxKind.NumberKeyword:\n case ts.SyntaxKind.NumericLiteral:\n return ts.createIdentifier('Number');\n case ts.SyntaxKind.UnionType:\n const childTypeNodes = (node as ts.UnionTypeNode).types.filter(t => t.kind !== ts.SyntaxKind.NullKeyword);\n\n return childTypeNodes.length === 1\n ? typeReferenceToExpression(entityNameToExpression, childTypeNodes[0], typeChecker)\n : undefined;\n case ts.SyntaxKind.TypeReference:\n const typeRef = node as ts.TypeReferenceNode;\n let typeSymbol = typeChecker.getSymbolAtLocation(typeRef.typeName);\n if (typeSymbol && typeSymbol.flags & ts.SymbolFlags.Alias) {\n typeSymbol = typeChecker.getAliasedSymbol(typeSymbol);\n }\n\n if (!typeSymbol || !(typeSymbol.flags & ts.SymbolFlags.Value)) {\n return undefined;\n }\n\n const type = typeChecker.getTypeOfSymbolAtLocation(typeSymbol, typeRef);\n if (!type || typeChecker.getSignaturesOfType(type, ts.SignatureKind.Construct).length === 0) {\n return undefined;\n }\n\n // Ignore any generic types, just return the base type.\n return entityNameToExpression(typeRef.typeName);\n default:\n return undefined;\n }\n}\n\n/** ParameterDecorationInfo describes the information for a single constructor parameter. */\ninterface ParameterDecorationInfo {\n /**\n * The type declaration for the parameter. Only set if the type is a value (e.g. a class, not an\n * interface).\n */\n type: ts.TypeNode | null;\n /** The list of decorators found on the parameter, null if none. */\n decorators: ts.Decorator[];\n}\n\n/**\n * Transformer factory for the decorator downlevel transformer. See fileoverview for details.\n */\nexport function decoratorDownlevelTransformer(\n typeChecker: ts.TypeChecker,\n diagnostics: ts.Diagnostic[],\n): (context: ts.TransformationContext) => ts.Transformer<ts.SourceFile> {\n return (context: ts.TransformationContext) => {\n const parameterTypeSymbols = new Set<ts.Symbol>();\n\n /**\n * Converts an EntityName (from a type annotation) to an expression (accessing a value).\n *\n * For a given ts.EntityName, this walks depth first to find the leftmost ts.Identifier, then\n * converts the path into property accesses.\n *\n */\n function entityNameToExpression(name: ts.EntityName): ts.Expression | undefined {\n if (ts.isIdentifier(name)) {\n const typeSymbol = typeChecker.getSymbolAtLocation(name);\n if (typeSymbol) {\n parameterTypeSymbols.add(typeSymbol);\n }\n\n // Based on TS's strategy to allow the checker to reach this identifier\n // tslint:disable-next-line:max-line-length\n // https://github.com/microsoft/TypeScript/blob/7f47a08a5e9874f0f97a667bd81eebddec61247c/src/compiler/transformers/ts.ts#L2093\n const exp = ts.getMutableClone(name);\n exp.flags &= ~ts.NodeFlags.Synthesized;\n ((exp as unknown) as { original: undefined }).original = undefined;\n exp.parent = ts.getParseTreeNode(name.getSourceFile());\n\n return exp;\n }\n const ref = entityNameToExpression(name.left);\n if (!ref) {\n return undefined;\n }\n\n return ts.createPropertyAccess(ref, name.right);\n }\n\n function classMemberVisitor(node: ts.Node): ts.VisitResult<ts.Node> {\n if (!ts.isConstructorDeclaration(node) || !node.body) {\n return visitor(node);\n }\n\n const parametersInfo: ParameterDecorationInfo[] = [];\n for (const param of node.parameters) {\n const paramInfo: ParameterDecorationInfo = { decorators: [], type: null };\n\n for (const decorator of param.decorators || []) {\n paramInfo.decorators.push(decorator);\n }\n if (param.type) {\n // param has a type provided, e.g. \"foo: Bar\".\n // The type will be emitted as a value expression in entityNameToExpression, which takes\n // care not to emit anything for types that cannot be expressed as a value (e.g.\n // interfaces).\n paramInfo.type = param.type;\n }\n parametersInfo.push(paramInfo);\n }\n\n if (parametersInfo.length > 0) {\n const ctorProperty = createCtorParametersClassProperty(\n diagnostics,\n entityNameToExpression,\n parametersInfo,\n typeChecker,\n );\n\n return [node, ctorProperty];\n } else {\n return node;\n }\n }\n\n function visitor<T extends ts.Node>(node: T): ts.Node {\n if (ts.isClassDeclaration(node) && node.decorators && node.decorators.length > 0) {\n return ts.updateClassDeclaration(\n node,\n node.decorators,\n node.modifiers,\n node.name,\n node.typeParameters,\n node.heritageClauses,\n ts.visitNodes(node.members, classMemberVisitor),\n );\n } else {\n return ts.visitEachChild(node, visitor, context);\n }\n }\n\n return (sf: ts.SourceFile) => {\n parameterTypeSymbols.clear();\n\n return ts.visitEachChild(\n visitor(sf) as ts.SourceFile,\n function visitImports(node: ts.Node): ts.Node {\n if ((ts.isImportSpecifier(node) || ts.isNamespaceImport(node) || ts.isImportClause(node)) && node.name) {\n const importSymbol = typeChecker.getSymbolAtLocation(node.name);\n if (importSymbol && parameterTypeSymbols.has(importSymbol)) {\n // Using a clone prevents TS from removing the import specifier\n return ts.getMutableClone(node);\n }\n }\n\n return ts.visitEachChild(node, visitImports, context);\n },\n context,\n );\n };\n };\n}\n"]}
@@ -1,9 +0,0 @@
1
- import * as ts from 'typescript';
2
- /**
3
- * Returns a TypeScript compiler host that redirects `writeFile` output to the given `declarationDir`.
4
- *
5
- * @param compilerHost Original compiler host
6
- * @param baseDir Project base directory
7
- * @param declarationDir Declarations target directory
8
- */
9
- export declare function redirectWriteFileCompilerHost(compilerHost: ts.CompilerHost, baseDir: string, declarationDir: string): ts.CompilerHost;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redirectWriteFileCompilerHost = void 0;
4
- const path = require("path");
5
- /**
6
- * Returns a TypeScript compiler host that redirects `writeFile` output to the given `declarationDir`.
7
- *
8
- * @param compilerHost Original compiler host
9
- * @param baseDir Project base directory
10
- * @param declarationDir Declarations target directory
11
- */
12
- function redirectWriteFileCompilerHost(compilerHost, baseDir, declarationDir) {
13
- return Object.assign(Object.assign({}, compilerHost), { writeFile: (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
14
- let filePath = fileName;
15
- if (/(\.d\.ts|\.metadata\.json)$/.test(fileName)) {
16
- const projectRelativePath = path.relative(baseDir, fileName);
17
- filePath = path.resolve(declarationDir, projectRelativePath);
18
- }
19
- compilerHost.writeFile.call(this, filePath, data, writeByteOrderMark, onError, sourceFiles);
20
- } });
21
- }
22
- exports.redirectWriteFileCompilerHost = redirectWriteFileCompilerHost;
23
- //# sourceMappingURL=redirect-write-file-compiler-host.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redirect-write-file-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/redirect-write-file-compiler-host.ts"],"names":[],"mappings":";;;AACA,6BAA6B;AAE7B;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAC3C,YAA6B,EAC7B,OAAe,EACf,cAAsB;IAEtB,uCACK,YAAY,KACf,SAAS,EAAE,CACT,QAAgB,EAChB,IAAY,EACZ,kBAA2B,EAC3B,OAAmC,EACnC,WAA0C,EAC1C,EAAE;YACF,IAAI,QAAQ,GAAG,QAAQ,CAAC;YACxB,IAAI,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAChD,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAC7D,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;aAC9D;YACD,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAC9F,CAAC,IACD;AACJ,CAAC;AAtBD,sEAsBC","sourcesContent":["import * as ts from 'typescript';\nimport * as path from 'path';\n\n/**\n * Returns a TypeScript compiler host that redirects `writeFile` output to the given `declarationDir`.\n *\n * @param compilerHost Original compiler host\n * @param baseDir Project base directory\n * @param declarationDir Declarations target directory\n */\nexport function redirectWriteFileCompilerHost(\n compilerHost: ts.CompilerHost,\n baseDir: string,\n declarationDir: string,\n): ts.CompilerHost {\n return {\n ...compilerHost,\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n let filePath = fileName;\n if (/(\\.d\\.ts|\\.metadata\\.json)$/.test(fileName)) {\n const projectRelativePath = path.relative(baseDir, fileName);\n filePath = path.resolve(declarationDir, projectRelativePath);\n }\n compilerHost.writeFile.call(this, filePath, data, writeByteOrderMark, onError, sourceFiles);\n },\n };\n}\n"]}