-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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!: auto resolve deps in lib-mode #10632
Conversation
I tested this now locally with a link to my local vite and it works. |
I wonder if this should really apply only to library mode? We do it in SvelteKit for applications (though weren't able to get it to work using existing Vite options so do it with a second bundling step by passing it through Rollup when the Vite build completes #9919) Also, there's probably some documentation update that would be needed as part of this PR |
Added a note into the docs 👍
I'm not used to SSR at all, so I do not have a testing ground and/or knowledge what to do / to test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for a late review. Maybe we need to think a bit more about how this interacts with other options.
Not sure if I want to bring this feature now for more complex setups |
if (libOptions) { | ||
const { libFormats } = resolveLibFormats(libOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this example will be applied. (I think it shouldn't be.)
{
build: {
lib: {
entry: { main: path.resolve(__dirname, 'src/main.js'), sub: path.resolve(__dirname, 'src/sub.js') },
name: 'MyLib'
},
rollupOptions: {
output: [
// format is set in rollupOptions.output instead of lib.formats
{ format: 'es' },
{ name: 'MyLib', format: 'umd' }
]
}
}
}
I think we need to check outputs
instead of libFormats
. Something like:
const hasUmdOrIifeFormat = outputs.some(output => output.format === 'umd' || output.format === 'iife')
@@ -130,6 +130,10 @@ Generate production source maps. If `true`, a separate sourcemap file will be cr | |||
|
|||
Directly customize the underlying Rollup bundle. This is the same as options that can be exported from a Rollup config file and will be merged with Vite's internal Rollup options. See [Rollup options docs](https://rollupjs.org/guide/en/#big-list-of-options) for more details. | |||
|
|||
::: tip Note | |||
If you specify `build.lib` but not `raw.rollupOptions.external`, Vite will automatically add all dependencies as external unless `build.lib.formats` contains `umd` or `iife`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you specify `build.lib` but not `raw.rollupOptions.external`, Vite will automatically add all dependencies as external unless `build.lib.formats` contains `umd` or `iife`. | |
If you specify `build.lib` but not `raw.rollupOptions.external`, Vite will automatically add all dependencies as external unless the output format contains `umd` or `iife`. |
We now take rollupOptions.output
into account.
I feel this behavior confusing. It's not consistent. I think we should make the behavior consistent or turn off for multiple entry files. To sum up, I think we should select any of:
|
I think this will not make it into v4 anymore |
Two situations come to mind that I think are worth discussing:
|
Let's remove this one from the Vite 5 milestone. Once it is ready, it could be merged. But maybe it makes more sense to merge it later on with a more complete review of library mode. |
Right now I'm also not working on that anymore as well as it was by far more easy for me to switch to tsup as trying to get this PR merged and running and satisfy every need. |
I'll close this for now from the last comment. |
Description
Related to #10582
Additional context
This is a breaking change⚠️
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).