Node: package self-reference works without a flag in node v12.16

Created on 12 Feb 2020  路  3Comments  路  Source: nodejs/node

Repro: clone https://github.com/ljharb/has-package-exports

It has a dev dep of "has-package-exports": "file:.", so that in every node version, i can require('has-package-exports') from within the package, and it works.

In node v13.6 and v12.15, node test passes without issuing (node:96292) ExperimentalWarning: Package name self resolution is an experimental feature. This feature could change at any time as a warning.

In node v13.7, the warning is correctly issued, and the local dev dep is byassed.

However, in node v12.16, without passing any flags, the warning is issued and the local dev dep is bypassed. v12.16 and v12.15 should behave identically with respect to this feature, regardless of the presence of "exports" in package.json.

cc @nodejs/modules-active-members

ES Modules confirmed-bug module v12.x

Most helpful comment

we can get out an emergency release to fix this

All 3 comments

This is definitely a bug, unfortunately due to the nature of the backporting process between the flagged and unflagged implementations. The fix would be to include an explicit if (!experimentalModules) return in the first line of the trySelf function in lib/internal/modules/cjs/loader.js for the 12.x branch.

we can get out an emergency release to fix this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seishun picture seishun  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments

Icemic picture Icemic  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments