Skip to content

Commit

Permalink
chore: do not fixStacktrace
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed May 2, 2022
1 parent 1db7c49 commit 33ed1f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 47 deletions.
5 changes: 1 addition & 4 deletions docs/guide/api-javascript.md
Expand Up @@ -92,10 +92,7 @@ interface ViteDevServer {
/**
* Load a given URL as an instantiated module for SSR.
*/
ssrLoadModule(
url: string,
options?: { fixStacktrace?: boolean }
): Promise<Record<string, any>>
ssrLoadModule(url: string): Promise<Record<string, any>>
/**
* Fix ssr error stacktrace.
*/
Expand Down
15 changes: 3 additions & 12 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -226,10 +226,7 @@ export interface ViteDevServer {
/**
* Load a given URL as an instantiated module for SSR.
*/
ssrLoadModule(
url: string,
opts?: { fixStacktrace?: boolean }
): Promise<Record<string, any>>
ssrLoadModule(url: string): Promise<Record<string, any>>
/**
* Returns a fixed version of the given stack
*/
Expand Down Expand Up @@ -362,7 +359,7 @@ export async function createServer(
return transformRequest(url, server, options)
},
transformIndexHtml: null!, // to be immediately set
async ssrLoadModule(url, opts?: { fixStacktrace?: boolean }) {
async ssrLoadModule(url) {
if (!server._ssrExternals) {
let knownImports: string[] = []
const optimizedDeps = server._optimizedDeps
Expand All @@ -375,13 +372,7 @@ export async function createServer(
}
server._ssrExternals = resolveSSRExternal(config, knownImports)
}
return ssrLoadModule(
url,
server,
undefined,
undefined,
opts?.fixStacktrace
)
return ssrLoadModule(url, server, undefined, undefined)
},
ssrFixStacktrace(e) {
if (e.stack) {
Expand Down
35 changes: 4 additions & 31 deletions packages/vite/src/node/ssr/ssrModuleLoader.ts
Expand Up @@ -8,7 +8,6 @@ import {
unwrapId,
usingDynamicImport
} from '../utils'
import { rebindErrorStacktrace, ssrRewriteStacktrace } from './ssrStacktrace'
import {
ssrExportAllKey,
ssrModuleExportsKey,
Expand All @@ -35,8 +34,7 @@ export async function ssrLoadModule(
url: string,
server: ViteDevServer,
context: SSRContext = { global },
urlStack: string[] = [],
fixStacktrace?: boolean
urlStack: string[] = []
): Promise<SSRModule> {
url = unwrapId(url).replace(NULL_BYTE_PLACEHOLDER, '\0')

Expand All @@ -49,13 +47,7 @@ export async function ssrLoadModule(
return pending
}

const modulePromise = instantiateModule(
url,
server,
context,
urlStack,
fixStacktrace
)
const modulePromise = instantiateModule(url, server, context, urlStack)
pendingModules.set(url, modulePromise)
modulePromise
.catch(() => {
Expand All @@ -71,8 +63,7 @@ async function instantiateModule(
url: string,
server: ViteDevServer,
context: SSRContext = { global },
urlStack: string[] = [],
fixStacktrace?: boolean
urlStack: string[] = []
): Promise<SSRModule> {
const { moduleGraph } = server
const mod = await moduleGraph.ensureEntryFromUrl(url, true)
Expand Down Expand Up @@ -144,13 +135,7 @@ async function instantiateModule(
if (pendingDeps.length === 1) {
pendingImports.set(url, pendingDeps)
}
const mod = await ssrLoadModule(
dep,
server,
context,
urlStack,
fixStacktrace
)
const mod = await ssrLoadModule(dep, server, context, urlStack)
if (pendingDeps.length === 1) {
pendingImports.delete(url)
} else {
Expand Down Expand Up @@ -207,18 +192,6 @@ async function instantiateModule(
)
} catch (e) {
mod.ssrError = e
if (e.stack && fixStacktrace !== false) {
const stacktrace = ssrRewriteStacktrace(e.stack, moduleGraph)
rebindErrorStacktrace(e, stacktrace)
server.config.logger.error(
`Error when evaluating SSR module ${url}:\n${stacktrace}`,
{
timestamp: true,
clear: server.config.clearScreen,
error: e
}
)
}
throw e
}

Expand Down

0 comments on commit 33ed1f1

Please sign in to comment.