ng-packagr 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +12 -12
- package/cli/main.d.ts +1 -0
- package/cli/main.js +4 -2
- package/cli/main.js.map +1 -1
- package/lib/brocc/build-graph.d.ts +1 -1
- package/lib/brocc/build-graph.js.map +1 -1
- package/lib/brocc/depth.js.map +1 -1
- package/lib/brocc/node.js.map +1 -1
- package/lib/brocc/select.js.map +1 -1
- package/lib/brocc/transform.di.js.map +1 -1
- package/lib/brocc/transform.js.map +1 -1
- package/lib/commands/build.command.d.ts +2 -0
- package/lib/commands/build.command.js +1 -0
- package/lib/commands/build.command.js.map +1 -1
- package/lib/commands/command.js.map +1 -1
- package/lib/file/file-cache.js +0 -1
- package/lib/file/file-cache.js.map +1 -1
- package/lib/file/file-watcher.js.map +1 -1
- package/lib/flatten/downlevel-transformer.js.map +1 -1
- package/lib/flatten/external-module-id-strategy.js.map +1 -1
- package/lib/flatten/flatten.js.map +1 -1
- package/lib/flatten/rollup.js +3 -0
- package/lib/flatten/rollup.js.map +1 -1
- package/lib/flatten/uglify.js.map +1 -1
- package/lib/flatten/umd-module-id-strategy.js.map +1 -1
- package/lib/ng-package-format/entry-point.d.ts +12 -12
- package/lib/ng-package-format/entry-point.js.map +1 -1
- package/lib/ng-package-format/package.d.ts +9 -9
- package/lib/ng-package-format/package.js.map +1 -1
- package/lib/ng-package-format/shared.d.ts +1 -1
- package/lib/ng-v5/discover-packages.js.map +1 -1
- package/lib/ng-v5/entry-point/resources/postcss-clean.js.map +1 -1
- package/lib/ng-v5/entry-point/resources/stylesheet-processor.d.ts +4 -4
- package/lib/ng-v5/entry-point/resources/stylesheet-processor.js +12 -10
- package/lib/ng-v5/entry-point/resources/stylesheet-processor.js.map +1 -1
- package/lib/ng-v5/entry-point/ts/compile-ngc.transform.js +7 -4
- package/lib/ng-v5/entry-point/ts/compile-ngc.transform.js.map +1 -1
- package/lib/ng-v5/entry-point/write-bundles.transform.js.map +1 -1
- package/lib/ng-v5/entry-point/write-package.transform.js +2 -1
- package/lib/ng-v5/entry-point/write-package.transform.js.map +1 -1
- package/lib/ng-v5/init/analyse-sources.transform.js +6 -4
- package/lib/ng-v5/init/analyse-sources.transform.js.map +1 -1
- package/lib/ng-v5/init/init-tsconfig.di.d.ts +1 -1
- package/lib/ng-v5/init/init-tsconfig.di.js.map +1 -1
- package/lib/ng-v5/init/init-tsconfig.transform.d.ts +1 -1
- package/lib/ng-v5/init/init-tsconfig.transform.js +1 -1
- package/lib/ng-v5/init/init-tsconfig.transform.js.map +1 -1
- package/lib/ng-v5/nodes.d.ts +3 -4
- package/lib/ng-v5/nodes.js +1 -2
- package/lib/ng-v5/nodes.js.map +1 -1
- package/lib/ng-v5/package.di.js.map +1 -1
- package/lib/ng-v5/package.transform.js +15 -23
- package/lib/ng-v5/package.transform.js.map +1 -1
- package/lib/ng-v5/packagr.d.ts +2 -2
- package/lib/ng-v5/packagr.js.map +1 -1
- package/lib/ngc/compile-source-files.d.ts +1 -2
- package/lib/ngc/compile-source-files.js +2 -15
- package/lib/ngc/compile-source-files.js.map +1 -1
- package/lib/ngc/create-emit-callback.js +2 -2
- package/lib/ngc/create-emit-callback.js.map +1 -1
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/lib/ts/conf/tsconfig.ngc.json +0 -2
- package/lib/ts/redirect-write-file-compiler-host.js +1 -1
- package/lib/ts/redirect-write-file-compiler-host.js.map +1 -1
- package/lib/ts/tsconfig.d.ts +14 -7
- package/lib/ts/tsconfig.js +69 -54
- package/lib/ts/tsconfig.js.map +1 -1
- package/lib/util/array.js.map +1 -1
- package/lib/util/copy.d.ts +2 -2
- package/lib/util/copy.js +5 -18
- package/lib/util/copy.js.map +1 -1
- package/lib/util/glob.js.map +1 -1
- package/lib/util/log.js.map +1 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/promisify.js.map +1 -1
- package/lib/util/rimraf.js.map +1 -1
- package/package.json +12 -12
package/lib/ng-v5/nodes.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
+
import { ParsedConfiguration } from '@angular/compiler-cli';
|
|
2
3
|
import { Node } from '../brocc/node';
|
|
3
4
|
import { NgEntryPoint } from '../ng-package-format/entry-point';
|
|
4
5
|
import { NgPackage } from '../ng-package-format/package';
|
|
5
|
-
import { TsConfig } from '../ts/tsconfig';
|
|
6
6
|
import { DestinationFiles } from '../ng-package-format/shared';
|
|
7
7
|
import { FileCache } from '../file/file-cache';
|
|
8
8
|
export declare const TYPE_NG_PACKAGE = "application/ng-package";
|
|
@@ -26,15 +26,14 @@ export declare function ngUrl(path: string): string;
|
|
|
26
26
|
export declare class EntryPointNode extends Node {
|
|
27
27
|
readonly type: string;
|
|
28
28
|
cache: {
|
|
29
|
-
|
|
30
|
-
compilationFileCache: FileCache;
|
|
29
|
+
sourcesFileCache: FileCache;
|
|
31
30
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
32
31
|
analysisModuleResolutionCache: ts.ModuleResolutionCache;
|
|
33
32
|
};
|
|
34
33
|
data: {
|
|
35
34
|
destinationFiles: DestinationFiles;
|
|
36
35
|
entryPoint: NgEntryPoint;
|
|
37
|
-
tsConfig?:
|
|
36
|
+
tsConfig?: ParsedConfiguration;
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
export declare class PackageNode extends Node {
|
package/lib/ng-v5/nodes.js
CHANGED
|
@@ -53,8 +53,7 @@ class EntryPointNode extends node_1.Node {
|
|
|
53
53
|
super(...arguments);
|
|
54
54
|
this.type = exports.TYPE_NG_ENTRY_POINT;
|
|
55
55
|
this.cache = {
|
|
56
|
-
|
|
57
|
-
compilationFileCache: new file_cache_1.FileCache(),
|
|
56
|
+
sourcesFileCache: new file_cache_1.FileCache(),
|
|
58
57
|
moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),
|
|
59
58
|
analysisModuleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s)
|
|
60
59
|
};
|
package/lib/ng-v5/nodes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/nodes.ts"],"names":[],"mappings":";;AAAA,iCAAiC;
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/nodes.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,wCAAqC;AACrC,4CAA4D;AAI5D,mDAA+C;AAElC,QAAA,eAAe,GAAG,wBAAwB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,4BAA4B,CAAC;AAEhE,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,kCAAkC;AACrB,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,sBAA6B,IAAU;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,2BAAmB,CAAC;AAC3C,CAAC;AAFD,oCAEC;AAED,mBAA0B,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,uBAAe,CAAC;AACvC,CAAC;AAFD,8BAEC;AAED;IACE,OAAO,WAAE,CAAC,YAAY,CAAC,CAAC;AAC1B,CAAC;AAFD,oCAEC;AAED;IACE,OAAO,WAAE,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC;AAC5C,CAAC;AAFD,wDAEC;AAED;IACE,OAAO,WAAE,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,gBAAO,CAAC,CAAC;AACvC,CAAC;AAFD,8CAEC;AAED,mBAA0B,KAAa;IACrC,OAAO,KAAK,CAAC,UAAU,CAAC,yBAAiB,CAAC,CAAC;AAC7C,CAAC;AAFD,8BAEC;AAED,iBAAwB,IAAY;IAClC,OAAO,GAAG,yBAAiB,GAAG,IAAI,EAAE,CAAC;AACvC,CAAC;AAFD,0BAEC;AAED,qBAA4B,GAAW;IACrC,IAAI,GAAG,CAAC,UAAU,CAAC,yBAAiB,CAAC,EAAE;QACrC,OAAO,GAAG,CAAC,SAAS,CAAC,yBAAiB,CAAC,MAAM,CAAC,CAAC;KAChD;AACH,CAAC;AAJD,kCAIC;AAED,eAAsB,IAAY;IAChC,OAAO,GAAG,uBAAe,GAAG,IAAI,EAAE,CAAC;AACrC,CAAC;AAFD,sBAEC;AAED,oBAA4B,SAAQ,WAAI;IAAxC;;QACW,SAAI,GAAG,2BAAmB,CAAC;QAEpC,UAAK,GAAG;YACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;YACjC,qBAAqB,EAAE,EAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5E,6BAA6B,EAAE,EAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACrF,CAAC;IAOJ,CAAC;CAAA;AAdD,wCAcC;AAED,iBAAyB,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;IAElC,CAAC;CAAA;AAHD,kCAGC","sourcesContent":["import * as ts from 'typescript';\nimport { ParsedConfiguration } from '@angular/compiler-cli';\nimport { Node } from '../brocc/node';\nimport { by, isInProgress, isDirty } from '../brocc/select';\nimport { NgEntryPoint } from '../ng-package-format/entry-point';\nimport { NgPackage } from '../ng-package-format/package';\nimport { DestinationFiles } from '../ng-package-format/shared';\nimport { FileCache } from '../file/file-cache';\n\nexport const TYPE_NG_PACKAGE = 'application/ng-package';\nexport const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nexport const URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nexport const URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint() {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress() {\n return by(isEntryPoint).and(isInProgress);\n}\n\nexport function isEntryPointDirty() {\n return by(isEntryPoint).and(isDirty);\n}\n\nexport function isFileUrl(value: string): boolean {\n return value.startsWith(URL_PROTOCOL_FILE);\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string {\n if (url.startsWith(URL_PROTOCOL_FILE)) {\n return url.substring(URL_PROTOCOL_FILE.length);\n }\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n analysisModuleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s)\n };\n\n data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n data: NgPackage;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.di.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/package.di.ts"],"names":[],"mappings":";;AAAA,+CAAwD;AAExD,wDAA4E;AAC5E,6CAA6C;AAC7C,qDAA+D;AAC/D,2DAA8D;AAC9D,kEAA6F;AAC7F,8DAAqH;AACrH,6CAAuE;AAE1D,QAAA,uBAAuB,GAAG,IAAI,6BAAc,CAAY,wBAAwB,CAAC,CAAC;AAElF,QAAA,iBAAiB,
|
|
1
|
+
{"version":3,"file":"package.di.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/package.di.ts"],"names":[],"mappings":";;AAAA,+CAAwD;AAExD,wDAA4E;AAC5E,6CAA6C;AAC7C,qDAA+D;AAC/D,2DAA8D;AAC9D,kEAA6F;AAC7F,8DAAqH;AACrH,6CAAuE;AAE1D,QAAA,uBAAuB,GAAG,IAAI,6BAAc,CAAY,wBAAwB,CAAC,CAAC;AAElF,QAAA,iBAAiB,GAAsB,+BAAgB,CAAC;IACnE,OAAO,EAAE,+BAAuB;IAChC,UAAU,EAAE,2CAAuB;IACnC,IAAI,EAAE,CAAC,0BAAa,EAAE,0BAAa,EAAE,uCAAoB,EAAE,0CAAqB,EAAE,4CAA2B,CAAC;CAC/G,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAe;IAC3C,yBAAiB;IACjB,qCAAwB;IACxB,6CAA0B;IAC1B,2CAAwB;IACxB,8CAAyB;CAC1B,CAAC","sourcesContent":["import { InjectionToken, Provider } from 'injection-js';\nimport { Transform } from '../brocc/transform';\nimport { provideTransform, TransformProvider } from '../brocc/transform.di';\nimport { PROJECT_TOKEN } from './project.di';\nimport { ENTRY_POINT_TRANSFORM_TOKEN } from './entry-point.di';\nimport { packageTransformFactory } from './package.transform';\nimport { ANALYSE_SOURCES_TOKEN, ANALYSE_SOURCES_TRANSFORM } from './init/analyse-sources.di';\nimport { DEFAULT_TS_CONFIG_PROVIDER, INIT_TS_CONFIG_TRANSFORM, INIT_TS_CONFIG_TOKEN } from './init/init-tsconfig.di';\nimport { OPTIONS_TOKEN, DEFAULT_OPTIONS_PROVIDER } from './options.di';\n\nexport const PACKAGE_TRANSFORM_TOKEN = new InjectionToken<Transform>(`ng.v5.packageTransform`);\n\nexport const PACKAGE_TRANSFORM: TransformProvider = provideTransform({\n provide: PACKAGE_TRANSFORM_TOKEN,\n useFactory: packageTransformFactory,\n deps: [PROJECT_TOKEN, OPTIONS_TOKEN, INIT_TS_CONFIG_TOKEN, ANALYSE_SOURCES_TOKEN, ENTRY_POINT_TRANSFORM_TOKEN]\n});\n\nexport const PACKAGE_PROVIDERS: Provider[] = [\n PACKAGE_TRANSFORM,\n DEFAULT_OPTIONS_PROVIDER,\n DEFAULT_TS_CONFIG_PROVIDER,\n INIT_TS_CONFIG_TRANSFORM,\n ANALYSE_SOURCES_TRANSFORM\n];\n"]}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
3
4
|
const rxjs_1 = require("rxjs");
|
|
4
5
|
const operators_1 = require("rxjs/operators");
|
|
5
6
|
const depth_1 = require("../brocc/depth");
|
|
6
7
|
const node_1 = require("../brocc/node");
|
|
7
8
|
const log = require("../util/log");
|
|
8
|
-
const copy_1 = require("../util/copy");
|
|
9
9
|
const rimraf_1 = require("../util/rimraf");
|
|
10
10
|
const nodes_1 = require("./nodes");
|
|
11
11
|
const discover_packages_1 = require("./discover-packages");
|
|
12
12
|
const file_watcher_1 = require("../file/file-watcher");
|
|
13
13
|
const array_1 = require("../util/array");
|
|
14
|
+
const copy_1 = require("../util/copy");
|
|
14
15
|
/**
|
|
15
16
|
* A transformation for building an npm package:
|
|
16
17
|
*
|
|
@@ -66,7 +67,7 @@ exports.packageTransformFactory = (project, options, initTsConfigTransform, anal
|
|
|
66
67
|
// perform build
|
|
67
68
|
buildTransform);
|
|
68
69
|
};
|
|
69
|
-
const watchTransformFactory = (project,
|
|
70
|
+
const watchTransformFactory = (project, _options, analyseSourcesTransform, entryPointTransform) => (source$) => {
|
|
70
71
|
const CompleteWaitingForFileChange = '\nCompilation complete. Watching for file changes...';
|
|
71
72
|
const FileChangeDetected = '\nFile change detected. Starting incremental compilation...';
|
|
72
73
|
const FailedWaitingForFileChange = '\nCompilation failed. Watching for file changes...';
|
|
@@ -77,8 +78,8 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
77
78
|
const { filePath } = fileChange;
|
|
78
79
|
let filePathsToClean = [filePath];
|
|
79
80
|
entryPoints.forEach((node) => {
|
|
80
|
-
const {
|
|
81
|
-
const cached =
|
|
81
|
+
const { sourcesFileCache } = node.cache;
|
|
82
|
+
const cached = sourcesFileCache.get(filePath);
|
|
82
83
|
// when a ts file changes we also need to clean it's .d.ts file
|
|
83
84
|
// and the entrypoint metadata due to the fact that metadata is used to validate component properties
|
|
84
85
|
if (cached && cached.declarationFileName) {
|
|
@@ -88,11 +89,10 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
88
89
|
});
|
|
89
90
|
filePathsToClean = array_1.unique(filePathsToClean);
|
|
90
91
|
entryPoints.forEach((node) => {
|
|
91
|
-
const {
|
|
92
|
+
const { sourcesFileCache } = node.cache;
|
|
92
93
|
let isDirty = false;
|
|
93
94
|
filePathsToClean.forEach(x => {
|
|
94
|
-
isDirty =
|
|
95
|
-
isDirty = compilationFileCache.delete(x) || isDirty;
|
|
95
|
+
isDirty = sourcesFileCache.delete(x) || isDirty;
|
|
96
96
|
});
|
|
97
97
|
if (isDirty) {
|
|
98
98
|
node.state = 'dirty';
|
|
@@ -123,32 +123,24 @@ const buildTransformFactory = (project, analyseSourcesTransform, entryPointTrans
|
|
|
123
123
|
}));
|
|
124
124
|
};
|
|
125
125
|
const writeNpmPackage = (pkgUri) => rxjs_1.pipe(operators_1.switchMap(graph => {
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const { data } = graph.get(pkgUri);
|
|
127
|
+
const filesToCopy = Promise.all([`${data.src}/LICENSE`, `${data.src}/README.md`].map(src => copy_1.copyFile(src, path.join(data.dest, path.basename(src)))));
|
|
128
|
+
return rxjs_1.from(filesToCopy).pipe(operators_1.map(() => graph));
|
|
128
129
|
}));
|
|
129
130
|
const scheduleEntryPoints = (epTransform) => rxjs_1.pipe(operators_1.concatMap(graph => {
|
|
130
131
|
// Calculate node/dependency depth and determine build order
|
|
131
132
|
const depthBuilder = new depth_1.DepthBuilder();
|
|
132
|
-
const entryPoints = graph.filter(
|
|
133
|
+
const entryPoints = graph.filter(nodes_1.isEntryPoint);
|
|
133
134
|
entryPoints.forEach(entryPoint => {
|
|
134
135
|
const deps = entryPoint.filter(nodes_1.isEntryPoint).map(ep => ep.url);
|
|
135
136
|
depthBuilder.add(entryPoint.url, deps);
|
|
136
137
|
});
|
|
137
138
|
// The array index is the depth.
|
|
138
139
|
const groups = depthBuilder.build();
|
|
139
|
-
const flattenedGroups = groups.reduce((prev, current) => prev.concat(current), []);
|
|
140
|
-
let currentIndex = 0;
|
|
141
140
|
// Build entry points with lower depth values first.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// Mark the entry point as 'in-progress'
|
|
147
|
-
entryPoint.state = node_1.STATE_IN_PROGESS;
|
|
148
|
-
}), epTransform, operators_1.tap(() => {
|
|
149
|
-
currentIndex += 1;
|
|
150
|
-
})));
|
|
151
|
-
// Build all entry points, then continue
|
|
152
|
-
return rxjs_1.concat(...eps$).pipe(operators_1.takeLast(1));
|
|
141
|
+
return rxjs_1.from(array_1.flatten(groups)).pipe(operators_1.map(epUrl => graph.find(nodes_1.byEntryPoint().and(ep => ep.url === epUrl))), operators_1.filter(entryPoint => entryPoint.state !== 'done'), operators_1.concatMap(ep => rxjs_1.of(ep).pipe(
|
|
142
|
+
// Mark the entry point as 'in-progress'
|
|
143
|
+
operators_1.tap(entryPoint => (entryPoint.state = node_1.STATE_IN_PROGESS)), operators_1.mapTo(graph), epTransform)), operators_1.takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',
|
|
144
|
+
operators_1.defaultIfEmpty(graph));
|
|
153
145
|
}));
|
|
154
146
|
//# sourceMappingURL=package.transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/package.transform.ts"],"names":[],"mappings":";;AAAA,+BAAgH;AAChH,8CAAsH;AAEtH,0CAA8C;AAC9C,wCAAiD;AAEjD,mCAAmC;AACnC,uCAAyC;AACzC,2CAAwC;AACxC,mCAAoG;AACpG,2DAAuD;AACvD,uDAAuD;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AC,CAAC;QAC/D,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IACpC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACnF,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,oDAAoD;IACpD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,CACpC,SAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CACtB,eAAG,CAAC,GAAG,EAAE;QACP,uCAAuC;QACvC,MAAM,KAAK,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC;QAE1E,wCAAwC;QACxC,UAAU,CAAC,KAAK,GAAG,uBAAgB,CAAC;IACtC,CAAC,CAAC,EACF,WAAW,EACX,eAAG,CAAC,GAAG,EAAE;QACP,YAAY,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC,CACH,CACF,CAAC;IAEF,wCAAwC;IACxC,MAAM,CAAC,aAAY,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { Observable, concat as concatStatic, from as fromPromise, of as observableOf, pipe, NEVER } from 'rxjs';\nimport { concatMap, map, switchMap, takeLast, tap, mapTo, catchError, startWith, debounceTime } from 'rxjs/operators';\nimport { BuildGraph } from '../brocc/build-graph';\nimport { DepthBuilder } from '../brocc/depth';\nimport { STATE_IN_PROGESS } from '../brocc/node';\nimport { Transform } from '../brocc/transform';\nimport * as log from '../util/log';\nimport { copyFiles } from '../util/copy';\nimport { rimraf } from '../util/rimraf';\nimport { PackageNode, EntryPointNode, ngUrl, isEntryPoint, byEntryPoint, isPackage } from './nodes';\nimport { discoverPackages } from './discover-packages';\nimport { createFileWatch } from '../file/file-watcher';\nimport { NgPackagrOptions } from './options.di';\nimport { unique } from '../util/array';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n * - writeNpmPackage\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory = (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform\n) => (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const pkgUri = ngUrl(project);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n return source$.pipe(\n tap(() => log.info(`Building Angular Package`)),\n // Discover packages and entry points\n switchMap(graph => {\n const pkg = discoverPackages({ project });\n\n return fromPromise(pkg).pipe(\n map(value => {\n const ngPkg = new PackageNode(pkgUri);\n ngPkg.data = value;\n\n return graph.put(ngPkg);\n })\n );\n }),\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(graph => {\n const { dest, deleteDestPath } = graph.get(pkgUri).data;\n return fromPromise(deleteDestPath ? rimraf(dest) : Promise.resolve());\n }, (graph, _) => graph),\n // Add entry points to graph\n map(graph => {\n const ngPkg = graph.get(pkgUri);\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(ngUrl(moduleId));\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform\n );\n};\n\nconst watchTransformFactory = (\n project: string,\n options: NgPackagrOptions,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform\n) => (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data } = graph.find(isPackage) as PackageNode;\n return createFileWatch(data.src, [data.dest]).pipe(\n tap(fileChange => {\n const entryPoints = graph.filter(isEntryPoint);\n const { filePath } = fileChange;\n let filePathsToClean: string[] = [filePath];\n\n entryPoints.forEach((node: EntryPointNode) => {\n const { compilationFileCache } = node.cache;\n const cached = compilationFileCache.get(filePath);\n\n // when a ts file changes we also need to clean it's .d.ts file\n // and the entrypoint metadata due to the fact that metadata is used to validate component properties\n if (cached && cached.declarationFileName) {\n const { metadata } = node.data.destinationFiles;\n filePathsToClean.push(cached.declarationFileName, metadata);\n }\n });\n\n filePathsToClean = unique(filePathsToClean);\n\n entryPoints.forEach((node: EntryPointNode) => {\n const { analysisFileCache, compilationFileCache } = node.cache;\n\n let isDirty = false;\n\n filePathsToClean.forEach(x => {\n isDirty = analysisFileCache.delete(x) || isDirty;\n isDirty = compilationFileCache.delete(x) || isDirty;\n });\n\n if (isDirty) {\n node.state = 'dirty';\n }\n });\n }),\n debounceTime(200),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n mapTo(graph)\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n return NEVER;\n })\n );\n })\n );\n};\n\nconst buildTransformFactory = (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) => (\n source$: Observable<BuildGraph>\n): Observable<BuildGraph> => {\n const pkgUri = ngUrl(project);\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n // Write npm package to dest folder\n writeNpmPackage(pkgUri),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success(`Built Angular Package!\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n })\n );\n};\n\nconst writeNpmPackage = (pkgUri: string): Transform =>\n pipe(\n switchMap(graph => {\n const ngPkg = graph.get(pkgUri);\n return fromPromise(copyFiles([`${ngPkg.data.src}/LICENSE`, `${ngPkg.data.src}/README.md`], ngPkg.data.dest)).pipe(\n map(() => graph)\n );\n })\n );\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depthBuilder = new DepthBuilder();\n const entryPoints = graph.filter(x => isEntryPoint(x) && x.state !== 'done');\n entryPoints.forEach(entryPoint => {\n const deps = entryPoint.filter(isEntryPoint).map(ep => ep.url);\n depthBuilder.add(entryPoint.url, deps);\n });\n\n // The array index is the depth.\n const groups = depthBuilder.build();\n const flattenedGroups = groups.reduce((prev, current) => prev.concat(current), []);\n let currentIndex = 0;\n\n // Build entry points with lower depth values first.\n const eps$ = flattenedGroups.map(() =>\n observableOf(graph).pipe(\n tap(() => {\n // Find current entry point in progress\n const epUrl = flattenedGroups[currentIndex];\n const entryPoint = graph.find(byEntryPoint().and(ep => ep.url === epUrl));\n\n // Mark the entry point as 'in-progress'\n entryPoint.state = STATE_IN_PROGESS;\n }),\n epTransform,\n tap(() => {\n currentIndex += 1;\n })\n )\n );\n\n // Build all entry points, then continue\n return concatStatic(...eps$).pipe(takeLast(1));\n })\n );\n"]}
|
|
1
|
+
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/package.transform.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,+BAAyE;AACzE,8CAYwB;AAExB,0CAA8C;AAC9C,wCAAiD;AAEjD,mCAAmC;AACnC,2CAAwC;AACxC,mCAAoG;AACpG,2DAAuD;AACvD,uDAAuD;AAEvD,yCAAgD;AAChD,uCAAwC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,uBAAuB,GAAG,CACrC,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CAAC,CAAC,OAA+B,EAA0B,EAAE;IAC/D,MAAM,MAAM,GAAG,aAAK,CAAC,OAAO,CAAC,CAAC;IAE9B,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK;QAClC,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC;QACvF,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;IAEjF,OAAO,OAAO,CAAC,IAAI,CACjB,eAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC/C,qCAAqC;IACrC,qBAAS,CAAC,KAAK,CAAC,EAAE;QAChB,MAAM,GAAG,GAAG,oCAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAE1C,OAAO,WAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CACnB,eAAG,CAAC,KAAK,CAAC,EAAE;YACV,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,MAAM,CAAC,CAAC;YACtC,KAAK,CAAC,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E,CAAC;IACxC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAC/C,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/D,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAEpC,oDAAoD;IACpD,OAAO,WAAI,CAAC,eAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAC/B,eAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAmB,CAAC,EACtF,kBAAM,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,MAAM,CAAC,EACjD,qBAAS,CAAC,EAAE,CAAC,EAAE,CACb,SAAY,CAAC,EAAE,CAAC,CAAC,IAAI;IACnB,wCAAwC;IACxC,eAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,uBAAgB,CAAC,CAAC,EACxD,iBAAK,CAAC,KAAK,CAAC,EACZ,WAAW,CACZ,CACF,EACD,oBAAQ,CAAC,CAAC,CAAC,EAAE,4EAA4E;IACzF,0BAAc,CAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC","sourcesContent":["import * as path from 'path';\nimport { Observable, of as observableOf, pipe, NEVER, from } from 'rxjs';\nimport {\n concatMap,\n map,\n switchMap,\n tap,\n mapTo,\n catchError,\n startWith,\n debounceTime,\n filter,\n takeLast,\n defaultIfEmpty\n} from 'rxjs/operators';\nimport { BuildGraph } from '../brocc/build-graph';\nimport { DepthBuilder } from '../brocc/depth';\nimport { STATE_IN_PROGESS } from '../brocc/node';\nimport { Transform } from '../brocc/transform';\nimport * as log from '../util/log';\nimport { rimraf } from '../util/rimraf';\nimport { PackageNode, EntryPointNode, ngUrl, isEntryPoint, byEntryPoint, isPackage } from './nodes';\nimport { discoverPackages } from './discover-packages';\nimport { createFileWatch } from '../file/file-watcher';\nimport { NgPackagrOptions } from './options.di';\nimport { unique, flatten } from '../util/array';\nimport { copyFile } from '../util/copy';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n * - writeNpmPackage\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory = (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform\n) => (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const pkgUri = ngUrl(project);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n return source$.pipe(\n tap(() => log.info(`Building Angular Package`)),\n // Discover packages and entry points\n switchMap(graph => {\n const pkg = discoverPackages({ project });\n\n return from(pkg).pipe(\n map(value => {\n const ngPkg = new PackageNode(pkgUri);\n ngPkg.data = value;\n\n return graph.put(ngPkg);\n })\n );\n }),\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(graph => {\n const { dest, deleteDestPath } = graph.get(pkgUri).data;\n return from(deleteDestPath ? rimraf(dest) : Promise.resolve());\n }, (graph, _) => graph),\n // Add entry points to graph\n map(graph => {\n const ngPkg = graph.get(pkgUri);\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(ngUrl(moduleId));\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform\n );\n};\n\nconst watchTransformFactory = (\n project: string,\n _options: NgPackagrOptions,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform\n) => (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data } = graph.find(isPackage) as PackageNode;\n return createFileWatch(data.src, [data.dest]).pipe(\n tap(fileChange => {\n const entryPoints = graph.filter(isEntryPoint);\n const { filePath } = fileChange;\n let filePathsToClean: string[] = [filePath];\n\n entryPoints.forEach((node: EntryPointNode) => {\n const { sourcesFileCache } = node.cache;\n const cached = sourcesFileCache.get(filePath);\n\n // when a ts file changes we also need to clean it's .d.ts file\n // and the entrypoint metadata due to the fact that metadata is used to validate component properties\n if (cached && cached.declarationFileName) {\n const { metadata } = node.data.destinationFiles;\n filePathsToClean.push(cached.declarationFileName, metadata);\n }\n });\n\n filePathsToClean = unique(filePathsToClean);\n\n entryPoints.forEach((node: EntryPointNode) => {\n const { sourcesFileCache } = node.cache;\n\n let isDirty = false;\n\n filePathsToClean.forEach(x => {\n isDirty = sourcesFileCache.delete(x) || isDirty;\n });\n\n if (isDirty) {\n node.state = 'dirty';\n }\n });\n }),\n debounceTime(200),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n mapTo(graph)\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n return NEVER;\n })\n );\n })\n );\n};\n\nconst buildTransformFactory = (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) => (\n source$: Observable<BuildGraph>\n): Observable<BuildGraph> => {\n const pkgUri = ngUrl(project);\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n // Write npm package to dest folder\n writeNpmPackage(pkgUri),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success(`Built Angular Package!\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n })\n );\n};\n\nconst writeNpmPackage = (pkgUri: string): Transform =>\n pipe(\n switchMap(graph => {\n const { data } = graph.get(pkgUri);\n const filesToCopy = Promise.all(\n [`${data.src}/LICENSE`, `${data.src}/README.md`].map(src =>\n copyFile(src, path.join(data.dest, path.basename(src)))\n )\n );\n\n return from(filesToCopy).pipe(map(() => graph));\n })\n );\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depthBuilder = new DepthBuilder();\n const entryPoints = graph.filter(isEntryPoint);\n entryPoints.forEach(entryPoint => {\n const deps = entryPoint.filter(isEntryPoint).map(ep => ep.url);\n depthBuilder.add(entryPoint.url, deps);\n });\n\n // The array index is the depth.\n const groups = depthBuilder.build();\n\n // Build entry points with lower depth values first.\n return from(flatten(groups)).pipe(\n map(epUrl => graph.find(byEntryPoint().and(ep => ep.url === epUrl)) as EntryPointNode),\n filter(entryPoint => entryPoint.state !== 'done'),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGESS)),\n mapTo(graph),\n epTransform\n )\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph)\n );\n })\n );\n"]}
|
package/lib/ng-v5/packagr.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from 'injection-js';
|
|
2
|
+
import { ParsedConfiguration } from '@angular/compiler-cli';
|
|
2
3
|
import { Observable } from 'rxjs';
|
|
3
4
|
import { Transform } from '../brocc/transform';
|
|
4
|
-
import { TsConfig } from '../ts/tsconfig';
|
|
5
5
|
import { NgPackagrOptions } from './options.di';
|
|
6
6
|
/**
|
|
7
7
|
* The original ng-packagr implemented on top of a rxjs-ified and di-jectable transformation pipeline.
|
|
@@ -42,7 +42,7 @@ export declare class NgPackagr {
|
|
|
42
42
|
* @param defaultValues A tsconfig providing default values to the compilation.
|
|
43
43
|
* @return Self instance for fluent API
|
|
44
44
|
*/
|
|
45
|
-
withTsConfig(defaultValues:
|
|
45
|
+
withTsConfig(defaultValues: ParsedConfiguration | string): NgPackagr;
|
|
46
46
|
/**
|
|
47
47
|
* Overwrites the 'build' transform.
|
|
48
48
|
*
|
package/lib/ng-v5/packagr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packagr.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/packagr.ts"],"names":[],"mappings":";;AAAA,+CAA4E;
|
|
1
|
+
{"version":3,"file":"packagr.js","sourceRoot":"","sources":["../../../src/lib/ng-v5/packagr.ts"],"names":[],"mappings":";;AAAA,+CAA4E;AAE5E,+BAAsD;AACtD,8CAAiD;AACjD,sDAAkD;AAElD,mCAAmC;AACnC,8DAA0D;AAC1D,qDAAyD;AACzD,6CAAoE;AACpE,6CAA8C;AAC9C,6CAAgE;AAEhE;;;;;;GAMG;AACH;IAGE,YAAoB,SAAqB;QAArB,cAAS,GAAT,SAAS,CA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BAAsB,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEjE,OAAO,SAAY,CAAC,IAAI,wBAAU,EAAE,CAAC,CAAC,IAAI,CACxC,sBAAsB,EACtB,sBAAU,CAAC,GAAG,CAAC,EAAE;YACf,2CAA2C;YAC3C,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACf,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC,EACF,eAAG,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CACrB,CAAC;IACJ,CAAC;CACF;AAzGD,8BAyGC;AAEY,QAAA,SAAS,GAAG,GAAc,EAAE,CACvC,IAAI,SAAS,CAAC;IACZ,sCAAsC;IACtC,GAAG,8BAAiB;IACpB,GAAG,sCAAqB;CACzB,CAAC,CAAC","sourcesContent":["import { InjectionToken, Provider, ReflectiveInjector } from 'injection-js';\nimport { ParsedConfiguration } from '@angular/compiler-cli';\nimport { of as observableOf, Observable } from 'rxjs';\nimport { map, catchError } from 'rxjs/operators';\nimport { BuildGraph } from '../brocc/build-graph';\nimport { Transform } from '../brocc/transform';\nimport * as log from '../util/log';\nimport { provideTsConfig } from './init/init-tsconfig.di';\nimport { ENTRY_POINT_PROVIDERS } from './entry-point.di';\nimport { PACKAGE_TRANSFORM, PACKAGE_PROVIDERS } from './package.di';\nimport { provideProject } from './project.di';\nimport { provideOptions, NgPackagrOptions } from './options.di';\n\n/**\n * The original ng-packagr implemented on top of a rxjs-ified and di-jectable transformation pipeline.\n *\n * See the `docs/transformations.md` for more prose description.\n *\n * @link https://github.com/dherges/ng-packagr/pull/572\n */\nexport class NgPackagr {\n private buildTransform: InjectionToken<Transform> = PACKAGE_TRANSFORM.provide;\n\n constructor(private providers: Provider[]) {}\n\n /**\n * Adds options to ng-packagr\n *\n * @param options Ng Packagr Options\n * @return Self instance for fluent API\n */\n public withOptions(options: NgPackagrOptions): NgPackagr {\n this.providers.push(provideOptions(options));\n\n return this;\n }\n\n /**\n * Sets the path to the user's \"ng-package\" file (either `package.json`, `ng-package.json`, or `ng-package.js`)\n *\n * @param project File path\n * @return Self instance for fluent API\n */\n public forProject(project: string): NgPackagr {\n this.providers.push(provideProject(project));\n\n return this;\n }\n\n /**\n * Adds dependency injection providers.\n *\n * @param providers\n * @return Self instance for fluent API\n * @link https://github.com/mgechev/injection-js\n */\n public withProviders(providers: Provider[]): NgPackagr {\n this.providers = [...this.providers, ...providers];\n\n return this;\n }\n\n /**\n * Overwrites the default TypeScript configuration.\n *\n * @param defaultValues A tsconfig providing default values to the compilation.\n * @return Self instance for fluent API\n */\n public withTsConfig(defaultValues: ParsedConfiguration | string): NgPackagr {\n this.providers.push(provideTsConfig(defaultValues));\n\n return this;\n }\n\n /**\n * Overwrites the 'build' transform.\n *\n * @param transform\n * @return Self intance for fluent API\n */\n public withBuildTransform(transform: InjectionToken<Transform>): NgPackagr {\n this.buildTransform = transform;\n\n return this;\n }\n\n /**\n * Builds the project by kick-starting the 'build' transform over an (initially) empty `BuildGraph``\n *\n * @return A promisified result of the transformation pipeline.\n */\n public build(): Promise<void> {\n return this.buildAsObservable().toPromise();\n }\n\n /**\n * Builds and watch for changes by kick-starting the 'watch' transform over an (initially) empty `BuildGraph``\n *\n * @return An observable result of the transformation pipeline.\n */\n public watch(): Observable<void> {\n this.providers.push(provideOptions({ watch: true }));\n\n return this.buildAsObservable();\n }\n\n /**\n * Builds the project by kick-starting the 'build' transform over an (initially) empty `BuildGraph``\n *\n * @return An observable result of the transformation pipeline.\n */\n public buildAsObservable(): Observable<void> {\n const injector = ReflectiveInjector.resolveAndCreate(this.providers);\n const buildTransformOperator = injector.get(this.buildTransform);\n\n return observableOf(new BuildGraph()).pipe(\n buildTransformOperator,\n catchError(err => {\n // Report error and re-throw to subscribers\n log.error(err);\n throw err;\n }),\n map(() => undefined)\n );\n }\n}\n\nexport const ngPackagr = (): NgPackagr =>\n new NgPackagr([\n // Add default providers to this list.\n ...PACKAGE_PROVIDERS,\n ...ENTRY_POINT_PROVIDERS\n ]);\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as ng from '@angular/compiler-cli';
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
|
-
import { TsConfig } from '../ts/tsconfig';
|
|
4
3
|
import { FileCache } from '../file/file-cache';
|
|
5
4
|
import { StylesheetProcessor } from '../ng-v5/entry-point/resources/stylesheet-processor';
|
|
6
|
-
export declare function compileSourceFiles(tsConfig:
|
|
5
|
+
export declare function compileSourceFiles(tsConfig: ng.ParsedConfiguration, sourcesFileCache: FileCache, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor: StylesheetProcessor, extraOptions?: Partial<ng.CompilerOptions>, declarationDir?: string): Promise<void>;
|
|
@@ -8,9 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const fs = require("fs-extra");
|
|
12
11
|
const ng = require("@angular/compiler-cli");
|
|
13
|
-
const path = require("path");
|
|
14
12
|
const log = require("../util/log");
|
|
15
13
|
const create_emit_callback_1 = require("./create-emit-callback");
|
|
16
14
|
const redirect_write_file_compiler_host_1 = require("../ts/redirect-write-file-compiler-host");
|
|
@@ -30,25 +28,14 @@ function compileSourceFiles(tsConfig, sourcesFileCache, moduleResolutionCache, s
|
|
|
30
28
|
});
|
|
31
29
|
// Don't use `ng.emit` as it doesn't output all errors.
|
|
32
30
|
// https://github.com/angular/angular/issues/24024
|
|
31
|
+
const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;
|
|
33
32
|
const result = ng.performCompilation({
|
|
34
33
|
rootNames: tsConfig.rootNames,
|
|
35
34
|
options: tsConfigOptions,
|
|
36
35
|
host: ngCompilerHost,
|
|
37
36
|
emitCallback: create_emit_callback_1.createEmitCallback(tsConfigOptions),
|
|
38
|
-
emitFlags
|
|
37
|
+
emitFlags
|
|
39
38
|
});
|
|
40
|
-
// XX(hack): redirect the `*.metadata.json` to the correct outDir
|
|
41
|
-
// @link https://github.com/angular/angular/pull/21787
|
|
42
|
-
if (declarationDir) {
|
|
43
|
-
const flatModuleFile = tsConfigOptions.flatModuleOutFile;
|
|
44
|
-
const flatModuleFileExtension = path.extname(flatModuleFile);
|
|
45
|
-
const metadataBundleFile = flatModuleFile.replace(flatModuleFileExtension, '.metadata.json');
|
|
46
|
-
const metadataSrc = path.resolve(tsConfigOptions.declarationDir, metadataBundleFile);
|
|
47
|
-
const metadataDest = path.resolve(declarationDir, metadataBundleFile);
|
|
48
|
-
if (metadataDest !== metadataSrc && fs.existsSync(metadataSrc)) {
|
|
49
|
-
fs.moveSync(metadataSrc, metadataDest, { overwrite: true });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
39
|
const exitCode = ng.exitCodeFromResult(result.diagnostics);
|
|
53
40
|
return exitCode === 0 ? Promise.resolve() : Promise.reject(new Error(ng.formatDiagnostics(result.diagnostics)));
|
|
54
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,4CAA4C;AAE5C,mCAAmC;AACnC,iEAA4D;AAC5D,+FAAwF;AACxF,mEAA8D;AAI9D,4BACE,QAAgC,EAChC,gBAA2B,EAC3B,qBAA+C,EAC/C,mBAAwC,EACxC,YAA0C,EAC1C,cAAuB;;QAEvB,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAEvC,MAAM,eAAe,qBAA4B,QAAQ,CAAC,OAAO,EAAK,YAAY,CAAE,CAAC;QAErF,IAAI,cAAc,GAAG,uCAAiB,CAAC,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;QACtH,IAAI,cAAc,EAAE;YAClB,cAAc,GAAG,iEAA6B,CAAC,cAAc,EAAE,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;SAC1G;QAED,kBAAkB;QAClB,MAAM,cAAc,GAAG,EAAE,CAAC,kBAAkB,CAAC;YAC3C,OAAO,EAAE,eAAe;YACxB,MAAM,EAAE,cAAc;SACvB,CAAC,CAAC;QAEH,uDAAuD;QACvD,kDAAkD;QAClD,MAAM,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;QAErF,MAAM,MAAM,GAAG,EAAE,CAAC,kBAAkB,CAAC;YACnC,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,cAAc;YACpB,YAAY,EAAE,yCAAkB,CAAC,eAAe,CAAC;YACjD,SAAS;SACV,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3D,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CAAA;AArCD,gDAqCC","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 { FileCache } from '../file/file-cache';\nimport { StylesheetProcessor } from '../ng-v5/entry-point/resources/stylesheet-processor';\n\nexport async function compileSourceFiles(\n tsConfig: ng.ParsedConfiguration,\n sourcesFileCache: FileCache,\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(tsConfigOptions, sourcesFileCache, moduleResolutionCache, stylesheetProcessor);\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 // Don't use `ng.emit` as it doesn't output all errors.\n // https://github.com/angular/angular/issues/24024\n const emitFlags = tsConfigOptions.declaration ? tsConfig.emitFlags : ng.EmitFlags.JS;\n\n const result = ng.performCompilation({\n rootNames: tsConfig.rootNames,\n options: tsConfigOptions,\n host: ngCompilerHost,\n emitCallback: createEmitCallback(tsConfigOptions),\n emitFlags\n });\n\n const exitCode = ng.exitCodeFromResult(result.diagnostics);\n return exitCode === 0 ? Promise.resolve() : Promise.reject(new Error(ng.formatDiagnostics(result.diagnostics)));\n}\n"]}
|
|
@@ -28,8 +28,8 @@ function createEmitCallback(options) {
|
|
|
28
28
|
}
|
|
29
29
|
const tsickleHost = {
|
|
30
30
|
shouldSkipTsickleProcessing: fileName => /\.d\.ts$/.test(fileName) || GENERATED_FILES.test(fileName),
|
|
31
|
-
pathToModuleName: (
|
|
32
|
-
shouldIgnoreWarningsForPath:
|
|
31
|
+
pathToModuleName: (_context, _importPath) => '',
|
|
32
|
+
shouldIgnoreWarningsForPath: _filePath => false,
|
|
33
33
|
fileNameToModuleId: fileName => fileName,
|
|
34
34
|
googmodule: false,
|
|
35
35
|
untyped: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-emit-callback.js","sourceRoot":"","sources":["../../../src/lib/ngc/create-emit-callback.ts"],"names":[],"mappings":";AAAA,wFAAwF;AACxF,0EAA0E;AAC1E,uIAAuI;;AAEvI;;;;;;GAMG;AAEH,4IAA4I;AAC5I,MAAM,eAAe,GAAG,oEAAoE,CAAC;AAE7F,+CAAmC;AAGnC,kGAAkG;AAClG,4BAAmC,OAA4B;IAC7D,MAAM,mBAAmB,GAAG,OAAO,CAAC,aAAa,KAAK,YAAY,CAAC;IACnE,MAAM,uBAAuB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IACnE,
|
|
1
|
+
{"version":3,"file":"create-emit-callback.js","sourceRoot":"","sources":["../../../src/lib/ngc/create-emit-callback.ts"],"names":[],"mappings":";AAAA,wFAAwF;AACxF,0EAA0E;AAC1E,uIAAuI;;AAEvI;;;;;;GAMG;AAEH,4IAA4I;AAC5I,MAAM,eAAe,GAAG,oEAAoE,CAAC;AAE7F,+CAAmC;AAGnC,kGAAkG;AAClG,4BAAmC,OAA4B;IAC7D,MAAM,mBAAmB,GAAG,OAAO,CAAC,aAAa,KAAK,YAAY,CAAC;IACnE,MAAM,uBAAuB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IACnE,IAAI,CAAC,mBAAmB,IAAI,CAAC,uBAAuB,EAAE;QACpD,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,mBAAmB,EAAE;QACvB,mFAAmF;QACnF,iEAAiE;QACjE,mCAAmC;QACnC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;KACtC;IACD,MAAM,WAAW,GAWb;QACF,2BAA2B,EAAE,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC;QACpG,gBAAgB,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE;QAC/C,2BAA2B,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK;QAC/C,kBAAkB,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ;QACxC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,IAAI;QACb,2BAA2B,EAAE,KAAK;QAClC,mBAAmB;QACnB,uBAAuB;KACxB,CAAC;IAEF,OAAO,CAAC,EACN,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GAAG,EAAE,EACvB,IAAI,EACJ,OAAO,EACR,EAAE,EAAE,CACH,OAAO,CAAC,eAAe,CACrB,OAAO,oBACF,WAAW,IAAE,OAAO,EAAE,IAAI,KAC/B,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB;QACE,QAAQ,EAAE,kBAAkB,CAAC,MAAM;QACnC,OAAO,EAAE,kBAAkB,CAAC,KAAK;KAClC,CACF,CAAC;AACN,CAAC;AA3DD,gDA2DC","sourcesContent":["// XX: internal in ngc's `main()`, a tsickle emit callback is passed to the tsc compiler\n// ... blatanlty copy-paste the emit callback here. it's not a public api.\n// ... @link https://github.com/angular/angular/blob/24bf3e2a251634811096b939e61d63297934579e/packages/compiler-cli/src/main.ts#L36-L38\n\n/*\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 */\n\n// @link https://github.com/angular/angular/blob/24bf3e2a251634811096b939e61d63297934579e/packages/compiler-cli/src/transformers/util.ts#L14\nconst GENERATED_FILES = /(.*?)\\.(ngfactory|shim\\.ngstyle|ngstyle|ngsummary)\\.(js|d\\.ts|ts)$/;\n\nimport * as tsickle from 'tsickle';\nimport * as api from '@angular/compiler-cli/src/transformers/api';\n\n// @link https://github.com/angular/angular/blob/83d207d/packages/compiler-cli/src/main.ts#L42-L84\nexport function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback | undefined {\n const transformDecorators = options.annotationsAs !== 'decorators';\n const transformTypesToClosure = options.annotateForClosureCompiler;\n if (!transformDecorators && !transformTypesToClosure) {\n return undefined;\n }\n if (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 const tsickleHost: Pick<\n tsickle.TsickleHost,\n | 'shouldSkipTsickleProcessing'\n | 'pathToModuleName'\n | 'shouldIgnoreWarningsForPath'\n | 'fileNameToModuleId'\n | 'googmodule'\n | 'untyped'\n | 'convertIndexImportShorthand'\n | 'transformDecorators'\n | 'transformTypesToClosure'\n > = {\n shouldSkipTsickleProcessing: fileName => /\\.d\\.ts$/.test(fileName) || GENERATED_FILES.test(fileName),\n pathToModuleName: (_context, _importPath) => '',\n shouldIgnoreWarningsForPath: _filePath => false,\n fileNameToModuleId: fileName => fileName,\n googmodule: false,\n untyped: true,\n convertIndexImportShorthand: false,\n transformDecorators,\n transformTypesToClosure\n };\n\n return ({\n program,\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers = {},\n host,\n options\n }) =>\n tsickle.emitWithTsickle(\n program,\n { ...tsickleHost, options, host },\n host,\n options,\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n {\n beforeTs: customTransformers.before,\n afterTs: customTransformers.after\n }\n );\n}\n"]}
|
|
@@ -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,uCAA8C;AAI9C,2BACE,eAAmC,EACnC,gBAA2B,EAC3B,qBAA+C,EAC/C,mBAAyC;IAEzC,MAAM,YAAY,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAE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AAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC/B,+BAA+B;gBAC/B,yFAAyF;gBACzF,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC3D,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;oBAC/C,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;AAvFD,8CAuFC","sourcesContent":["import * as ts from 'typescript';\nimport * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport { ensureUnixPath } from '../util/path';\nimport { FileCache } from '../file/file-cache';\nimport { StylesheetProcessor } from '../ng-v5/entry-point/resources/stylesheet-processor';\n\nexport function cacheCompilerHost(\n compilerOptions: ng.CompilerOptions,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor\n): ng.CompilerHost {\n const compilerHost = ng.createCompilerHost({ options: compilerOptions });\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 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 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 resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n return path.resolve(path.dirname(containingFilePath), resourceName);\n },\n\n readResource: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n // todo: transform styles here.\n // the empty string is needed because of include paths file's won't be resolved properly.\n cache.content = compilerHost.readFile.call(this, fileName);\n if (!/(html|htm)$/.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"]}
|
|
@@ -11,7 +11,7 @@ const path = require("path");
|
|
|
11
11
|
function redirectWriteFileCompilerHost(compilerHost, baseDir, declarationDir) {
|
|
12
12
|
return Object.assign({}, compilerHost, { writeFile: (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
13
13
|
let filePath = fileName;
|
|
14
|
-
if (
|
|
14
|
+
if (/(\.d\.ts|\.metadata\.json)$/.test(fileName)) {
|
|
15
15
|
const projectRelativePath = path.relative(baseDir, fileName);
|
|
16
16
|
filePath = path.resolve(declarationDir, projectRelativePath);
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
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,uCACE,YAA6B,EAC7B,OAAe,EACf,cAAsB;IAEtB,
|
|
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,uCACE,YAA6B,EAC7B,OAAe,EACf,cAAsB;IAEtB,yBACK,YAAY,IACf,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"]}
|
package/lib/ts/tsconfig.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import * as ng from '@angular/compiler-cli
|
|
1
|
+
import * as ng from '@angular/compiler-cli';
|
|
2
2
|
import { EntryPointNode } from '../ng-v5/nodes';
|
|
3
|
-
/**
|
|
4
|
-
* TypeScript configuration used internally (marker typer).
|
|
5
|
-
*/
|
|
6
|
-
export declare type TsConfig = ng.ParsedConfiguration;
|
|
7
3
|
/**
|
|
8
4
|
* Reads the default TypeScript configuration.
|
|
9
5
|
*/
|
|
10
|
-
export declare function readDefaultTsConfig(fileName?: string):
|
|
6
|
+
export declare function readDefaultTsConfig(fileName?: string): ng.ParsedConfiguration;
|
|
11
7
|
/**
|
|
12
8
|
* Creates a parsed TypeScript configuration object.
|
|
13
9
|
*
|
|
14
10
|
* @param values File path or parsed configuration.
|
|
15
11
|
*/
|
|
16
|
-
export declare function createDefaultTsConfig(values?:
|
|
12
|
+
export declare function createDefaultTsConfig(values?: ng.ParsedConfiguration | string): ng.ParsedConfiguration;
|
|
17
13
|
/**
|
|
18
14
|
* Initializes TypeScript Compiler options and Angular Compiler options by overriding the
|
|
19
15
|
* default config with entry point-specific values.
|
|
20
16
|
*/
|
|
21
17
|
export declare const initializeTsConfig: (defaultTsConfig: ng.ParsedConfiguration, entryPoints: EntryPointNode[]) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Set the paths for entrypoint dependencies.
|
|
20
|
+
*
|
|
21
|
+
* This doesn't mutate the object.
|
|
22
|
+
*
|
|
23
|
+
* @param parsedTsConfig - A parsed tsconfig
|
|
24
|
+
* @param entryPoints - A list of entryPoints
|
|
25
|
+
* @param pointToSource Point the path mapping to either the source code or emitted declarations.
|
|
26
|
+
* Typically for analysis one should point to the source files while for a compilation once should use the emitted declarations
|
|
27
|
+
*/
|
|
28
|
+
export declare function setDependenciesTsConfigPaths(parsedTsConfig: ng.ParsedConfiguration, entryPoints: EntryPointNode[], pointToSource?: boolean): any;
|