ng-packagr 4.7.0 → 4.7.1

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,18 @@
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
+ <a name="4.7.1"></a>
6
+ ## [4.7.1](https://github.com/ng-packagr/ng-packagr/compare/v4.7.0...v4.7.1) (2019-02-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * don't use classic module resolution during analyse ([f0a1c38](https://github.com/ng-packagr/ng-packagr/commit/f0a1c38)), closes [#1210](https://github.com/ng-packagr/ng-packagr/issues/1210)
12
+ * emit complete diagnostics ([82e1fd0](https://github.com/ng-packagr/ng-packagr/commit/82e1fd0))
13
+ * replace opencollective-cli with opencollective-postinstall ([#1203](https://github.com/ng-packagr/ng-packagr/issues/1203)) ([44776da](https://github.com/ng-packagr/ng-packagr/commit/44776da)), closes [#1178](https://github.com/ng-packagr/ng-packagr/issues/1178)
14
+
15
+
16
+
5
17
  <a name="4.7.0"></a>
6
18
  # [4.7.0](https://github.com/ng-packagr/ng-packagr/compare/v4.6.0...v4.7.0) (2019-01-26)
7
19
 
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  [![npm License](https://img.shields.io/npm/l/ng-packagr.svg?style=flat-square)](https://github.com/ng-packagr/ng-packagr/blob/master/LICENSE)
8
8
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)
9
9
  [![CircleCI](https://img.shields.io/circleci/project/github/ng-packagr/ng-packagr/master.svg?label=Circle%20CI&style=flat-square)](https://circleci.com/gh/ng-packagr/ng-packagr)
10
- [![Travis](https://img.shields.io/travis/ng-packagr/ng-packagr/master.svg?label=Travis%20CI&style=flat-square)](https://travis-ci.org/ng-packagr/ng-packagr)
11
10
 
12
11
  [![Backers on Open Collective](https://opencollective.com/ng-packagr/backers/badge.svg?style=flat-square)](#backers)
13
12
  [![Sponsors on Open Collective](https://opencollective.com/ng-packagr/sponsors/badge.svg?style=flat-square)](#sponsors)
@@ -8,6 +8,7 @@ const log = require("../../util/log");
8
8
  const nodes_1 = require("../nodes");
9
9
  const cache_compiler_host_1 = require("../../ts/cache-compiler-host");
10
10
  const array_1 = require("../../util/array");
11
+ const path_1 = require("../../util/path");
11
12
  exports.analyseSourcesTransform = rxjs_1.pipe(operators_1.map(graph => {
12
13
  const entryPoints = graph.filter(x => nodes_1.isEntryPoint(x) && x.state !== 'done');
13
14
  for (let entryPoint of entryPoints) {
@@ -27,8 +28,17 @@ function analyseEntryPoint(graph, entryPoint, entryPoints) {
27
28
  const oldProgram = oldPrograms && oldPrograms['analysis'];
28
29
  const { moduleId } = entryPoint.data.entryPoint;
29
30
  log.debug(`Analysing sources for ${moduleId}`);
30
- const tsConfigOptions = Object.assign({}, entryPoint.data.tsConfig.options, { skipLibCheck: true, resolveJsonModule: false, moduleResolution: ts.ModuleResolutionKind.Classic, types: [] });
31
+ const tsConfigOptions = Object.assign({}, entryPoint.data.tsConfig.options, { skipLibCheck: true, types: [] });
31
32
  const compilerHost = cache_compiler_host_1.cacheCompilerHost(graph, entryPoint, tsConfigOptions, analysisModuleResolutionCache, undefined, analysisSourcesFileCache);
33
+ compilerHost.resolveModuleNames = (moduleNames, containingFile) => {
34
+ return moduleNames.map(moduleName => {
35
+ if (!moduleName.startsWith('.')) {
36
+ return undefined;
37
+ }
38
+ const { resolvedModule } = ts.resolveModuleName(moduleName, path_1.ensureUnixPath(containingFile), tsConfigOptions, compilerHost, analysisModuleResolutionCache);
39
+ return resolvedModule;
40
+ });
41
+ };
32
42
  const program = ts.createProgram(entryPoint.data.tsConfig.rootNames, tsConfigOptions, compilerHost, oldProgram);
33
43
  const diagnostics = program.getOptionsDiagnostics();
34
44
  if (diagnostics.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"analyse-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K,CACP,oCAAoC,UAAU,CAAC,CAAC,CAAE,UAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAC5G,CAAC;IAEF,UAAU,CAAC,KAAK,CAAC,WAAW,qBAAQ,UAAU,CAAC,KAAK,CAAC,WAAW,IAAE,CAAC,UAAU,CAAC,EAAE,OAAO,GAAE,CAAC;IAE1F,gBAAgB,GAAG,cAAM,CAAC,gBAAgB,CAAC,CAAC;IAC5C,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACpC,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;QAC/E,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,KAAK,CAAC,iCAAiC,QAAQ,OAAO,UAAU,EAAE,CAAC,CAAC;YAExE,IAAI,QAAQ,KAAK,UAAU,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;aACnF;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC3B;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport * as ts from 'typescript';\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport * as log from '../../util/log';\nimport { Transform } from '../../brocc/transform';\nimport { isEntryPoint, EntryPointNode } from '../nodes';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { unique } from '../../util/array';\nimport { BuildGraph } from '../../brocc/build-graph';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints = graph.filter(x => isEntryPoint(x) && x.state !== 'done') as EntryPointNode[];\n for (let entryPoint of entryPoints) {\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 { analysisModuleResolutionCache, oldPrograms, analysisSourcesFileCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n\n log.debug(`Analysing sources for ${moduleId}`);\n\n const tsConfigOptions = {\n ...entryPoint.data.tsConfig.options,\n skipLibCheck: true,\n resolveJsonModule: false,\n moduleResolution: ts.ModuleResolutionKind.Classic,\n types: []\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n analysisModuleResolutionCache,\n undefined,\n analysisSourcesFileCache\n );\n\n const program: ts.Program = ts.createProgram(\n entryPoint.data.tsConfig.rootNames,\n tsConfigOptions,\n compilerHost,\n oldProgram\n );\n\n const diagnostics = program.getOptionsDiagnostics();\n if (diagnostics.length) {\n throw new Error(ng.formatDiagnostics(diagnostics));\n }\n\n // this is a workaround due to the below\n // https://github.com/angular/angular/issues/24010\n let moduleStatements: string[] = [];\n program\n .getSourceFiles()\n .filter(x => !/node_modules|\\.ngfactory|\\.ngstyle|(\\.d\\.ts$)/.test(x.fileName))\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) {\n return;\n }\n\n const text = moduleSpecifier.getText();\n const trimmedText = text.substring(1, text.length - 1);\n if (!trimmedText.startsWith('.')) {\n moduleStatements.push(trimmedText);\n }\n });\n });\n\n log.debug(\n `tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`\n );\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n moduleStatements = unique(moduleStatements);\n moduleStatements.forEach(moduleName => {\n const dep = entryPoints.find(ep => ep.data.entryPoint.moduleId === moduleName);\n if (dep) {\n log.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 entryPoint.dependsOn(dep);\n }\n });\n}\n"]}
1
+ {"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-v5/init/analyse-sources.transform.ts"],"names":[],"mappings":";;AAAA,4CAA4C;AAC5C,iCAAiC;AACjC,+BAA4B;AAC5B,8CAAqC;AACrC,sCAAsC;AAEtC,oCAAwD;AACxD,sEAAiE;AACjE,4CAA0C;AAE1C,0CAAiD;AAEpC,QAAA,uBAAuB,GAAc,WAAI,CACpD,eAAG,CAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAqB,CAAC;IACjG,KAAK,IAAI,UAAU,IAAI,WAAW,EAAE;QAClC,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,6BAA6B,EAAE,WAAW,EAAE,wBAAwB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IAClG,MAAM,UAAU,GAAG,WAAW,IAAK,WAAW,CAAC,UAAU,CAA4B,CAAC;IACtF,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAEhD,GAAG,CAAC,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAA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AAI,QAAQ,KAAK,UAAU,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;aACnF;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC3B;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport * as ts from 'typescript';\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport * as log from '../../util/log';\nimport { Transform } from '../../brocc/transform';\nimport { isEntryPoint, EntryPointNode } from '../nodes';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { unique } from '../../util/array';\nimport { BuildGraph } from '../../brocc/build-graph';\nimport { ensureUnixPath } from '../../util/path';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints = graph.filter(x => isEntryPoint(x) && x.state !== 'done') as EntryPointNode[];\n for (let entryPoint of entryPoints) {\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 { analysisModuleResolutionCache, oldPrograms, analysisSourcesFileCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n\n log.debug(`Analysing sources for ${moduleId}`);\n\n const tsConfigOptions = {\n ...entryPoint.data.tsConfig.options,\n skipLibCheck: true,\n types: []\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n analysisModuleResolutionCache,\n undefined,\n analysisSourcesFileCache\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 analysisModuleResolutionCache\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 const diagnostics = program.getOptionsDiagnostics();\n if (diagnostics.length) {\n throw new Error(ng.formatDiagnostics(diagnostics));\n }\n\n // this is a workaround due to the below\n // https://github.com/angular/angular/issues/24010\n let moduleStatements: string[] = [];\n program\n .getSourceFiles()\n .filter(x => !/node_modules|\\.ngfactory|\\.ngstyle|(\\.d\\.ts$)/.test(x.fileName))\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) {\n return;\n }\n\n const text = moduleSpecifier.getText();\n const trimmedText = text.substring(1, text.length - 1);\n if (!trimmedText.startsWith('.')) {\n moduleStatements.push(trimmedText);\n }\n });\n });\n\n log.debug(\n `tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`\n );\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n moduleStatements = unique(moduleStatements);\n moduleStatements.forEach(moduleName => {\n const dep = entryPoints.find(ep => ep.data.entryPoint.moduleId === moduleName);\n if (dep) {\n log.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 entryPoint.dependsOn(dep);\n }\n });\n}\n"]}
@@ -37,23 +37,36 @@ function compileSourceFiles(graph, entryPoint, tsConfig, moduleResolutionCache,
37
37
  oldProgram
38
38
  });
39
39
  yield ngProgram.loadNgStructureAsync();
40
- const diagnostics = [
40
+ log.debug(`ngc program structure is reused: ${oldProgram ? oldProgram.getTsProgram().structureIsReused : 'No old program'}`);
41
+ cache.oldPrograms = Object.assign({}, cache.oldPrograms, { [scriptTarget]: ngProgram });
42
+ const allDiagnostics = [
41
43
  ...ngProgram.getNgOptionDiagnostics(),
42
44
  ...ngProgram.getTsSyntacticDiagnostics(),
43
45
  ...ngProgram.getTsSemanticDiagnostics(),
44
46
  ...ngProgram.getNgSemanticDiagnostics(),
45
47
  ...ngProgram.getNgStructuralDiagnostics()
46
48
  ];
47
- log.debug(`ngc program structure is reused: ${oldProgram ? oldProgram.getTsProgram().structureIsReused : 'No old program'}`);
48
- cache.oldPrograms = Object.assign({}, cache.oldPrograms, { [scriptTarget]: ngProgram });
49
- const exitCode = ng.exitCodeFromResult(diagnostics);
49
+ // if we have an error we don't want to transpile.
50
+ const hasError = ng.exitCodeFromResult(allDiagnostics) > 0;
51
+ if (!hasError) {
52
+ // certain errors are only emitted by a compilation hence append to previous diagnostics
53
+ const { diagnostics } = ngProgram.emit({
54
+ emitCallback: create_emit_callback_1.createEmitCallback(tsConfigOptions),
55
+ emitFlags
56
+ });
57
+ allDiagnostics.push(...diagnostics);
58
+ }
59
+ if (allDiagnostics.length === 0) {
60
+ return;
61
+ }
62
+ const exitCode = ng.exitCodeFromResult(allDiagnostics);
63
+ const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);
50
64
  if (exitCode !== 0) {
51
- throw new Error(ng.formatDiagnostics(diagnostics));
65
+ throw new Error(formattedDiagnostics);
66
+ }
67
+ else {
68
+ log.msg(formattedDiagnostics);
52
69
  }
53
- ngProgram.emit({
54
- emitCallback: create_emit_callback_1.createEmitCallback(tsConfigOptions),
55
- emitFlags
56
- });
57
70
  });
58
71
  }
59
72
  exports.compileSourceFiles = compileSourceFiles;
@@ -1 +1 @@
1
- {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;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AE,CAAC;QAEvC,MAAM,WAAW,GAAG;YAClB,GAAG,SAAS,CAAC,sBAAsB,EAAE;YACrC,GAAG,SAAS,CAAC,yBAAyB,EAAE;YACxC,GAAG,SAAS,CAAC,wBAAwB,EAAE;YACvC,GAAG,SAAS,CAAC,wBAAwB,EAAE;YACvC,GAAG,SAAS,CAAC,0BAA0B,EAAE;SAC1C,CAAC;QAEF,GAAG,CAAC,KAAK,CACP,oCACE,UAAU,CAAC,CAAC,CAAE,UAAU,CAAC,YAAY,EAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBACtE,EAAE,CACH,CAAC;QAEF,KAAK,CAAC,WAAW,qBAAQ,KAAK,CAAC,WAAW,IAAE,CAAC,YAAY,CAAC,EAAE,SAAS,GAAE,CAAC;QAExE,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,QAAQ,KAAK,CAAC,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;SACpD;QAED,SAAS,CAAC,IAAI,CAAC;YACb,YAAY,EAAE,yCAAkB,CAAC,eAAe,CAAC;YACjD,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CAAA;AAtED,gDAsEC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport * as ts from 'typescript';\nimport * as log from '../util/log';\nimport { createEmitCallback } from './create-emit-callback';\nimport { redirectWriteFileCompilerHost } from '../ts/redirect-write-file-compiler-host';\nimport { cacheCompilerHost } from '../ts/cache-compiler-host';\nimport { StylesheetProcessor } from '../ng-v5/entry-point/resources/stylesheet-processor';\nimport { BuildGraph } from '../brocc/build-graph';\nimport { EntryPointNode } from '../ng-v5/nodes';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor: StylesheetProcessor,\n extraOptions?: Partial<ng.CompilerOptions>,\n declarationDir?: string\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\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 // ng.CompilerHost\n const ngCompilerHost = ng.createCompilerHost({\n options: tsConfigOptions,\n tsHost: tsCompilerHost\n });\n\n const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;\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 const diagnostics = [\n ...ngProgram.getNgOptionDiagnostics(),\n ...ngProgram.getTsSyntacticDiagnostics(),\n ...ngProgram.getTsSemanticDiagnostics(),\n ...ngProgram.getNgSemanticDiagnostics(),\n ...ngProgram.getNgStructuralDiagnostics()\n ];\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 exitCode = ng.exitCodeFromResult(diagnostics);\n if (exitCode !== 0) {\n throw new Error(ng.formatDiagnostics(diagnostics));\n }\n\n ngProgram.emit({\n emitCallback: createEmitCallback(tsConfigOptions),\n emitFlags\n });\n}\n"]}
1
+ {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,4CAA4C;AAE5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 'typescript';\nimport * as log from '../util/log';\nimport { createEmitCallback } from './create-emit-callback';\nimport { redirectWriteFileCompilerHost } from '../ts/redirect-write-file-compiler-host';\nimport { cacheCompilerHost } from '../ts/cache-compiler-host';\nimport { StylesheetProcessor } from '../ng-v5/entry-point/resources/stylesheet-processor';\nimport { BuildGraph } from '../brocc/build-graph';\nimport { EntryPointNode } from '../ng-v5/nodes';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor: StylesheetProcessor,\n extraOptions?: Partial<ng.CompilerOptions>,\n declarationDir?: string\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\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 // ng.CompilerHost\n const ngCompilerHost = ng.createCompilerHost({\n options: tsConfigOptions,\n tsHost: tsCompilerHost\n });\n\n const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;\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.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 // certain errors are only emitted by a compilation hence append to previous diagnostics\n const { diagnostics } = ngProgram.emit({\n emitCallback: createEmitCallback(tsConfigOptions),\n emitFlags\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "4.7.0",
3
+ "version": "4.7.1",
4
4
  "description": "Compile and package a TypeScript library to Angular Package Format",
5
5
  "keywords": [
6
6
  "angular",
@@ -41,7 +41,7 @@
41
41
  "less-plugin-npm-import": "^2.1.0",
42
42
  "node-sass": "^4.9.3",
43
43
  "node-sass-tilde-importer": "^1.0.0",
44
- "opencollective": "^1.0.3",
44
+ "opencollective-postinstall": "^2.0.1",
45
45
  "postcss": "^7.0.0",
46
46
  "postcss-url": "^8.0.0",
47
47
  "read-pkg-up": "^4.0.0",
@@ -75,6 +75,6 @@
75
75
  }
76
76
  },
77
77
  "scripts": {
78
- "postinstall": "opencollective postinstall"
78
+ "postinstall": "opencollective-postinstall"
79
79
  }
80
80
  }