unimport icon indicating copy to clipboard operation
unimport copied to clipboard

Introduce a convention for packages to define their auto import patterns

Open antfu opened this issue 1 year ago • 6 comments

Describe the feature

It doesn't scale well for us to maintain all the presets for every single library. It would also be hard to align the version of each library, especially for major changes.

I propose we have a convention for each library to define its own auto-import entries. For example, a unimport.json file is published along with the npm package. This would make library authors easier to control and maintain the entires, it also naturally solve the problem of version controls.

We already have auto-scan as https://github.com/unjs/unimport#exports-auto-scan, introduced in https://github.com/unjs/unimport/pull/104; in the PR, we also mentioned the potential of this but never got implemented. I want to have this PR to bring back the discussion of the design.

A few ideas for the approach:

  • A. unimport.json or dist/unimport.json file.
  • B. meta.unimport field in package.json
  • C. /unimport sub-export (that supports JS)

Additional information

  • [X] Would you be willing to help implement this feature?

antfu avatar Dec 09 '24 15:12 antfu