Skip to content

Commit

Permalink
fix: isStandalone defaults to true if angular >= 19
Browse files Browse the repository at this point in the history
  • Loading branch information
ingowagner committed Nov 21, 2024
1 parent 80905a2 commit 92dad57
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Provider,
ɵReflectionCapabilities as ReflectionCapabilities,
importProvidersFrom,
VERSION,
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
Expand Down Expand Up @@ -176,15 +177,18 @@ export class PropertyExtractor implements NgModuleMetadata {
const isDeclarable = isComponent || isDirective || isPipe;

// Check if the hierarchically lowest Component or Directive decorator (the only relevant for importing dependencies) is standalone.
const isStandalone = !!(
(isComponent || isDirective) &&
let isStandalone = (isComponent || isDirective) &&
[...decorators]
.reverse() // reflectionCapabilities returns decorators in a hierarchically top-down order
.find(
(d) =>
this.isDecoratorInstanceOf(d, 'Component') || this.isDecoratorInstanceOf(d, 'Directive')
)?.standalone
);
)?.standalone;

//Starting in Angular 19 the default (in case it's undefined) value for standalone is true
if (isStandalone === undefined) {
isStandalone = !!(VERSION.major && Number(VERSION.major) >= 19);
}

return { isDeclarable, isStandalone };
};
Expand Down

0 comments on commit 92dad57

Please sign in to comment.