Skip to content

Commit 37969d8

Browse files
committed
fix(component): don't declare component in web module if it's not shared
1 parent d16152a commit 37969d8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/generate/component/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@ export default function (options: ComponentOptions): Rule {
4242
options.spec = false;
4343
}
4444

45+
if (
46+
!platformUse.nsOnly && // the project is shared
47+
platformUse.useNs && !platformUse.useWeb // the new component is only for {N}
48+
) {
49+
options.skipImport = true; // don't declare it in the web NgModule
50+
}
51+
4552
validateGenerateOptions(platformUse, options);
4653
validateGenerateComponentOptions(platformUse, options);
4754

4855
return tree;
4956
},
5057

51-
() => {
52-
return externalSchematic('@schematics/angular', 'component', removeNsSchemaOptions(options));
53-
},
58+
() => externalSchematic('@schematics/angular', 'component', removeNsSchemaOptions(options)),
5459

5560
(tree: Tree) => {
5661
extensions = getExtensions(tree, options);

0 commit comments

Comments
 (0)