refactor(compiler-cli): expose code needed by Angular CLI (#43431)

Exposes code needed by the Angular CLI. Previously the CLI used
deep imports for most of these things, but now with bundling
the CLI, we no longer support deep imports.

We will expose the necessary dependencies for the linker as part
of the primary entry-point (I think that is more maintable than
re-exporting them as part of the linker). We also expose the ngcc
entry-point for the CLI with a new constant that will point to the
ngcc command line entry-point (which the CLI relies on).

PR Close #43431
This commit is contained in:
Paul Gschwendtner
2021-09-20 19:30:08 +02:00
committed by Dylan Hunn
parent 7d886ce91c
commit f7cd8a0e45
3 changed files with 23 additions and 2 deletions
+9 -2
View File
@@ -21,12 +21,19 @@ export * from './src/perform_compile';
export {CompilerOptions as AngularCompilerOptions} from './src/transformers/api';
export {ngToTsDiagnostic} from './src/transformers/util';
export {NgTscPlugin} from './src/ngtsc/tsc_plugin';
export {NgtscProgram} from './src/ngtsc/program';
// Internal exports needed for packages relying on the compiler-cli.
// TODO: Consider moving into `@angular/compiler-cli/private`. This would
// help with a consistent pattern for cross package imports for Angular.
export * from './src/tooling';
// Exposed as they are needed for relying on the `linker`.
export * from './src/ngtsc/logging';
export * from './src/ngtsc/file_system';
// Exports for dealing with the `ngtsc` program.
export {NgTscPlugin} from './src/ngtsc/tsc_plugin';
export {NgtscProgram} from './src/ngtsc/program';
export {OptimizeFor} from './src/ngtsc/typecheck/api';
setFileSystem(new NodeJSFileSystem());
+10
View File
@@ -5,6 +5,8 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {join} from 'path';
import {NodeJSFileSystem, setFileSystem} from '../src/ngtsc/file_system';
import {mainNgcc} from './src/main';
@@ -20,3 +22,11 @@ export function process(options: AsyncNgccOptions|SyncNgccOptions): void|Promise
setFileSystem(new NodeJSFileSystem());
return mainNgcc(options);
}
/**
* Absolute file path that points to the `ngcc` entry-point.
*
* This can be used by the Angular CLI to spawn a process running ngcc using
* command line options.
*/
export const ngccMainFilePath = join(__dirname, './main-ngcc.js');
+4
View File
@@ -17,6 +17,10 @@
"./package.json": {
"default": "./package.json"
},
"./ngcc": {
"types": "./ngcc/index.d.ts",
"default": "./bundles/ngcc/index.js"
},
"./linker": {
"types": "./linker/index.d.ts",
"default": "./bundles/linker/index.js"