Skip to content

Commit 0cb4b25

Browse files
committed
fix(ssr): strip NULL_BYTE_PLACEHOLDER before import
1 parent d12d469 commit 0cb4b25

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ import {
3838
moduleListContains,
3939
normalizePath,
4040
prettifyUrl,
41-
removeImportQuery,
4241
stripBomTag,
4342
timeFrom,
44-
transformStableResult,
45-
unwrapId
43+
transformStableResult
4644
} from '../utils'
4745
import type { ResolvedConfig } from '../config'
4846
import type { Plugin } from '../plugin'
@@ -706,10 +704,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
706704
// by the deps optimizer
707705
if (config.server.preTransformRequests && staticImportedUrls.size) {
708706
staticImportedUrls.forEach(({ url, id }) => {
709-
url = unwrapId(removeImportQuery(url)).replace(
710-
NULL_BYTE_PLACEHOLDER,
711-
'\0'
712-
)
713707
transformRequest(url, server, { ssr }).catch((e) => {
714708
if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
715709
// This are expected errors

packages/vite/src/node/ssr/ssrModuleLoader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function ssrLoadModule(
3838
urlStack: string[] = [],
3939
fixStacktrace?: boolean
4040
): Promise<SSRModule> {
41-
url = unwrapId(url).replace(NULL_BYTE_PLACEHOLDER, '\0')
41+
url = unwrapId(url)
4242

4343
// when we instantiate multiple dependency modules in parallel, they may
4444
// point to shared modules. We need to avoid duplicate instantiation attempts
@@ -137,7 +137,7 @@ async function instantiateModule(
137137
if (dep[0] !== '.' && dep[0] !== '/') {
138138
return nodeImport(dep, mod.file!, resolveOptions)
139139
}
140-
dep = unwrapId(dep)
140+
dep = unwrapId(dep).replace(NULL_BYTE_PLACEHOLDER, '\0')
141141
if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
142142
pendingDeps.push(dep)
143143
if (pendingDeps.length === 1) {

0 commit comments

Comments
 (0)