Skip to content

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

@kennyr87

Description

@kennyr87

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions