ng-packagr 13.3.1 → 14.0.0-next.10
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/README.md +6 -26
- package/lib/esbuild/esbuild-executor.d.ts +2 -2
- package/lib/esbuild/esbuild-executor.js +6 -14
- package/lib/esbuild/esbuild-executor.js.map +1 -1
- package/lib/file-system/file-watcher.js +1 -0
- package/lib/file-system/file-watcher.js.map +1 -1
- package/lib/graph/build-graph.js +1 -1
- package/lib/graph/build-graph.js.map +1 -1
- package/lib/ng-package/discover-packages.js +19 -31
- package/lib/ng-package/discover-packages.js.map +1 -1
- package/lib/ng-package/entry-point/analyse-sources.transform.js +2 -1
- package/lib/ng-package/entry-point/analyse-sources.transform.js.map +1 -1
- package/lib/ng-package/entry-point/entry-point.js +3 -2
- package/lib/ng-package/entry-point/entry-point.js.map +1 -1
- package/lib/ng-package/entry-point/write-package.transform.js +112 -90
- package/lib/ng-package/entry-point/write-package.transform.js.map +1 -1
- package/lib/ng-package/package.d.ts +3 -4
- package/lib/ng-package/package.js +2 -5
- package/lib/ng-package/package.js.map +1 -1
- package/lib/ng-package/schema.js +1 -0
- package/lib/ng-package/schema.js.map +1 -1
- package/lib/styles/stylesheet-processor.d.ts +0 -6
- package/lib/styles/stylesheet-processor.js +2 -9
- package/lib/styles/stylesheet-processor.js.map +1 -1
- package/lib/ts/cache-compiler-host.d.ts +3 -2
- package/lib/ts/cache-compiler-host.js +11 -0
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/lib/ts/ngcc-transform-compiler-host.js +2 -1
- package/lib/ts/ngcc-transform-compiler-host.js.map +1 -1
- package/lib/utils/fs.d.ts +1 -0
- package/lib/utils/fs.js +1 -2
- package/lib/utils/fs.js.map +1 -1
- package/ng-package.schema.d.ts +23 -1
- package/ng-package.schema.js.map +1 -1
- package/ng-package.schema.json +42 -2
- package/package.json +22 -22
- package/lib/esbuild/esbuild-check.js +0 -8
- package/package.schema.json +0 -15
package/README.md
CHANGED
|
@@ -4,21 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/ng-packagr)
|
|
7
|
-
[](https://github.com/ng-packagr/ng-packagr/blob/
|
|
8
|
-
[](https://github.com/ng-packagr/ng-packagr/blob/main/LICENSE)
|
|
8
|
+
[](https://circleci.com/gh/ng-packagr/ng-packagr)
|
|
9
9
|
|
|
10
10
|
[](https://github.com/ng-packagr/ng-packagr)
|
|
11
11
|
[](https://www.npmjs.com/package/ng-packagr)
|
|
12
12
|
[](https://renovateapp.com/)
|
|
13
13
|
|
|
14
|
-
## Credits
|
|
15
|
-
|
|
16
|
-
### Contributors
|
|
17
|
-
|
|
18
|
-
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
|
19
|
-
|
|
20
|
-
<a href="https://github.com/ng-packagr/ng-packagr/graphs/contributors"><img src="https://opencollective.com/ng-packagr/contributors.svg?width=890&button=false" /></a>
|
|
21
|
-
|
|
22
14
|
## Installation
|
|
23
15
|
|
|
24
16
|
```bash
|
|
@@ -28,33 +20,22 @@ npm install -D ng-packagr
|
|
|
28
20
|
## Usage Example
|
|
29
21
|
|
|
30
22
|
Let's walk through a _getting started_ that'll build an Angular library from TypeScript sources and create a distribution-ready npm package:
|
|
31
|
-
create a `package.json` file
|
|
23
|
+
create a `ng-package.json` file and run `ng-packagr -p package.json`
|
|
32
24
|
– Here we go:
|
|
33
25
|
|
|
34
26
|
```json
|
|
35
27
|
{
|
|
36
|
-
"$schema": "./node_modules/ng-packagr/package.schema.json",
|
|
37
|
-
|
|
38
|
-
"version": "1.0.0",
|
|
39
|
-
"ngPackage": {
|
|
40
|
-
"lib": {
|
|
41
|
-
"entryFile": "public_api.ts"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
28
|
+
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
|
|
29
|
+
...
|
|
44
30
|
}
|
|
45
31
|
```
|
|
46
32
|
|
|
47
|
-
Note 1: Paths in the `ngPackage` section are resolved relative to the location of the `package.json` file.
|
|
48
|
-
In the above example, `public_api.ts` is the entry file to the library's sources and must be placed next to `package.json` (a sibling in the same folder).
|
|
49
|
-
|
|
50
|
-
Note 2: referencing the `$schema` enables JSON editing support (auto-completion for configuration) in IDEs like [VSCode](https://github.com/Microsoft/vscode).
|
|
51
|
-
|
|
52
33
|
You can easily run _ng-packagr_ through a npm/yarn script:
|
|
53
34
|
|
|
54
35
|
```json
|
|
55
36
|
{
|
|
56
37
|
"scripts": {
|
|
57
|
-
"build": "ng-packagr -p package.json"
|
|
38
|
+
"build": "ng-packagr -p ng-package.json"
|
|
58
39
|
}
|
|
59
40
|
}
|
|
60
41
|
```
|
|
@@ -78,7 +59,6 @@ Create one `package.json` per npm package, run _ng-packagr_ for each!
|
|
|
78
59
|
* :checkered_flag: Bundles your library in FESM2020
|
|
79
60
|
* :school_satchel: npm package can be consumed by [Angular CLI](https://github.com/angular/angular-cli), [Webpack](https://github.com/webpack/webpack), or [SystemJS](https://github.com/systemjs/systemjs)
|
|
80
61
|
* :dancer: Creates type definitions (`.d.ts`)
|
|
81
|
-
* :trophy: Auto-discovers and bundles secondary entry points such as `@my/foo`, `@my/foo/testing`, `@my/foo/bar`
|
|
82
62
|
* :mag_right: Creates [scoped and non-scoped packages](https://docs.npmjs.com/misc/scope) for publishing to npm registry
|
|
83
63
|
* :surfer: Inlines Templates and Stylesheets
|
|
84
64
|
* :sparkles: CSS Features
|
|
@@ -28,9 +28,9 @@ export declare class EsbuildExecutor implements Pick<typeof import('esbuild'), '
|
|
|
28
28
|
/**
|
|
29
29
|
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
30
30
|
*
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
32
32
|
*/
|
|
33
|
-
static hasNativeSupport(): boolean
|
|
33
|
+
static hasNativeSupport(): Promise<boolean>;
|
|
34
34
|
/**
|
|
35
35
|
* Initializes the esbuild transform and format messages functions.
|
|
36
36
|
*
|
|
@@ -31,8 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.EsbuildExecutor = void 0;
|
|
34
|
-
const child_process_1 = require("child_process");
|
|
35
|
-
const path = __importStar(require("path"));
|
|
36
34
|
/**
|
|
37
35
|
* Provides the ability to execute esbuild regardless of the current platform's support
|
|
38
36
|
* for using the native variant of esbuild. The native variant will be preferred (assuming
|
|
@@ -57,20 +55,14 @@ class EsbuildExecutor {
|
|
|
57
55
|
/**
|
|
58
56
|
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
59
57
|
*
|
|
60
|
-
* @returns
|
|
58
|
+
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
61
59
|
*/
|
|
62
|
-
static hasNativeSupport() {
|
|
60
|
+
static async hasNativeSupport() {
|
|
63
61
|
// Try to use native variant to ensure it is functional for the platform.
|
|
64
|
-
// Spawning a separate esbuild check process is used to determine if the native
|
|
65
|
-
// variant is viable. If check fails, the WASM variant is initialized instead.
|
|
66
|
-
// Attempting to call one of the native esbuild functions is not a viable test
|
|
67
|
-
// currently since esbuild spawn errors are currently not propagated through the
|
|
68
|
-
// call stack for the esbuild function. If this limitation is removed in the future
|
|
69
|
-
// then the separate process spawn check can be removed in favor of a direct function
|
|
70
|
-
// call check.
|
|
71
62
|
try {
|
|
72
|
-
const {
|
|
73
|
-
|
|
63
|
+
const { formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild')));
|
|
64
|
+
await formatMessages([], { kind: 'error' });
|
|
65
|
+
return true;
|
|
74
66
|
}
|
|
75
67
|
catch {
|
|
76
68
|
return false;
|
|
@@ -86,7 +78,7 @@ class EsbuildExecutor {
|
|
|
86
78
|
return;
|
|
87
79
|
}
|
|
88
80
|
// If the WASM variant was preferred at class construction or native is not supported, use WASM
|
|
89
|
-
if (this.alwaysUseWasm || !EsbuildExecutor.hasNativeSupport()) {
|
|
81
|
+
if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {
|
|
90
82
|
await this.useWasm();
|
|
91
83
|
this.initialized = true;
|
|
92
84
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-executor.js","sourceRoot":"","sources":["../../../src/lib/esbuild/esbuild-executor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"esbuild-executor.js","sourceRoot":"","sources":["../../../src/lib/esbuild/esbuild-executor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH;;;;;;GAMG;AACH,MAAa,eAAe;IAK1B;;;;;OAKG;IACH,YAAoB,gBAAgB,KAAK;QAArB,kBAAa,GAAb,aAAa,CAAQ;QARjC,gBAAW,GAAG,KAAK,CAAC;QAS1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE;YACxD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB;QAC3B,yEAAyE;QACzE,IAAI;YACF,MAAM,EAAE,cAAc,EAAE,GAAG,wDAAa,SAAS,GAAC,CAAC;YACnD,MAAM,cAAc,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAE5C,OAAO,IAAI,CAAC;SACb;QAAC,MAAM;YACN,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IACD;;;;OAIG;IACK,KAAK,CAAC,aAAa;QACzB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QAED,+FAA+F;QAC/F,IAAI,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,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\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\nimport type { FormatMessagesOptions, PartialMessage, TransformOptions, TransformResult } from 'esbuild';\n\n/**\n * Provides the ability to execute esbuild regardless of the current platform's support\n * for using the native variant of esbuild. The native variant will be preferred (assuming\n * the `alwaysUseWasm` constructor option is `false) due to its inherent performance advantages.\n * At first use of esbuild, a supportability test will be automatically performed and the\n * WASM-variant will be used if needed by the platform.\n */\nexport class EsbuildExecutor implements Pick<typeof import('esbuild'), 'transform' | 'formatMessages'> {\n private esbuildTransform: this['transform'];\n private esbuildFormatMessages: this['formatMessages'];\n private initialized = false;\n\n /**\n * Constructs an instance of the `EsbuildExecutor` class.\n *\n * @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be\n * performed; if false (default), the native variant will be preferred.\n */\n constructor(private alwaysUseWasm = false) {\n this.esbuildTransform = this.esbuildFormatMessages = () => {\n throw new Error('esbuild implementation missing');\n };\n }\n\n /**\n * Determines whether the native variant of esbuild can be used on the current platform.\n *\n * @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.\n */\n static async hasNativeSupport(): Promise<boolean> {\n // Try to use native variant to ensure it is functional for the platform.\n try {\n const { formatMessages } = await import('esbuild');\n await formatMessages([], { kind: 'error' });\n\n return true;\n } catch {\n return false;\n }\n }\n /**\n * Initializes the esbuild transform and format messages functions.\n *\n * @returns A promise that fulfills when esbuild has been loaded and available for use.\n */\n private async ensureEsbuild(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // If the WASM variant was preferred at class construction or native is not supported, use WASM\n if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {\n await this.useWasm();\n this.initialized = true;\n\n return;\n }\n\n try {\n // Use the faster native variant if available.\n const { transform, formatMessages } = await import('esbuild');\n\n this.esbuildTransform = transform;\n this.esbuildFormatMessages = formatMessages;\n } catch {\n // If the native variant is not installed then use the WASM-based variant\n await this.useWasm();\n }\n\n this.initialized = true;\n }\n\n /**\n * Transitions an executor instance to use the WASM-variant of esbuild.\n */\n private async useWasm(): Promise<void> {\n const { transform, formatMessages } = await import('esbuild-wasm');\n this.esbuildTransform = transform;\n this.esbuildFormatMessages = formatMessages;\n\n // The ESBUILD_BINARY_PATH environment variable cannot exist when attempting to use the\n // WASM variant. If it is then the binary located at the specified path will be used instead\n // of the WASM variant.\n delete process.env.ESBUILD_BINARY_PATH;\n\n this.alwaysUseWasm = true;\n }\n\n async transform(input: string, options?: TransformOptions): Promise<TransformResult> {\n await this.ensureEsbuild();\n\n return this.esbuildTransform(input, options);\n }\n\n async formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]> {\n await this.ensureEsbuild();\n\n return this.esbuildFormatMessages(messages, options);\n }\n}\n"]}
|
|
@@ -59,6 +59,7 @@ function createFileWatch(basePaths, ignoredPaths = []) {
|
|
|
59
59
|
watcher: watch,
|
|
60
60
|
onFileChange: new rxjs_1.Observable(observer => {
|
|
61
61
|
watch.on('all', (event, filePath) => handleFileChange(event, filePath, observer));
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
62
63
|
return () => watch.close();
|
|
63
64
|
}),
|
|
64
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAqC;AACrC,2BAA8B;AAC9B,2CAA6B;AAC7B,+BAA4C;AAC5C,kDAAoC;AACpC,wCAA+C;AAU/C,SAAgB,eAAe,CAC7B,SAA4B,EAC5B,eAAoC,EAAE;IAKtC,GAAG,CAAC,KAAK,CAAC,mCAAmC,SAAS,mBAAmB,YAAY,EAAE,CAAC,CAAC;IAEzF,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE;QAC/B,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,CAAC,G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AO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AA9CD,0CA8CC","sourcesContent":["import * as chokidar from 'chokidar';\nimport { platform } from 'os';\nimport * as path from 'path';\nimport { Observable, Observer } from 'rxjs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\ntype AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';\nexport type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;\n\nexport interface FileChangedEvent {\n filePath: string;\n event: FileWatchEvent;\n}\n\nexport function createFileWatch(\n basePaths: string | string[],\n ignoredPaths: (RegExp | string)[] = [],\n): {\n watcher: chokidar.FSWatcher;\n onFileChange: Observable<FileChangedEvent>;\n} {\n log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);\n\n const watch = chokidar.watch([], {\n ignoreInitial: true,\n ignored: [...ignoredPaths, /\\.map$/],\n persistent: true,\n });\n\n const isLinux = platform() === 'linux';\n const handleFileChange = (event: AllFileWatchEvents, filePath: string, observer: Observer<FileChangedEvent>) => {\n log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);\n\n if (isLinux) {\n // Workaround for Linux where chokidar will not handle future events\n // for files that were unlinked and immediately recreated.\n watch.unwatch(filePath);\n watch.add(filePath);\n }\n\n if (event === 'unlinkDir' || event === 'addDir') {\n // we don't need to trigger on directory removed or renamed as chokidar will fire the changes for each file\n return;\n }\n\n observer.next({\n filePath: ensureUnixPath(path.resolve(filePath)),\n event,\n });\n };\n\n return {\n watcher: watch,\n onFileChange: new Observable(observer => {\n watch.on('all', (event: AllFileWatchEvents, filePath: string) => handleFileChange(event, filePath, observer));\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => watch.close();\n }),\n };\n}\n"]}
|
package/lib/graph/build-graph.js
CHANGED
|
@@ -26,7 +26,7 @@ class BuildGraph {
|
|
|
26
26
|
oldNode['_dependees'].delete(oldNode);
|
|
27
27
|
}
|
|
28
28
|
if (this.watcher && node.url.startsWith(nodes_1.URL_PROTOCOL_FILE)) {
|
|
29
|
-
this.watcher.add(node.url.
|
|
29
|
+
this.watcher.add(node.url.slice(nodes_1.URL_PROTOCOL_FILE.length));
|
|
30
30
|
}
|
|
31
31
|
this.store.set(node.url, node);
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+CAAwD;AAqBxD;;;GAGG;AACH,MAAa,UAAU;IAAvB;QACU,UAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAwD1C,CAAC;IArDQ,GAAG,CAAC,KAAoB;QAC7B,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1C;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,IAAU;QACvB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC5B,+BAA+B;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,yBAAiB,CAAC,EAAE;YAC1D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"build-graph.js","sourceRoot":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AAO;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAEnC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAEM,IAAI,CAAC,EAAmB;QAC7B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,MAAM,CAAwB,EAA6B;QAChE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,CAAQ,CAAC;IAC1C,CAAC;IAEM,IAAI,CAAwB,EAA6B;QAC9D,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAkB,CAAC;IAClD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAzDD,gCAyDC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { URL_PROTOCOL_FILE } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T, index: number): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T, index: number): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n private store = new Map<string, Node>();\n watcher?: FSWatcher;\n\n public put(value: Node | Node[]) {\n if (value instanceof Array) {\n value.forEach(node => this.insert(node));\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher && node.url.startsWith(URL_PROTOCOL_FILE)) {\n this.watcher.add(node.url.slice(URL_PROTOCOL_FILE.length));\n }\n\n this.store.set(node.url, node);\n }\n\n public get(url: string): Node {\n return this.store.get(url);\n }\n\n public has(url: string): boolean {\n return this.store.has(url);\n }\n\n public entries(): Node[] {\n const values = this.store.values();\n\n return Array.from(values);\n }\n\n public some(by: SimplePredicate): boolean {\n return this.entries().some(by);\n }\n\n public filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n return this.entries().filter(by) as T[];\n }\n\n public find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n return this.entries().find(by) as T | undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n"]}
|
|
@@ -44,7 +44,7 @@ async function readConfigFile(filePath) {
|
|
|
44
44
|
return (0, jsonc_parser_1.parse)(data, undefined, { allowTrailingComma: true });
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Resolves a user's package by testing
|
|
47
|
+
* Resolves a user's package by testing 'ng-package.json', or 'ng-package.js'.
|
|
48
48
|
*
|
|
49
49
|
* @param folderPathOrFilePath A path pointing either to a file or a directory
|
|
50
50
|
* @param isSecondary A boolean determining if this is a secondary package
|
|
@@ -55,21 +55,8 @@ async function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
55
55
|
const fullPath = path.resolve(folderPathOrFilePath);
|
|
56
56
|
const pathStats = await (0, fs_1.stat)(fullPath);
|
|
57
57
|
const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);
|
|
58
|
-
const pkgJsonPath = path.join(basePath, 'package.json');
|
|
59
|
-
const packageJson = await readConfigFile(pkgJsonPath);
|
|
60
|
-
if (!packageJson && !isSecondary) {
|
|
61
|
-
throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);
|
|
62
|
-
}
|
|
63
|
-
if (packageJson && typeof packageJson !== 'object') {
|
|
64
|
-
throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);
|
|
65
|
-
}
|
|
66
58
|
let ngPackageJson;
|
|
67
|
-
if (
|
|
68
|
-
// Read `ngPackage` from `package.json`
|
|
69
|
-
ngPackageJson = { ...packageJson['ngPackage'] };
|
|
70
|
-
log.warn(`Found configuration in ${pkgJsonPath}.\nConfiguring ng-packagr in "package.json" is deprecated. Use "ng-package.json" instead.`);
|
|
71
|
-
}
|
|
72
|
-
else if (pathStats.isDirectory()) {
|
|
59
|
+
if (pathStats.isDirectory()) {
|
|
73
60
|
ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));
|
|
74
61
|
if (!ngPackageJson) {
|
|
75
62
|
ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));
|
|
@@ -81,9 +68,20 @@ async function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
81
68
|
if (ngPackageJson) {
|
|
82
69
|
ngPackageJson = (_a = ngPackageJson['default']) !== null && _a !== void 0 ? _a : ngPackageJson;
|
|
83
70
|
(0, schema_1.validateNgPackageSchema)(ngPackageJson);
|
|
71
|
+
let packageJson = {};
|
|
72
|
+
if (!isSecondary) {
|
|
73
|
+
const pkgJsonPath = path.join(basePath, 'package.json');
|
|
74
|
+
packageJson = await readConfigFile(pkgJsonPath);
|
|
75
|
+
if (!packageJson) {
|
|
76
|
+
throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);
|
|
77
|
+
}
|
|
78
|
+
if (packageJson && typeof packageJson !== 'object') {
|
|
79
|
+
throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
84
82
|
return {
|
|
85
83
|
basePath,
|
|
86
|
-
packageJson
|
|
84
|
+
packageJson,
|
|
87
85
|
ngPackageJson,
|
|
88
86
|
};
|
|
89
87
|
}
|
|
@@ -92,35 +90,25 @@ async function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
92
90
|
return undefined;
|
|
93
91
|
}
|
|
94
92
|
if (pathStats.isFile()) {
|
|
95
|
-
// a project file was specified but was in valid
|
|
96
|
-
if (path.basename(folderPathOrFilePath) === 'package.json') {
|
|
97
|
-
throw new Error(`Cannot read a package from 'package.json' without 'ngPackage' property.`);
|
|
98
|
-
}
|
|
99
93
|
throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);
|
|
100
94
|
}
|
|
101
95
|
throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);
|
|
102
96
|
}
|
|
103
97
|
/**
|
|
104
|
-
* Scans `directoryPath` and sub-folders, looking for `package
|
|
105
|
-
* Similar to `find ${directoryPath} --name package
|
|
98
|
+
* Scans `directoryPath` and sub-folders, looking for `ng-package` files.
|
|
99
|
+
* Similar to `find ${directoryPath} --name ng-package --exec dirname {}`.
|
|
106
100
|
*
|
|
107
101
|
* @param directoryPath Path pointing to a directory
|
|
108
102
|
* @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.
|
|
109
103
|
*/
|
|
110
104
|
async function findSecondaryPackagesPaths(directoryPath, excludeFolder) {
|
|
111
|
-
const ignore = [
|
|
112
|
-
|
|
113
|
-
'**/.git/**',
|
|
114
|
-
`${path.resolve(directoryPath, excludeFolder)}/**`,
|
|
115
|
-
`${directoryPath}/package.json`,
|
|
116
|
-
`${directoryPath}/ng-package.json`,
|
|
117
|
-
];
|
|
118
|
-
const filePaths = await (0, glob_1.globFiles)(`${directoryPath}/**/{package,ng-package}.json`, {
|
|
105
|
+
const ignore = ['**/node_modules/**', '**/.git/**', `${excludeFolder}/**`, 'ng-package.json'];
|
|
106
|
+
const filePaths = await (0, glob_1.globFiles)(`**/ng-package.json`, {
|
|
119
107
|
ignore,
|
|
120
108
|
nodir: true,
|
|
121
109
|
cwd: directoryPath,
|
|
122
110
|
});
|
|
123
|
-
return filePaths.map(path.dirname);
|
|
111
|
+
return filePaths.map(subpath => path.dirname(path.join(directoryPath, subpath)));
|
|
124
112
|
}
|
|
125
113
|
/**
|
|
126
114
|
* Reads a secondary entry point from it's package file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,2CAA6B;AAC7B,oCAAqD;AACrD,wCAA0C;AAC1C,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAyD;AACzD,uCAAsC;AACtC,qCAAmD;AAWnD,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAA,WAAM,EAAC,QAAQ,CAAC,CAAC,EAAE;QAC7B,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,yDAAc,QAAQ,IAAE;KACzB;IAED,MAAM,IAAI,GAAG,MAAM,IAAA,aAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/C,OAAO,IAAA,oBAAS,EAAC,IAAI,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,kBAAkB,CAAC,oBAA4B,EAAE,WAAW,GAAG,KAAK;;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,IAAA,SAAI,EAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7E,MAAM,WAAW,GAAG,IAAI,CAA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SAClE;KACF;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,GAAG,CAAC,KAAK,CAAC,iCAAiC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KAC3F;IAED,OAAO,IAAI,mBAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAtBD,4CAsBC","sourcesContent":["import { parse as parseJson } from 'jsonc-parser';\nimport * as path from 'path';\nimport { exists, readFile, stat } from '../utils/fs';\nimport { globFiles } from '../utils/glob';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { validateNgPackageSchema } from './schema';\n\ninterface UserPackage {\n /** Values from the `package.json` file of this user package. */\n packageJson: Record<string, any>;\n /** NgPackageConfig for this user package. */\n ngPackageJson: Record<string, any>;\n /** Absolute directory path of this user package. */\n basePath: string;\n}\n\nasync function readConfigFile(filePath: string): Promise<any> {\n if (!(await exists(filePath))) {\n return undefined;\n }\n\n if (filePath.endsWith('.js')) {\n return import(filePath);\n }\n\n const data = await readFile(filePath, 'utf-8');\n\n return parseJson(data, undefined, { allowTrailingComma: true });\n}\n\n/**\n * Resolves a user's package by testing for 'package.json', 'ng-package.json', or 'ng-package.js'.\n *\n * @param folderPathOrFilePath A path pointing either to a file or a directory\n * @param isSecondary A boolean determining if this is a secondary package\n * @return The user's package\n */\nasync function resolveUserPackage(folderPathOrFilePath: string, isSecondary = false): Promise<UserPackage | undefined> {\n const fullPath = path.resolve(folderPathOrFilePath);\n const pathStats = await stat(fullPath);\n const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);\n const pkgJsonPath = path.join(basePath, 'package.json');\n const packageJson: unknown = await readConfigFile(pkgJsonPath);\n\n if (!packageJson && !isSecondary) {\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);\n }\n\n if (packageJson && typeof packageJson !== 'object') {\n throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);\n }\n\n let ngPackageJson: unknown;\n if (packageJson && packageJson['ngPackage']) {\n // Read `ngPackage` from `package.json`\n ngPackageJson = { ...packageJson['ngPackage'] };\n log.warn(\n `Found configuration in ${pkgJsonPath}.\\nConfiguring ng-packagr in \"package.json\" is deprecated. Use \"ng-package.json\" instead.`,\n );\n } else if (pathStats.isDirectory()) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));\n if (!ngPackageJson) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));\n }\n } else {\n ngPackageJson = await readConfigFile(fullPath);\n }\n\n if (ngPackageJson) {\n ngPackageJson = ngPackageJson['default'] ?? ngPackageJson;\n\n validateNgPackageSchema(ngPackageJson);\n\n return {\n basePath,\n packageJson: packageJson || {},\n ngPackageJson,\n };\n }\n\n if (pathStats.isDirectory()) {\n // return even if it's undefined and use defaults when it's not a file\n return undefined;\n }\n\n if (pathStats.isFile()) {\n // a project file was specified but was in valid\n if (path.basename(folderPathOrFilePath) === 'package.json') {\n throw new Error(`Cannot read a package from 'package.json' without 'ngPackage' property.`);\n }\n\n throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);\n }\n\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);\n}\n\n/**\n * Scans `directoryPath` and sub-folders, looking for `package.json` files.\n * Similar to `find ${directoryPath} --name package.json --exec dirname {}`.\n *\n * @param directoryPath Path pointing to a directory\n * @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.\n */\nasync function findSecondaryPackagesPaths(directoryPath: string, excludeFolder: string): Promise<string[]> {\n const ignore = [\n '**/node_modules/**',\n '**/.git/**',\n `${path.resolve(directoryPath, excludeFolder)}/**`,\n `${directoryPath}/package.json`,\n `${directoryPath}/ng-package.json`,\n ];\n\n const filePaths = await globFiles(`${directoryPath}/**/{package,ng-package}.json`, {\n ignore,\n nodir: true,\n cwd: directoryPath,\n });\n\n return filePaths.map(path.dirname);\n}\n\n/**\n * Reads a secondary entry point from it's package file.\n *\n * @param primary The primary entry point.\n * @param userPackage The user package for the secondary entry point.\n */\nfunction secondaryEntryPoint(primary: NgEntryPoint, userPackage: UserPackage): NgEntryPoint {\n const { packageJson, ngPackageJson, basePath } = userPackage;\n if (path.resolve(basePath) === path.resolve(primary.basePath)) {\n log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);\n throw new Error(`Secondary entry point is already a primary.`);\n }\n\n const relativeSourcePath = path.relative(primary.basePath, basePath);\n const secondaryModuleId = ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);\n\n return new NgEntryPoint(packageJson, ngPackageJson, basePath, {\n moduleId: secondaryModuleId,\n primaryDestinationPath: primary.destinationPath,\n destinationPath: path.join(primary.destinationPath, relativeSourcePath),\n });\n}\n\nexport async function discoverPackages({ project }: { project: string }): Promise<NgPackage> {\n project = path.isAbsolute(project) ? project : path.resolve(project);\n\n const { packageJson, ngPackageJson, basePath } = await resolveUserPackage(project);\n const primary = new NgEntryPoint(packageJson, ngPackageJson, basePath);\n log.debug(`Found primary entry point: ${primary.moduleId}`);\n\n const folderPaths = await findSecondaryPackagesPaths(basePath, primary.$get('dest'));\n const secondaries: NgEntryPoint[] = [];\n\n for (const folderPath of folderPaths) {\n const secondaryPackage = await resolveUserPackage(folderPath, true);\n if (secondaryPackage) {\n secondaries.push(secondaryEntryPoint(primary, secondaryPackage));\n }\n }\n\n if (secondaries.length > 0) {\n log.debug(`Found secondary entry points: ${secondaries.map(e => e.moduleId).join(', ')}`);\n }\n\n return new NgPackage(basePath, primary, secondaries);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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AE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnF,MAAM,OAAO,GAAG,IAAI,0BAAY,CAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;IACvE,GAAG,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE5D,MAAM,WAAW,GAAG,MAAM,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACpE,IAAI,gBAAgB,EAAE;YACpB,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;SAClE;KACF;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,GAAG,CAAC,KAAK,CAAC,iCAAiC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KAC3F;IAED,OAAO,IAAI,mBAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAtBD,4CAsBC","sourcesContent":["import { parse as parseJson } from 'jsonc-parser';\nimport * as path from 'path';\nimport { exists, readFile, stat } from '../utils/fs';\nimport { globFiles } from '../utils/glob';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { validateNgPackageSchema } from './schema';\n\ninterface UserPackage {\n /** Values from the `package.json` file of this user package. */\n packageJson: Record<string, any>;\n /** NgPackageConfig for this user package. */\n ngPackageJson: Record<string, any>;\n /** Absolute directory path of this user package. */\n basePath: string;\n}\n\nasync function readConfigFile(filePath: string): Promise<any> {\n if (!(await exists(filePath))) {\n return undefined;\n }\n\n if (filePath.endsWith('.js')) {\n return import(filePath);\n }\n\n const data = await readFile(filePath, 'utf-8');\n\n return parseJson(data, undefined, { allowTrailingComma: true });\n}\n\n/**\n * Resolves a user's package by testing 'ng-package.json', or 'ng-package.js'.\n *\n * @param folderPathOrFilePath A path pointing either to a file or a directory\n * @param isSecondary A boolean determining if this is a secondary package\n * @return The user's package\n */\nasync function resolveUserPackage(folderPathOrFilePath: string, isSecondary = false): Promise<UserPackage | undefined> {\n const fullPath = path.resolve(folderPathOrFilePath);\n const pathStats = await stat(fullPath);\n const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);\n\n let ngPackageJson: unknown;\n if (pathStats.isDirectory()) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));\n if (!ngPackageJson) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));\n }\n } else {\n ngPackageJson = await readConfigFile(fullPath);\n }\n\n if (ngPackageJson) {\n ngPackageJson = ngPackageJson['default'] ?? ngPackageJson;\n\n validateNgPackageSchema(ngPackageJson);\n\n let packageJson: {} = {};\n if (!isSecondary) {\n const pkgJsonPath = path.join(basePath, 'package.json');\n packageJson = await readConfigFile(pkgJsonPath);\n\n if (!packageJson) {\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);\n }\n\n if (packageJson && typeof packageJson !== 'object') {\n throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);\n }\n }\n\n return {\n basePath,\n packageJson,\n ngPackageJson,\n };\n }\n\n if (pathStats.isDirectory()) {\n // return even if it's undefined and use defaults when it's not a file\n return undefined;\n }\n\n if (pathStats.isFile()) {\n throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);\n }\n\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);\n}\n\n/**\n * Scans `directoryPath` and sub-folders, looking for `ng-package` files.\n * Similar to `find ${directoryPath} --name ng-package --exec dirname {}`.\n *\n * @param directoryPath Path pointing to a directory\n * @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.\n */\nasync function findSecondaryPackagesPaths(directoryPath: string, excludeFolder: string): Promise<string[]> {\n const ignore = ['**/node_modules/**', '**/.git/**', `${excludeFolder}/**`, 'ng-package.json'];\n\n const filePaths = await globFiles(`**/ng-package.json`, {\n ignore,\n nodir: true,\n cwd: directoryPath,\n });\n\n return filePaths.map(subpath => path.dirname(path.join(directoryPath, subpath)));\n}\n\n/**\n * Reads a secondary entry point from it's package file.\n *\n * @param primary The primary entry point.\n * @param userPackage The user package for the secondary entry point.\n */\nfunction secondaryEntryPoint(primary: NgEntryPoint, userPackage: UserPackage): NgEntryPoint {\n const { packageJson, ngPackageJson, basePath } = userPackage;\n if (path.resolve(basePath) === path.resolve(primary.basePath)) {\n log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);\n throw new Error(`Secondary entry point is already a primary.`);\n }\n\n const relativeSourcePath = path.relative(primary.basePath, basePath);\n const secondaryModuleId = ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);\n\n return new NgEntryPoint(packageJson, ngPackageJson, basePath, {\n moduleId: secondaryModuleId,\n primaryDestinationPath: primary.destinationPath,\n destinationPath: path.join(primary.destinationPath, relativeSourcePath),\n });\n}\n\nexport async function discoverPackages({ project }: { project: string }): Promise<NgPackage> {\n project = path.isAbsolute(project) ? project : path.resolve(project);\n\n const { packageJson, ngPackageJson, basePath } = await resolveUserPackage(project);\n const primary = new NgEntryPoint(packageJson, ngPackageJson, basePath);\n log.debug(`Found primary entry point: ${primary.moduleId}`);\n\n const folderPaths = await findSecondaryPackagesPaths(basePath, primary.$get('dest'));\n const secondaries: NgEntryPoint[] = [];\n\n for (const folderPath of folderPaths) {\n const secondaryPackage = await resolveUserPackage(folderPath, true);\n if (secondaryPackage) {\n secondaries.push(secondaryEntryPoint(primary, secondaryPackage));\n }\n }\n\n if (secondaries.length > 0) {\n log.debug(`Found secondary entry points: ${secondaries.map(e => e.moduleId).join(', ')}`);\n }\n\n return new NgPackage(basePath, primary, secondaries);\n}\n"]}
|
|
@@ -46,7 +46,8 @@ function analyseEntryPoint(graph, entryPoint, entryPoints) {
|
|
|
46
46
|
const compilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, undefined, analysesSourcesFileCache);
|
|
47
47
|
const potentialDependencies = new Set();
|
|
48
48
|
compilerHost.resolveTypeReferenceDirectives = (moduleNames, containingFile, redirectedReference, options) => {
|
|
49
|
-
return moduleNames.map(
|
|
49
|
+
return moduleNames.map(name => {
|
|
50
|
+
const moduleName = typeof name === 'string' ? name : name.fileName;
|
|
50
51
|
if (!moduleName.startsWith('.')) {
|
|
51
52
|
if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {
|
|
52
53
|
potentialDependencies.add(moduleName);
|
|
@@ -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,+BAA4B;AAC5B,8CAAqC;AACrC,4DAA4B;AAG5B,sEAAiE;AACjE,yCAAwC;AACxC,2CAAkD;AAClD,oCAAgF;AAEnE,QAAA,uBAAuB,GAAc,IAAA,WAAI,EACpD,IAAA,eAAG,EAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAqB,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAqB,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IAEvF,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;IAChD,MAAM,WAAW,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAE1D,IAAA,WAAK,EAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAuB;QAC1C,2FAA2F;QAC3F,GAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAA8B;QAC3D,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,uCAAiB,EACpC,KAAK,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,wBAAwB,CACzB,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhD,YAAY,CAAC,8BAA8B,GAAG,CAC5C,
|
|
1
|
+
{"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":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AAK,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 { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport ts from 'typescript';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Transform } from '../../graph/transform';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, isEntryPoint, isPackage } from '../nodes';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n const dirtyEntryPoints: EntryPointNode[] = entryPoints.filter(x => x.state !== 'done');\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: PackageNode = graph.find(isPackage);\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n debug(`Analysing sources for ${moduleId}`);\n const tsConfigOptions: ts.CompilerOptions = {\n // Needed because of `Property 'extendedDiagnostics' is incompatible with index signature.`\n ...(entryPoint.data.tsConfig.options as ts.CompilerOptions),\n skipLibCheck: true,\n noLib: true,\n noEmit: true,\n types: [],\n target: ts.ScriptTarget.Latest,\n strict: false,\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n undefined,\n undefined,\n analysesSourcesFileCache,\n );\n\n const potentialDependencies = new Set<string>();\n\n compilerHost.resolveTypeReferenceDirectives = (\n moduleNames: string[] | ts.FileReference[],\n containingFile: string,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(name => {\n const moduleName = typeof name === 'string' ? name : name.fileName;\n\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const result = ts.resolveTypeReferenceDirective(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n redirectedReference,\n ).resolvedTypeReferenceDirective;\n\n return result;\n });\n };\n\n compilerHost.resolveModuleNames = (\n moduleNames: string[],\n containingFile: string,\n _reusedNames: string[] | undefined,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(moduleName => {\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n moduleResolutionCache,\n redirectedReference,\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 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"]}
|
|
@@ -98,7 +98,7 @@ class NgEntryPoint {
|
|
|
98
98
|
const pathJoinWithDest = (...paths) => path.join(primaryDestPath, ...paths);
|
|
99
99
|
return {
|
|
100
100
|
directory: (0, path_1.ensureUnixPath)(secondaryDir),
|
|
101
|
-
declarations: pathJoinWithDest(secondaryDir,
|
|
101
|
+
declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),
|
|
102
102
|
esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),
|
|
103
103
|
fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),
|
|
104
104
|
fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),
|
|
@@ -118,7 +118,8 @@ class NgEntryPoint {
|
|
|
118
118
|
return value;
|
|
119
119
|
}
|
|
120
120
|
get entryFile() {
|
|
121
|
-
|
|
121
|
+
// `./index.ts` -> `index.ts`
|
|
122
|
+
return path.posix.normalize(this.$get('lib.entryFile'));
|
|
122
123
|
}
|
|
123
124
|
get cssUrl() {
|
|
124
125
|
return this.$get('lib.cssUrl');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,2CAAkD;AAgBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACvB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAsC;QANvC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CAAyB;IACtD,CAAC;IAEJ,sEAAsE;IACtE,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,iDAAiD;IACjD,IAAW,qBAAqB;QAC9B,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,oEAAoE;IACpE,IAAW,eAAe;QACxB,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,OAAO,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;SAC3C;aAAM;YACL,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACvD;IACH,CAAC;IAED,IAAW,gBAAgB;QACzB,IAAI,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC3C,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC;YAC5D,YAAY,GAAG,IA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AAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjD;IACH,CAAC;CACF;AA3GD,oCA2GC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../../utils/path';\n\n/** A list of output absolute paths for various formats */\nexport interface DestinationFiles {\n /** Absolute path of this entry point `declarations` */\n declarations: string;\n /** Absolute path of this entry point `FESM2020` module */\n fesm2020: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2020` module */\n esm2020: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n}\n\n/**\n * An entry point - quoting Angular Package Format - is:\n *\n * > a module intended to be imported by the user. It is referenced by a unique module ID and\n * > exports the public API referenced by that module ID. An example is `@angular/core` or\n * > `@angular/core/testing`. Both entry points exist in the `@angular/core` package, but they\n * > export different symbols. A package can have many entry points.\n *\n * #### Public API, source file tree and build output\n *\n * An entry point serves as the root of a source tree.\n * The entry point's public API references one TypeScript source file (`*.ts`).\n * That source file, e.g. `public_api.ts`, references other source files who in turn may reference\n * other source files, thus creating a tree of source code files.\n * The source files may be TypeScript (`*.ts`), Templates (`.html`) or Stylesheets\n * (`.css`, `.scss`, ..), or other formats.\n *\n * The compilation process for an entry point is a series of transformations applied to the source\n * files, e.g. TypeScript compilation, Inlining of Stylesheets and Templates, and so on.\n * As a result of the compilation process, an entry point is transpiled to a set of artefacts\n * (the build output) which include a FESM'15 Bundle, a FESM'5 Bundle, AoT metadata, TypeScript\n * type definitions, and so on.\n *\n * #### Representation in the domain\n *\n * The set of artefacts is reflected by `NgArtefacts`;\n * one `NgEntryPoint` relates to one `NgArtefacts`.\n * The parent package of an entry point is reflected by `NgPackage`.\n */\nexport class NgEntryPoint {\n constructor(\n /** Values from the `package.json` file of this entry point. */\n public readonly packageJson: Record<string, any>,\n /** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */\n public readonly ngPackageJson: NgPackageConfig,\n /** Absolute directory path of this entry point's `package.json` location. */\n public readonly basePath: string,\n /** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */\n private readonly secondaryData?: { [key: string]: any },\n ) {}\n\n /** Absolute file path of the entry point's source code entry file. */\n public get entryFilePath(): string {\n return path.resolve(this.basePath, this.entryFile);\n }\n\n /** Whether or not the entrypoint is secondary */\n public get isSecondaryEntryPoint(): boolean {\n return !!this.secondaryData;\n }\n\n /** Absolute directory path of this entry point's 'package.json'. */\n public get destinationPath(): string {\n if (this.secondaryData) {\n return this.secondaryData.destinationPath;\n } else {\n return path.resolve(this.basePath, this.$get('dest'));\n }\n }\n\n public get destinationFiles(): DestinationFiles {\n let primaryDestPath = this.destinationPath;\n let secondaryDir = '';\n\n if (this.secondaryData) {\n primaryDestPath = this.secondaryData.primaryDestinationPath;\n secondaryDir = path.relative(primaryDestPath, this.secondaryData.destinationPath);\n }\n\n const flatModuleFile = this.flatModuleFile;\n const pathJoinWithDest = (...paths: string[]) => path.join(primaryDestPath, ...paths);\n\n return {\n directory: ensureUnixPath(secondaryDir),\n declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),\n esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),\n fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),\n };\n }\n\n public $get(key: string): any {\n const parts = key.split('.');\n let value = this.ngPackageJson as unknown;\n for (const key of parts) {\n if (typeof value === 'object' && key in value) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n // `./index.ts` -> `index.ts`\n return path.posix.normalize(this.$get('lib.entryFile'));\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get flatModuleFile(): string {\n return this.$get('lib.flatModuleFile') || this.flattenModuleId('-');\n }\n\n public get styleIncludePaths(): string[] {\n const includePaths = this.$get('lib.styleIncludePaths') || [];\n\n return includePaths.map(includePath =>\n path.isAbsolute(includePath) ? includePath : path.resolve(this.basePath, includePath),\n );\n }\n\n /**\n * The module ID is an \"identifier of a module used in the import statements, e.g.\n * '@angular/core'. The ID often maps directly to a path on the filesystem, but this\n * is not always the case due to various module resolution strategies.\"\n */\n public get moduleId(): string {\n if (this.secondaryData) {\n return this.secondaryData.moduleId;\n } else {\n return this.packageJson['name'];\n }\n }\n\n private flattenModuleId(separator = '.') {\n if (this.moduleId.startsWith('@')) {\n return this.moduleId.substring(1).split('/').join(separator);\n } else {\n return this.moduleId.split('/').join(separator);\n }\n }\n}\n"]}
|