-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a convention for packages to define their auto import patterns #405
Comments
/cc @JOU-amjs, as we discussed this in person before, thanks for pushing me on this, and would also love to hear your point of view |
That is good enough for me.🥳🥳🥳 AutoImport({
imports: ['a', 'b', 'c']
}) in this case, only scan the packages and another suggestion I am considering is that may be some exports are ignored in certain package(such as package // unimport.json in package `a`
presets: [{
package: 'a',
exports: 'auto'
ignore: ['h']
}]
AutoImport({
imports: [
{
'a': ['h']
},
'b',
'c'
]
}) |
For ignores, it's already possible in https://github.com/unjs/unimport |
It is a really nice idea. I suggest
|
I like that. But I wonder if this way, library authors would need to define another entry of If we end up requires WDYT? |
Using Bundlers, often already scan Precomputed meta (as JSON) has benefit that we make sure the cost of loading meta is fixed (IE: libraries won't add runtime overhead of evaluating a code), it is statically analyzable just as bundler tooling goes through them (this actually also is super helpful to auto generate docs by picking meta from standard place) Having a meta namespace in pkg also gives unimport a way to allow more advanced specifiers without hacking over I think it wouldn't hurt BTW to support both methods, but I prefer to have meta/json method and advice it ecosystem-wise considering perf advantages. |
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 #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:
unimport.json
ordist/unimport.json
file.meta.unimport
field in package.json/unimport
sub-export (that supports JS)Additional information
The text was updated successfully, but these errors were encountered: