diff --git a/packages/vite/src/node/ssr/ssrModuleLoader.ts b/packages/vite/src/node/ssr/ssrModuleLoader.ts index 2b09bc050603ff..4cb226de83944e 100644 --- a/packages/vite/src/node/ssr/ssrModuleLoader.ts +++ b/packages/vite/src/node/ssr/ssrModuleLoader.ts @@ -10,7 +10,6 @@ import { import { transformRequest } from '../server/transformRequest' import type { InternalResolveOptionsWithOverrideConditions } from '../plugins/resolve' import { tryNodeResolve } from '../plugins/resolve' -import { genSourceMapUrl } from '../server/sourcemap' import { ssrDynamicImportKey, ssrExportAllKey, @@ -26,16 +25,6 @@ interface SSRContext { type SSRModule = Record -// eslint-disable-next-line @typescript-eslint/no-empty-function -const AsyncFunction = async function () {}.constructor as typeof Function -let fnDeclarationLineCount = 0 -{ - const body = '/*code*/' - const source = new AsyncFunction('a', 'b', body).toString() - fnDeclarationLineCount = - source.slice(0, source.indexOf(body)).split('\n').length - 1 -} - const pendingModules = new Map>() const pendingImports = new Map() @@ -192,17 +181,9 @@ async function instantiateModule( } } - let sourceMapSuffix = '' - if (result.map) { - const moduleSourceMap = Object.assign({}, result.map, { - // offset the first three lines of the module (function declaration and 'use strict') - mappings: ';'.repeat(fnDeclarationLineCount + 1) + result.map.mappings, - }) - sourceMapSuffix = - '\n//# sourceMappingURL=' + genSourceMapUrl(moduleSourceMap) - } - try { + // eslint-disable-next-line @typescript-eslint/no-empty-function + const AsyncFunction = async function () {}.constructor as typeof Function const initModule = new AsyncFunction( `global`, ssrModuleExportsKey, @@ -210,9 +191,7 @@ async function instantiateModule( ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, - '"use strict";\n' + - result.code + - `\n//# sourceURL=${mod.url}${sourceMapSuffix}`, + '"use strict";' + result.code + `\n//# sourceURL=${mod.url}`, ) await initModule( context.global,