Skip to content

Commit

Permalink
feat(vite): set default format in buildOutputOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gobeli committed Jun 29, 2021
1 parent 5f525ab commit 7ed0f5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/build.ts
Expand Up @@ -426,7 +426,7 @@ async function doBuild(
entryFileNames: ssr
? `[name].js`
: libOptions
? resolveLibFilename(libOptions, output.format, pkgName)
? resolveLibFilename(libOptions, output.format || 'es', pkgName)
: path.posix.join(options.assetsDir, `[name].[hash].js`),
chunkFileNames: libOptions
? `[name].js`
Expand Down Expand Up @@ -624,12 +624,12 @@ function staticImportedByEntry(

export function resolveLibFilename(
libOptions: LibraryOptions,
format: ModuleFormat | undefined,
format: ModuleFormat,
pkgName: string
): string {
return typeof libOptions.fileName === 'function' && format
return typeof libOptions.fileName === 'function'
? libOptions.fileName(format)
: `${libOptions.fileName || pkgName}.${format || `es`}.js`
: `${libOptions.fileName || pkgName}.${format}.js`
}

function resolveBuildOutputs(
Expand Down

0 comments on commit 7ed0f5d

Please sign in to comment.