bug: Angular import paths are incorrect with child components
sean-perkins opened this issue · 1 comments
I am interested in helping provide a fix!
Yes
Which generators are impacted?
- All
- Angular
- HTML
- Preact
- Qwik
- React
- React-Native
- Solid
- Stencil
- Svelte
- Vue
- Web components
Reproduction case
Expected Behaviour
An additional import statement (or the existing one replaced) should import the generated module of the component, instead of the component class.
+import { ChildComponentModule } from "./child";
-import { ChildComponent } from "./child";
Actual Behaviour
The generated output is missing a necessary import for the Angular module:
@NgModule({
declarations: [MyComponent],
imports: [CommonModule, ChildComponentModule],
exports: [MyComponent],
})
ChildComponentModule
is not imported in the generated output.
Additional Information
Angular standalone components could be a solid replacement for modules to simplify the generated output.
This is the code that generates Mitosis component imports:
mitosis/packages/core/src/helpers/render-imports.ts
Lines 154 to 161 in a3d65ca
We actually have an importMapper
here that can be passed as an option by generators, and is passed by the Angular generator:
mitosis/packages/core/src/generators/angular.ts
Lines 464 to 471 in a3d65ca
Easiest way would be to set a default value for options.importMapper
in the DEFAULT_OPTIONS
:
So that it imports the correct thing (depending on whether options.standalone
is true or false)