byCodemod

Npm Esm First In Exports

/icons/calendar.svg

Last update

Aug 9, 2024

Sort package.json export order to prefer ESM over CJS

"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs", // <-- this would cause platforms to prefer CJS over ESM
"import": "./dist/index.js"
},
}

Example

Before

"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
}

After

"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
}

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now