diff --git a/goldens/public-api/compiler-cli/compiler_options.md b/goldens/public-api/compiler-cli/compiler_options.md index 8b82227eee1..589f0d92f82 100644 --- a/goldens/public-api/compiler-cli/compiler_options.md +++ b/goldens/public-api/compiler-cli/compiler_options.md @@ -73,7 +73,7 @@ export interface StrictTemplateOptions { // @public export interface TargetOptions { - compilationMode?: 'full' | 'partial'; + compilationMode?: 'full' | 'partial' | 'experimental-local'; } // (No @packageDocumentation comment for this package) diff --git a/packages/compiler-cli/src/ngtsc/core/api/src/public_options.ts b/packages/compiler-cli/src/ngtsc/core/api/src/public_options.ts index ba4d56a1d75..a1e1e0daed6 100644 --- a/packages/compiler-cli/src/ngtsc/core/api/src/public_options.ts +++ b/packages/compiler-cli/src/ngtsc/core/api/src/public_options.ts @@ -383,10 +383,13 @@ export interface TargetOptions { * Specifies the compilation mode to use. The following modes are available: * - 'full': generates fully AOT compiled code using Ivy instructions. * - 'partial': generates code in a stable, but intermediate form suitable for publication to NPM. + * - 'experimental-local': generates code based on each individual source file without using its + * dependencies. This mode is suitable only for fast edit/refresh during development. It will be + * eventually replaced by the value `local` once the feature is ready to be public. * * The default value is 'full'. */ - compilationMode?: 'full'|'partial'; + compilationMode?: 'full'|'partial'|'experimental-local'; } /** diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index a76c924b9c1..460ec49ab86 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -1006,9 +1006,20 @@ export class NgCompiler { // Note: If this compilation builds `@angular/core`, we always build in full compilation // mode. Code inside the core package is always compatible with itself, so it does not // make sense to go through the indirection of partial compilation - const compilationMode = this.options.compilationMode === 'partial' && !isCore ? - CompilationMode.PARTIAL : - CompilationMode.FULL; + let compilationMode: CompilationMode = CompilationMode.FULL; + if (!isCore) { + switch (this.options.compilationMode) { + case 'full': + compilationMode = CompilationMode.FULL; + break; + case 'partial': + compilationMode = CompilationMode.PARTIAL; + break; + case 'experimental-local': + compilationMode = CompilationMode.LOCAL; + break; + } + } // Cycles are handled in full compilation mode by "remote scoping". // "Remote scoping" does not work well with tree shaking for libraries. diff --git a/packages/compiler-cli/src/ngtsc/transform/src/api.ts b/packages/compiler-cli/src/ngtsc/transform/src/api.ts index 816b9e0c0a8..c3751229802 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/api.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/api.ts @@ -31,6 +31,12 @@ export enum CompilationMode { * Generates code using a stable, but intermediate format suitable to be published to NPM. */ PARTIAL, + + /** + * Generates code based on each individual source file without using its + * dependencies (suitable for local dev edit/refresh workflow). + */ + LOCAL, } export enum HandlerPrecedence {