-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(lib): allow multiple entries #7047
Conversation
for this the entry points would need to be added to the package json exports |
after #6827 file names will be a bit different to give correct file names |
Indeed. But this is not Vite's concern, right? It should probably be mentioned in the docs under "Recommended package.json for your lib". |
yup. should be mentioned in docs |
I have added some docs and another check. Is there anything obvious missing? |
I very much look forward for this to be merged. to reply, I think the array option can benefit from a little bit more highlight than just a comment... but it’s a much needed feature and thank you |
@bluwy I see that the to-be-discussed label has been added. How does that work? I'm happy to discuss any open questions. |
it will be discussed at a team about the approach and if it should go in |
That means we will be discussing about this in the next team meeting (if we have the time) 😄 I'd like to review this PR myself too, but we'll have to see if the new API is good to go. |
Alright, let me know if I can contribute/clarify/justify something or if you require changes. Thanks! |
Need this feature +1. Any update? The solution proposed in #4530 seems to be more flexible, with the possibility of specifying different formats and UMD names for different lib entries |
True, it's a bit more flexible. However it's also more complex to implement and has other limitations. Also, if you're aiming for maximum flexibility I would argue it doesn't go far enough. What it you want to configure e.g. different I think we are not talking about mutually exclusive features here, both havbe their advantages:
|
Possibly the UMD (and IIFE) case should be covered better in this PR as well. Currently you would see an error when trying to have multiple entrypoints and one of the formats is UMD. I think good behavior would be: For other formats, just feed it into rollup as is currently done. For UMD and IIFE, extra builds could be triggered per entrypoint. I'd be happy to build it, but before putting more effort in it I would wait for the team's feedback, if the api makes sense for them at all. |
@schummar Need this feature +1. Any update? |
Any updates? |
We had a big backlog while we are working to release v3, so we haven't had time yet to review this one in a team meeting. We'll comment once we do. |
Thanks, this is a really valuable feature for vite |
+1 for the head up. It's a titanic work making adequately a multientry build in lib mode, at least with Web Components libs. |
+1 from me. |
Another |
6c717d8
to
2765862
Compare
I have rebased the changes onto current main now. Still awaiting the team's feedback, but the p3-significant label is probably a good sign 😁 |
Outline for possible multi entries support for umd and iife: Needs fine tuning obviously, but works in principle. With the expected downside of course, that no code splitting takes place and redundant code is put into files. E.g.:
|
@schummar this is great! I tried running it locally and get a |
@drewloomer that's a limitation of Rollup (see rollup/rollup#2072), which we might be able to work around. I have described a possible solution before (#7047 (comment), #7047 (comment)) but it will create redundant output, which might or might not be a deal breaker. If you want you can try it out from this branch: https://github.com/schummar/vite/tree/feature/libMultiEntryUMD |
@drewloomer it just occurred to me that the confusion could also come from "es" and "umd" being the default output format, which will then just show an error. That is unfortunate indeed. Maybe one way to solve it could be, to change the default format when using multiple entry points... For now the best way to configure it, is to use |
Is this landing any time soon? 🥺 |
Would #10116 (once it gets merged) make this PR redundant? Or are they doing slightly different things? |
I'd say they are not quite the same. By overriding |
@schummar thanks for your patience on this PR, we discussed it in the last team meeting and got a consensus on moving forward with it. And we think your proposed API is the right way to go. We are starting to work towards 3.2 and we can include this feature in it. Would you resolve the conflicts when you have a chance? |
2765862
to
2dbb6dd
Compare
@patak-dev cool! I have rebased the branch and the conflict is gone. One test is failing but it's failing on main as well, so I guess nothing to do for me. I suggest finishing this PR with the scope it has now - including whatever changes you still require. After merging I would then open new PRs for the other suggestions (different default formats when using multiple entries, non-code splitting build for UMD and IIFE with multiple entries). Ok? |
Un-chunked umd versions would be super useful for us at https://github.com/rrweb-io/rrweb. Because we end up injecting all the code in a browser via puppeteer un-chuncked is actually preferred as it makes it a lot less complex to inject one file vs many. |
Description
Hi, I think it's a common occurrence that libraries provide multiple entrypoints, so it would be nice if Vite's library mode supported this scenario. Since rollup does the heavy lifting, the main challenge is to provide a nice and simple interface.
The idea would be for
entry
to have rollup's InputOption interface and to tweakfileName
and the resulting file names and chunk names accordingly. All without chaning the behavior for existing cases of course.Example:
or
Additional context
There is an issue regarding the topic, though the proposed interface differs: #4530
Some discussion has been going on here: #1736
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).