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

Support import.meta.url #13

Merged
merged 2 commits into from
Jan 6, 2022
Merged

Support import.meta.url #13

merged 2 commits into from
Jan 6, 2022

Conversation

yKanon
Copy link
Contributor

@yKanon yKanon commented Nov 25, 2021

description: use import.meta.url when use esmodule. but its value is 'file://xxxx'. so, globalDir return undefine, and path.relative throw Error

index.js Outdated
const filenameInLocalNodeModules = !path.relative(localNodeModules, filename).startsWith('..') &&
// On Windows, if `localNodeModules` and `filename` are on different partitions, `path.relative()` returns the value of `filename`, resulting in `filenameInLocalNodeModules` incorrectly becoming `true`.
path.parse(localNodeModules).root === path.parse(filename).root;
const filenameInLocalNodeModules = !path.relative(localNodeModules, normalizedFilename).startsWith('..') &&
Copy link
Owner

Choose a reason for hiding this comment

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

Please don't make unrelated changes (the indentation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, my fault. now, my modifications follow the lint information

@sindresorhus
Copy link
Owner

This is not fixing anything as import.meta.url support was never promised. That being said, I'm ok with the improvement.

You also need to update the readme to mention support for import.meta.url.

@yKanon yKanon changed the title fix: globalDir is undefined when cli use esm Support import.meta.url Jan 5, 2022
@yKanon
Copy link
Contributor Author

yKanon commented Jan 5, 2022

This is not fixing anything as import.meta.url support was never promised. That being said, I'm ok with the improvement.

You also need to update the readme to mention support for import.meta.url.

alright. So, does big brother means that it is a feature?

@sindresorhus sindresorhus changed the title Support import.meta.url Support import.meta.url Jan 6, 2022
@sindresorhus sindresorhus merged commit d0f784e into sindresorhus:main Jan 6, 2022
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.

2 participants