Skip to content

doc: esm: improve dual package hazard docs

This updates the ES modules docs regarding hazards related to dual packages per the findings in https://github.com/nodejs/modules/issues/409. Basically, the hazard that we previously thought was isolated to divergent specifiers (e.g. 'pkg' resolving to index.cjs for CommonJS and index.mjs for ESM) happens for all dual packages even if the two entry points are at different specifiers (e.g. 'pkg' and 'pkg/module'). Therefore the section on writing dual packages applies not just to conditional exports but to the ES modules implementation generally.

Follow up to https://github.com/nodejs/node/pull/30051.

cc @guybedford @MylesBorins @nodejs/modules-active-members

Checklist

Merge request reports

Loading