Skip to content

Commit

Permalink
fix: throw if passing multiple entry points for umd of iife
Browse files Browse the repository at this point in the history
  • Loading branch information
schummar committed Feb 23, 2022
1 parent a64c732 commit d8542fa
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,14 +713,22 @@ function resolveBuildOutputs(
): OutputOptions | OutputOptions[] | undefined {
if (libOptions) {
const formats = libOptions.formats || ['es', 'umd']
if (
(formats.includes('umd') || formats.includes('iife')) &&
!libOptions.name
) {
throw new Error(
`Option "build.lib.name" is required when output formats ` +
`include "umd" or "iife".`
)
if (formats.includes('umd') || formats.includes('iife')) {
if (
typeof libOptions.entry !== 'string' &&
Object.values(libOptions.entry).length > 1
) {
throw new Error(
`Multiple entry points are not supported when output formats include "umd" or "iife".`
)
}

if (!libOptions.name) {
throw new Error(
`Option "build.lib.name" is required when output formats ` +
`include "umd" or "iife".`
)
}
}
if (!outputs) {
return formats.map((format) => ({ format }))
Expand Down

0 comments on commit d8542fa

Please sign in to comment.