Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
"build": "rollup -c",
"test": "tape -r esm test/*.js | tap-spec"
},
"exports": {
".": {
"types": "./index.d.ts",
"module-sync": "./lib/index.mjs",
"require": "./lib/index.js",
"default": "./lib/index.mjs"
}
Comment on lines +24 to +29
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
".": {
"types": "./index.d.ts",
"module-sync": "./lib/index.mjs",
"require": "./lib/index.js",
"default": "./lib/index.mjs"
}
".": {
"types": "./index.d.ts",
"module-sync": "./lib/index.mjs",
"import": "./lib/index.mjs",
"require": "./lib/index.js"
},
"./package.json": "./package.json"

right? the default fallthrough is to remain CJS, not ESM. Anything that require()s and understands exports will hit require. If it supports require(esm) then it stops at module-sync. Anything that can import will be directed to ESM

Also adding an exports map is breaking on its own.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using import/require vs require/default I think is equivalent, so I don't have a preference for one vs the other

I don't think you really need to export package.json. There was an old version of rollup-plugin-svelte that required it, but otherwise I don't think there's a great reason to do it

Ah, yeah, I guess adding an exports map could be breaking if someone were trying to access something that wasn't intended to be exposed. I forgot about that...

},
"dependencies": {
"mri": "^1.1.0"
},
Expand Down