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

ESM specifier resolution flag does not use useESMLoader for entry point #35095

Closed
kennyr87 opened this issue Sep 8, 2020 · 0 comments · Fixed by #35098
Closed

ESM specifier resolution flag does not use useESMLoader for entry point #35095

kennyr87 opened this issue Sep 8, 2020 · 0 comments · Fixed by #35098
Labels
esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@kennyr87
Copy link

kennyr87 commented Sep 8, 2020

The ES module specifier flag should use the esm loader to load extensionless entrypoints as esm modules. I believe the es-module-specifier-resolution option was deprecated in v13.4.0, but the esm loader is still using that option to specify the resolver: https://github.com/nodejs/node/blob/master/lib/internal/modules/run_main.js#L28

  • Version: 14.7.0
  • Platform: openSUSE Tumbleweed
  • Subsystem: ESM Loader

What steps will reproduce the bug?

mkdir test-dir
cd test-dir
echo '{}' > package.json
touch entrypoint
touch test.mjs

/usr/bin/node --trace-warnings ./entrypoint test.mjs # <-- no error

/usr/bin/node --experimental-specifier-resolution=node --trace-warnings ./entrypoint test.mjs  <-- no error

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

/usr/bin/node --experimental-specifier-resolution=node --trace-warnings ./entrypoint test.mjs

Should print the following to stdout:

internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected string to be returned for the "format" from the "loader getFormat" function but got type object.
    at Loader.getFormat (internal/modules/esm/loader.js:110:13)
    at async Loader.getModuleJob (internal/modules/esm/loader.js:230:20)
    at async Loader.import (internal/modules/esm/loader.js:164:17)
    at async Object.loadESM (internal/process/esm_loader.js:68:5) {
  code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}

What do you see instead?

/usr/bin/node --es-module-specifier-resolution=node --trace-warnings ./entrypoint test.mjs returns code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'

I believe the es-module-specifier-resolution option was deprecated in v13.4.0

Additional information

https://github.com/nodejs/node/blob/master/lib/internal/modules/run_main.js#L28

@himself65 himself65 added the esm Issues and PRs related to the ECMAScript Modules implementation. label Sep 8, 2020
@Trott Trott closed this as completed in 22c52aa Sep 10, 2020
ruyadorno pushed a commit that referenced this issue Sep 17, 2020
Fixes: #35095

PR-URL: #35098
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 3, 2020
Fixes: #35095

PR-URL: #35098
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 16, 2020
Fixes: #35095

PR-URL: #35098
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
joesepi pushed a commit to joesepi/node that referenced this issue Jan 8, 2021
Fixes: nodejs#35095

PR-URL: nodejs#35098
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants