Pure ESM package

Pure ESM package

Add "type": "module" to your package.json.
Replace "main": "index.js" with "exports": "./index.js" in your package.json.
Update the "engines" field in package.json to Node.js 12: "node": ">=12.20".
Remove 'use strict'; from all JavaScript files.
Replace all require()/module.export with import/export.
Use only full relative file paths for imports: import x from '.'; → import x from './index.js';.
If you have a TypeScript type definition (for example, index.d.ts), update it to use ESM imports/exports.
Optional but recommended, use the node: protocol for imports.

既存の Node.js のパッケージの移行方法

もうネイティブに esm で書いちゃえばいいのか...?

Node.js JavaScript esm