huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
861 stars 28 forks source link

[RFC] Deprecate wildcard exports #469

Closed huozhi closed 4 months ago

huozhi commented 4 months ago

In the previous versions we introduced a convenient mode: wildcard exports that allows you to write * to match all the exports. However this makes the exports matching more complex and unpredicable.

Imaging you have entries:

- src
  |- foo
      | - index.js
      | - index.development.js
  |- bar
      | - index.edge-light.js

Where foo has development optimize condition but bar only has a edge runtime condition. And when you are using * in exports config like below

   "./*": {
      "import": "./dist/*.mjs",
      "require": "./dist/*.cjs"
   }

It will make the exports parser super difficult to match it also it might mismatch the cases since each condition have different export. If you enumerate all cases in package.json like below, it's also not accurate since you don't know some has this condition development and another probably don't.

   "./*": {
      "development": "./dist/*.mjs",
      "edge-light": "./dist/*.mjs",
      "import": "./dist/*.mjs",
      "require": "./dist/*.cjs"
   }

Another limitcation is it's hard to use the extension to decide if you want to output cjs or mjs.

With another introduced feature bunchee --prepare we probably don't need anything to do it manually, instead you can just run the command. Comparing to the uncertain and unclear configuration, I decdided to deprecate the wildcard feature.

huozhi commented 4 months ago

cc @devjiwonchoi

devjiwonchoi commented 4 months ago

100% agreed. This feature needed more thought on edge cases before building it, I did rush. Thank you for letting me know ahead!

huozhi commented 4 months ago

Thank you, I wouldn't say it's a less considered feature, it's more like with the project evolving we have different ways to handle the cases and bump to the new obstacles