Skip to content

Instantly share code, notes, and snippets.

@dominique-mueller
Last active April 20, 2021 19:49
Show Gist options
  • Save dominique-mueller/c25be90847a90a2df6aa7aad8c663b46 to your computer and use it in GitHub Desktop.
Save dominique-mueller/c25be90847a90a2df6aa7aad8c663b46 to your computer and use it in GitHub Desktop.
package.json fields for exports
{
// Support for native ESM (official)
// See <https://nodejs.org/api/packages.html#packages_type>
"type": "module",
// Export map (official)
// See <https://nodejs.org/api/packages.html#packages_subpath_exports>
"exports": {
".": {
"require": "./index.cjs", // Good old CJS
"import": "./index.js" // Brand new ESM
}
},
// Export (unofficial)
// See <https://github.com/rollup/rollup/wiki/pkg.module>
"module": "./index.js", // Brand new ESM
// Export (unofficial?)
"main": "./index.cjs", // Good old CJS
// TypeScript typings (official)
// See <https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package>
"types": "index.d.ts",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment