You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
The package.json"main" field reverts to its prior CommonJS-only use.
A new field "exports" is created that takes a string like "./src/index.js". This is the ES module entry point. "exports" is to import what "main" is to require.
Notes:
"exports" may in the future take an object, preserving design space for the package exports proposal.
If "exports" points to a .js file and "type": "module" is not set, an error is thrown similar to the “type mismatch” errors (like using --type=commonjs with an .mjs file). The error would also instruct the user to add "type": "module" to package.json. The "exports" field does not imply "type": "module".
And that’s it! This should cover the case while preserving design space for future proposals, and for Node potentially switching to ESM by default someday.
@guybedford, @jkrems and I discussed the package dual-ESM/CommonJS case and we have a small proposal, based on the current ecmascript-modules implementation:
The
package.json"main"field reverts to its prior CommonJS-only use.A new field
"exports"is created that takes a string like"./src/index.js". This is the ES module entry point."exports"is toimportwhat"main"is torequire.Notes:
"exports"may in the future take an object, preserving design space for the package exports proposal.If
"exports"points to a.jsfile and"type": "module"is not set, an error is thrown similar to the “type mismatch” errors (like using--type=commonjswith an.mjsfile). The error would also instruct the user to add"type": "module"topackage.json. The"exports"field does not imply"type": "module".And that’s it! This should cover the case while preserving design space for future proposals, and for Node potentially switching to ESM by default someday.