From ee5f86d5f1777a1e2a10399eae38a1cde53378ba Mon Sep 17 00:00:00 2001 From: underfin Date: Mon, 29 Jul 2024 17:12:18 +0800 Subject: [PATCH] fix: ssr entry names --- packages/vite/src/node/build.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 954e24e0bf3ec8..9ca0b32c8dd455 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -670,9 +670,11 @@ 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}`), @@ -680,10 +682,10 @@ export async function build( ? `[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, } } @@ -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' } @@ -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')) { @@ -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(