From 08d3aac412168988f1c02aa2a097ef418c7557c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20Andr=C3=A9s=20L=C3=B3pez=20Molina?= Date: Wed, 11 Oct 2023 22:06:09 -0500 Subject: [PATCH] fix: allow loading standalone directives --- .../angular-beta/utils/PropertyExtractor.test.ts | 14 ++++++++++++++ .../client/angular-beta/utils/PropertyExtractor.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts index 45d2fb73e62f..c5be68cc1a34 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts @@ -18,6 +18,7 @@ const TestComponent1 = Component({})(class {}); const TestComponent2 = Component({})(class {}); const StandaloneTestComponent = Component({ standalone: true })(class {}); const TestDirective = Directive({})(class {}); +const StandaloneTestDirective = Directive({ standalone: true })(class {}); const TestModuleWithDeclarations = NgModule({ declarations: [TestComponent1] })(class {}); const TestModuleWithImportsAndProviders = NgModule({ imports: [TestModuleWithDeclarations], @@ -117,6 +118,19 @@ describe('PropertyExtractor', () => { TestModuleWithImportsAndProviders, StandaloneTestComponent, ]); + + it('should return standalone directives', () => { + const imports = extractImports( + { + imports: [TestModuleWithImportsAndProviders], + }, + StandaloneTestDirective + ); + expect(imports).toEqual([ + CommonModule, + TestModuleWithImportsAndProviders, + StandaloneTestDirective, + ]); }); }); diff --git a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts index d8664259e158..e6db7384488f 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts @@ -173,7 +173,7 @@ export class PropertyExtractor implements NgModuleMetadata { const isPipe = decorators.some((d) => this.isDecoratorInstanceOf(d, 'Pipe')); const isDeclarable = isComponent || isDirective || isPipe; - const isStandalone = isComponent && decorators.some((d) => d.standalone); + const isStandalone = (isComponent || isDirective) && decorators.some((d) => d.standalone); return { isDeclarable, isStandalone }; };