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

Non-JS extensions not always throwing in ESM resolver #30632

Closed
guybedford opened this issue Nov 25, 2019 · 2 comments
Closed

Non-JS extensions not always throwing in ESM resolver #30632

guybedford opened this issue Nov 25, 2019 · 2 comments
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@guybedford
Copy link
Contributor

In #30514 (comment) @GeoffreyBooth found a scenario in which unsupported file extensions are still being resolved by the ESM resolver as modules.

We need to ensure that all unknown file extensions throw for the ESM resolver, as is the intention in the spec described in the ESM_FORMAT specification - https://nodejs.org/dist/latest-v13.x/docs/api/esm.html#esm_resolution_algorithm.

@guybedford guybedford added the esm Issues and PRs related to the ECMAScript Modules implementation. label Nov 25, 2019
@guybedford guybedford added good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Nov 25, 2019
@adarshsaraogi
Copy link

hi I would like to work on this.

@guybedford
Copy link
Contributor Author

I managed to track this one down and it is actually not a bug after all. @GeoffreyBooth when you called resolve(specifier) in the loader you only provided one argument to the resolver (whereas the resolver takes two arguments - the specifier, and the parent specifier. When no parent specifier is provided this is taken to mean isMain (Node.js main entry). Which results in a different resolution rule that extensions don't matter. This was done to support extensionless bin files and is correct by the specification isMain check in ESM_FORMAT. If you simply provide the parentUrl to the resolve call in your loader example there you will find it throws an error.

Thanks so much @adarshsaraogi for offering to help here, if you are interested in contributing there are some other issues labelled ES modules / help wanted / good first issue that I'd be glad to help you with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

No branches or pull requests

2 participants