ai / dual-publish

Publish JS project as dual ES modules and CommonJS package to npm
MIT License
187 stars 11 forks source link

Keep original package.browser #24

Closed arturi closed 3 years ago

arturi commented 3 years ago

Previously dual-publish would overwrite the browser object field in package.json, thus important fields there would get lost and JS bundlers left confused. Now it appends to the browser object, as @ai proposed in https://github.com/ai/nanoid/issues/294

Current browser field in nanoid:

"browser": {
  "./index.js": "./index.browser.js"
}

After this PR (tested with npm link and node_modules/.bin/dual-publish --check):

"browser": {
  "./index.js": "./index.browser.js",
  "./index.cjs": "./index.browser.js",
  "./async/index.js": "./async/index.browser.js",
  "./async/index.cjs": "./async/index.browser.js"
}
ai commented 3 years ago

Seems like we need to improve test coverage

arturi commented 3 years ago

Please check what I did, cause I was very confused in what goes where, what dual-publish actually changes, etc. Thanks!