Skip to content

Conversation

@cexbrayat
Copy link
Member

Fixes #6183

@cexbrayat cexbrayat force-pushed the fix/simplify-imports branch from 1642923 to 8c57136 Compare May 5, 2017 08:17
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

3 participants