Skip to content

Commit

Permalink
fix: ssr entry names
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 30, 2024
1 parent 79f1fea commit ee5f86d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,20 +670,22 @@ export async function build(
// config.packageCache,
// )
// : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
entryFileNames: libOptions
? `[name]-[hash].${jsExt}`
: path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
entryFileNames: ssr
? `[name].${jsExt}`
: libOptions
? `[name]-[hash].${jsExt}`
: path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
chunkFileNames: libOptions
? `[name]-[hash].${jsExt}`
: path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
assetFileNames: libOptions
? `[name].[ext]`
: path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
// inlineDynamicImports:
// output.format === 'umd' ||
// output.format === 'iife' ||
// (ssrWorkerBuild &&
// (typeof input === 'string' || Object.keys(input).length === 1)),
// output.format === 'umd' ||
// output.format === 'iife' ||
// (ssrWorkerBuild &&
// (typeof input === 'string' || Object.keys(input).length === 1)),
...output,
}
}
Expand Down Expand Up @@ -844,7 +846,7 @@ function resolveOutputJsExtension(
type: string = 'commonjs',
): JsExt {
if (type === 'module') {
return format === 'cjs' /* || format === 'umd' */ ? 'cjs' :'js'
return format === 'cjs' /* || format === 'umd' */ ? 'cjs' : 'js'
} else {
return format === 'es' ? 'mjs' : 'js'
}
Expand Down Expand Up @@ -894,7 +896,7 @@ export function resolveBuildOutputs(
Object.values(libOptions.entry).length > 1
const libFormats =
libOptions.formats ||
(libHasMultipleEntries ? ['es', 'cjs'] : ['es', /* 'umd' */])
(libHasMultipleEntries ? ['es', 'cjs'] : ['es' /* 'umd' */])

if (!Array.isArray(outputs)) {
// if (libFormats.includes('umd') || libFormats.includes('iife')) {
Expand Down Expand Up @@ -1236,7 +1238,7 @@ export function createToImportMetaURLBasedRelativeRuntime(
format: InternalModuleFormat,
isWorker: boolean,
): (filename: string, importer: string) => { runtime: string } {
const formatLong = isWorker && format === 'iife' ? 'worker-iife' : format
const formatLong = isWorker && format === 'iife' ? 'worker-iife' : format
const toRelativePath = customRelativeUrlMechanisms[formatLong]
return (filename, importer) => ({
runtime: toRelativePath(
Expand Down

0 comments on commit ee5f86d

Please sign in to comment.