Skip to content

Commit

Permalink
fix: allow loading standalone directives
Browse files Browse the repository at this point in the history
  • Loading branch information
osnoser1 committed Oct 12, 2023
1 parent 25af33c commit 08d3aac
Show file tree
Hide file tree
Showing 2 changed files with 15 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 @@ -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,
]);
});
});

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 08d3aac

Please sign in to comment.