Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): import paths for child components #1208

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sean-perkins
Copy link
Contributor

Description

Provides a default importMapper to the Angular generator to generate valid import statements for Angular module projects.

For example, when importing a child component called ChildComponent, the import path will be generated as:

import { ChildComponentModule } from './child';

I opted against assigning the importMapper to the DEFAULT_OPTIONS, since the function needs context to whether the user has selected to generate for standalone components or not. With standalone enabled, the import mapper should not rewrite the import value to include the Module postfix.

Resolves #1205

@vercel
Copy link

vercel bot commented Jun 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mitosis-fiddle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2023 2:44am

@nx-cloud
Copy link

nx-cloud bot commented Jun 21, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3e4b8a7. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

Copy link
Contributor

@samijaber samijaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Make sure to:

  • run yarn snapupdate in packages/core to update snapshots.
  • run yarn fmt:prettier in the root dir to format the PR.

packages/core/src/generators/angular.ts Outdated Show resolved Hide resolved
.join(', ');
}

return `import ${importValue} from '${importPath}';`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing wrapping brackets { }, right now the PR imports the same default output, just under a different name. I don't think this is what you want?

Is this what's needed instead?

Suggested change
return `import ${importValue} from '${importPath}';`;
return `import {${importValue}} from '${importPath}';`;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Angular import paths are incorrect with child components
2 participants