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

module: no type module resolver changes #33086

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions doc/api/esm.md
Expand Up @@ -1601,13 +1601,6 @@ The resolver can throw the following errors:
> 1. Return **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_,
> _mainExport_, _""_).
> 1. Throw a _Package Path Not Exported_ error.
> 1. If _pjson.main_ is a String, then
> 1. Let _resolvedMain_ be the URL resolution of _packageURL_, "/", and
> _pjson.main_.
> 1. If the file at _resolvedMain_ exists, then
> 1. Return _resolvedMain_.
> 1. If _pjson.type_ is equal to _"module"_, then
> 1. Throw a _Module Not Found_ error.
> 1. Let _legacyMainURL_ be the result applying the legacy
> **LOAD_AS_DIRECTORY** CommonJS resolver to _packageURL_, throwing a
> _Module Not Found_ error for no resolution.
Expand Down
9 changes: 1 addition & 8 deletions lib/internal/modules/esm/resolve.js
Expand Up @@ -439,11 +439,6 @@ function packageMainResolve(packageJSONUrl, packageConfig, base, conditions) {

throw new ERR_PACKAGE_PATH_NOT_EXPORTED(packageJSONUrl, '.');
}
if (packageConfig.main !== undefined) {
const resolved = new URL(packageConfig.main, packageJSONUrl);
const path = fileURLToPath(resolved);
if (tryStatSync(path).isFile()) return resolved;
}
if (getOptionValue('--experimental-specifier-resolution') === 'node') {
if (packageConfig.main !== undefined) {
return finalizeResolution(
Expand All @@ -453,9 +448,7 @@ function packageMainResolve(packageJSONUrl, packageConfig, base, conditions) {
new URL('index', packageJSONUrl), base);
}
}
if (packageConfig.type !== 'module') {
return legacyMainResolve(packageJSONUrl, packageConfig);
}
return legacyMainResolve(packageJSONUrl, packageConfig);
}

throw new ERR_MODULE_NOT_FOUND(
Expand Down
9 changes: 9 additions & 0 deletions test/es-module/test-esm-type-main.mjs
@@ -0,0 +1,9 @@
import { mustNotCall } from '../common/index.mjs';
import assert from 'assert';
import { importFixture } from '../fixtures/pkgexports.mjs';

(async () => {
const m = await importFixture('type-main');
assert.strictEqual(m.default, 'asdf');
})()
.catch(mustNotCall);
1 change: 1 addition & 0 deletions test/fixtures/node_modules/type-main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test/fixtures/node_modules/type-main/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.