Skip to content

Commit

Permalink
fix(ssr): strip NULL_BYTE_PLACEHOLDER before import
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jul 14, 2022
1 parent d12d469 commit 0cb4b25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -38,11 +38,9 @@ import {
moduleListContains,
normalizePath,
prettifyUrl,
removeImportQuery,
stripBomTag,
timeFrom,
transformStableResult,
unwrapId
transformStableResult
} from '../utils'
import type { ResolvedConfig } from '../config'
import type { Plugin } from '../plugin'
Expand Down Expand Up @@ -706,10 +704,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// by the deps optimizer
if (config.server.preTransformRequests && staticImportedUrls.size) {
staticImportedUrls.forEach(({ url, id }) => {
url = unwrapId(removeImportQuery(url)).replace(
NULL_BYTE_PLACEHOLDER,
'\0'
)
transformRequest(url, server, { ssr }).catch((e) => {
if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
// This are expected errors
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/ssr/ssrModuleLoader.ts
Expand Up @@ -38,7 +38,7 @@ export async function ssrLoadModule(
urlStack: string[] = [],
fixStacktrace?: boolean
): Promise<SSRModule> {
url = unwrapId(url).replace(NULL_BYTE_PLACEHOLDER, '\0')
url = unwrapId(url)

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

0 comments on commit 0cb4b25

Please sign in to comment.