Skip to content

Commit

Permalink
Merge pull request #24448 from osnoser1/bugfix/standalone-angular-dir…
Browse files Browse the repository at this point in the history
…ectives

Angular: Allow loading standalone directives
  • Loading branch information
valentinpalkovic authored Oct 13, 2023
2 parents a427c33 + 84d046d commit 048272f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -118,6 +119,20 @@ describe('PropertyExtractor', () => {
StandaloneTestComponent,
]);
});

it('should return standalone directives', () => {
const imports = extractImports(
{
imports: [TestModuleWithImportsAndProviders],
},
StandaloneTestDirective
);
expect(imports).toEqual([
CommonModule,
TestModuleWithImportsAndProviders,
StandaloneTestDirective,
]);
});
});

describe('extractDeclarations', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};
Expand Down

0 comments on commit 048272f

Please sign in to comment.