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/cli): simplify import path if possible #6184

Merged
merged 1 commit into from
May 9, 2017

Conversation

cexbrayat
Copy link
Member

Fixes #6183

@@ -229,7 +229,8 @@ export default Blueprint.extend({
const className = stringUtils.classify(`${options.entity.name}Component`);
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
const normalizeRelativeDir = componentDir.startsWith('.') ? componentDir : `./${componentDir}`;
const importPath = componentDir ? `${normalizeRelativeDir}/${fileName}` : `./${fileName}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you instead use path.normalize on importPath? It guarantees the path is always simplified.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly path.normalize will simplify import {Hello} from './hello/hello' to import {Hello} from 'hello/hello', which breaks the app...

Copy link
Contributor

Choose a reason for hiding this comment

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

Did not know that, you're right. Plus on windows it also replaces the slashes.

@filipesilva filipesilva merged commit 2d42a58 into angular:master May 9, 2017
filipesilva pushed a commit to filipesilva/angular-cli that referenced this pull request May 9, 2017
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this pull request Apr 23, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated import paths can sometimes be simplified
3 participants