-
-
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
fix: throw missing name error only when 'umd' or 'iife' are used #9886
Conversation
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.
Thanks for the PR!
I have some nitpicks but it mostly looks good to me.
packages/vite/src/node/build.ts
Outdated
outputs.forEach((output) => { | ||
if (['umd', 'iife'].includes(output.format!) && !output.name) { | ||
throw new Error( | ||
'Entries in "build.rollupOptions.output" must specify "name" when output formats include "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.
Rollup does output the following error during build. But I think it's good to have this, because this will output the error before build.
vite v3.1.0-beta.0 building for production...
✓ 1 modules transformed.
dist/index.html 0.76 KiB
dist/my-lib-custom-filename.mjs 0.59 KiB / gzip: 0.36 KiB
You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.
ddeb27f
to
6f47bbb
Compare
Thanks for the feedback, @sapphi-red! I made the updates you requested. |
Do you want me to resolve these conflicts, or will this likely be waiting a while longer before being merged? |
Sorry for taking time. It would be great if you could resolve the conflict. |
Not a problem. I'll get those resolved soon. |
6f47bbb
to
c74870c
Compare
c74870c
to
b796284
Compare
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.
Thanks for resolving the conflict!
Description
When
build.rollupOptions.output
is an array, Vite throws the following error if you don't specifybuild.lib.name
even whenumd
andiife
formats are not present. This is because the default forbuild.lib.formats
is['es', 'umd']
, and the code does not currently take thebuild.rollupOptions.output
value into account until after the error-throwing check is run.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).