vite-node 2.0.0-beta.1 → 2.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.cjs CHANGED
@@ -14,7 +14,7 @@ require('node:module');
14
14
  require('node:path');
15
15
 
16
16
  const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
17
- const ESM_SYNTAX_RE = /([\s;]|^)(import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
17
+ const ESM_SYNTAX_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
18
18
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
19
19
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
20
20
  const defaultInline = [
@@ -23,7 +23,7 @@ const defaultInline = [
23
23
  // special Vite query strings
24
24
  /[?&](init|raw|url|inline)\b/,
25
25
  // Vite returns a string for assets imports, even if it's inside "node_modules"
26
- new RegExp(`\\.(${constants.KNOWN_ASSET_TYPES.join("|")})$`)
26
+ constants.KNOWN_ASSET_RE
27
27
  ];
28
28
  const depsExternal = [
29
29
  /\/node_modules\/.*\.cjs\.js$/,
@@ -37,8 +37,9 @@ function guessCJSversion(id) {
37
37
  id.replace(ESM_EXT_RE, ".cjs.js"),
38
38
  id.replace(ESM_EXT_RE, ".js")
39
39
  ]) {
40
- if (fs.existsSync(i))
40
+ if (fs.existsSync(i)) {
41
41
  return i;
42
+ }
42
43
  }
43
44
  }
44
45
  if (id.match(ESM_FOLDER_RE)) {
@@ -48,79 +49,98 @@ function guessCJSversion(id) {
48
49
  id.replace(ESM_FOLDER_RE, "/lib/$1"),
49
50
  id.replace(ESM_FOLDER_RE, "/$1")
50
51
  ]) {
51
- if (fs.existsSync(i))
52
+ if (fs.existsSync(i)) {
52
53
  return i;
54
+ }
53
55
  }
54
56
  }
55
57
  }
56
58
  async function isValidNodeImport(id) {
57
59
  const extension = pathe.extname(id);
58
- if (BUILTIN_EXTENSIONS.has(extension))
60
+ if (BUILTIN_EXTENSIONS.has(extension)) {
59
61
  return true;
60
- if (extension !== ".js")
62
+ }
63
+ if (extension !== ".js") {
61
64
  return false;
65
+ }
62
66
  id = id.replace("file:///", "");
63
67
  const package_ = await utils.findNearestPackageData(pathe.dirname(id));
64
- if (package_.type === "module")
68
+ if (package_.type === "module") {
65
69
  return true;
66
- if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id))
70
+ }
71
+ if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id)) {
67
72
  return false;
73
+ }
68
74
  const code = await fs.promises.readFile(id, "utf8").catch(() => "");
69
75
  return !ESM_SYNTAX_RE.test(code);
70
76
  }
71
77
  const _defaultExternalizeCache = /* @__PURE__ */ new Map();
72
78
  async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
73
- if (!cache.has(id))
79
+ if (!cache.has(id)) {
74
80
  cache.set(id, _shouldExternalize(id, options));
81
+ }
75
82
  return cache.get(id);
76
83
  }
77
84
  async function _shouldExternalize(id, options) {
78
- if (utils.isNodeBuiltin(id))
85
+ if (utils.isNodeBuiltin(id)) {
79
86
  return id;
80
- if (id.startsWith("data:") || /^(https?:)?\/\//.test(id))
87
+ }
88
+ if (id.startsWith("data:") || /^(?:https?:)?\/\//.test(id)) {
81
89
  return id;
90
+ }
82
91
  id = patchWindowsImportPath(id);
83
- if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir))
92
+ if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir)) {
84
93
  return id;
94
+ }
85
95
  const moduleDirectories = (options == null ? void 0 : options.moduleDirectories) || ["/node_modules/"];
86
- if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.inline))
96
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.inline)) {
87
97
  return false;
88
- if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.external))
98
+ }
99
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.external)) {
89
100
  return id;
101
+ }
90
102
  const isLibraryModule = moduleDirectories.some((dir) => id.includes(dir));
91
103
  const guessCJS = isLibraryModule && (options == null ? void 0 : options.fallbackCJS);
92
104
  id = guessCJS ? guessCJSversion(id) || id : id;
93
- if (matchExternalizePattern(id, moduleDirectories, defaultInline))
105
+ if (matchExternalizePattern(id, moduleDirectories, defaultInline)) {
94
106
  return false;
95
- if (matchExternalizePattern(id, moduleDirectories, depsExternal))
107
+ }
108
+ if (matchExternalizePattern(id, moduleDirectories, depsExternal)) {
96
109
  return id;
97
- if (isLibraryModule && await isValidNodeImport(id))
110
+ }
111
+ if (isLibraryModule && await isValidNodeImport(id)) {
98
112
  return id;
113
+ }
99
114
  return false;
100
115
  }
101
116
  function matchExternalizePattern(id, moduleDirectories, patterns) {
102
- if (patterns == null)
117
+ if (patterns == null) {
103
118
  return false;
104
- if (patterns === true)
119
+ }
120
+ if (patterns === true) {
105
121
  return true;
122
+ }
106
123
  for (const ex of patterns) {
107
124
  if (typeof ex === "string") {
108
- if (moduleDirectories.some((dir) => id.includes(pathe.join(dir, ex))))
125
+ if (moduleDirectories.some((dir) => id.includes(pathe.join(dir, ex)))) {
109
126
  return true;
127
+ }
110
128
  } else {
111
- if (ex.test(id))
129
+ if (ex.test(id)) {
112
130
  return true;
131
+ }
113
132
  }
114
133
  }
115
134
  return false;
116
135
  }
117
136
  function patchWindowsImportPath(path) {
118
- if (path.match(/^\w:\\/))
137
+ if (path.match(/^\w:\\/)) {
119
138
  return `file:///${utils.slash(path)}`;
120
- else if (path.match(/^\w:\//))
139
+ } else if (path.match(/^\w:\//)) {
121
140
  return `file:///${path}`;
122
- else
141
+ } else {
123
142
  return path;
143
+ }
124
144
  }
125
145
 
126
146
  function hashCode(s) {
@@ -132,13 +152,22 @@ function hashCode(s) {
132
152
  class Debugger {
133
153
  constructor(root, options) {
134
154
  this.options = options;
135
- if (options.dumpModules)
136
- this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
155
+ if (options.dumpModules) {
156
+ this.dumpDir = pathe.resolve(
157
+ root,
158
+ options.dumpModules === true ? ".vite-node/dump" : options.dumpModules
159
+ );
160
+ }
137
161
  if (this.dumpDir) {
138
- if (options.loadDumppedModules)
139
- console.info(c.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
140
- else
141
- console.info(c.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
162
+ if (options.loadDumppedModules) {
163
+ console.info(
164
+ c.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`)
165
+ );
166
+ } else {
167
+ console.info(
168
+ c.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`)
169
+ );
170
+ }
142
171
  }
143
172
  this.initPromise = this.clearDump();
144
173
  }
@@ -146,50 +175,67 @@ class Debugger {
146
175
  initPromise;
147
176
  externalizeMap = /* @__PURE__ */ new Map();
148
177
  async clearDump() {
149
- if (!this.dumpDir)
178
+ if (!this.dumpDir) {
150
179
  return;
151
- if (!this.options.loadDumppedModules && fs.existsSync(this.dumpDir))
180
+ }
181
+ if (!this.options.loadDumppedModules && fs.existsSync(this.dumpDir)) {
152
182
  await fs.promises.rm(this.dumpDir, { recursive: true, force: true });
183
+ }
153
184
  await fs.promises.mkdir(this.dumpDir, { recursive: true });
154
185
  }
155
186
  encodeId(id) {
156
- return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
187
+ return `${id.replace(/[^\w@\-]/g, "_").replace(/_+/g, "_")}-${hashCode(
188
+ id
189
+ )}.js`;
157
190
  }
158
191
  async recordExternalize(id, path) {
159
- if (!this.dumpDir)
192
+ if (!this.dumpDir) {
160
193
  return;
194
+ }
161
195
  this.externalizeMap.set(id, path);
162
196
  await this.writeInfo();
163
197
  }
164
198
  async dumpFile(id, result) {
165
- if (!result || !this.dumpDir)
199
+ if (!result || !this.dumpDir) {
166
200
  return;
201
+ }
167
202
  await this.initPromise;
168
203
  const name = this.encodeId(id);
169
- return await fs.promises.writeFile(pathe.join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
170
- ${result.code}`, "utf-8");
204
+ return await fs.promises.writeFile(
205
+ pathe.join(this.dumpDir, name),
206
+ `// ${id.replace(/\0/g, "\\0")}
207
+ ${result.code}`,
208
+ "utf-8"
209
+ );
171
210
  }
172
211
  async loadDump(id) {
173
- if (!this.dumpDir)
212
+ if (!this.dumpDir) {
174
213
  return null;
214
+ }
175
215
  await this.initPromise;
176
216
  const name = this.encodeId(id);
177
217
  const path = pathe.join(this.dumpDir, name);
178
- if (!fs.existsSync(path))
218
+ if (!fs.existsSync(path)) {
179
219
  return null;
220
+ }
180
221
  const code = await fs.promises.readFile(path, "utf-8");
181
222
  return {
182
- code: code.replace(/^\/\/.*?\n/, ""),
223
+ code: code.replace(/^\/\/.*\n/, ""),
183
224
  map: void 0
184
225
  };
185
226
  }
186
227
  async writeInfo() {
187
- if (!this.dumpDir)
228
+ if (!this.dumpDir) {
188
229
  return;
189
- const info = JSON.stringify({
190
- time: (/* @__PURE__ */ new Date()).toLocaleString(),
191
- externalize: Object.fromEntries(this.externalizeMap.entries())
192
- }, null, 2);
230
+ }
231
+ const info = JSON.stringify(
232
+ {
233
+ time: (/* @__PURE__ */ new Date()).toLocaleString(),
234
+ externalize: Object.fromEntries(this.externalizeMap.entries())
235
+ },
236
+ null,
237
+ 2
238
+ );
193
239
  return fs.promises.writeFile(pathe.join(this.dumpDir, "info.json"), info, "utf-8");
194
240
  }
195
241
  }
@@ -202,38 +248,55 @@ class ViteNodeServer {
202
248
  var _a, _b, _c;
203
249
  const ssrOptions = server.config.ssr;
204
250
  options.deps ?? (options.deps = {});
205
- options.deps.cacheDir = pathe.relative(server.config.root, options.deps.cacheDir || server.config.cacheDir);
251
+ options.deps.cacheDir = pathe.relative(
252
+ server.config.root,
253
+ options.deps.cacheDir || server.config.cacheDir
254
+ );
206
255
  if (ssrOptions) {
207
256
  if (ssrOptions.noExternal === true) {
208
257
  (_a = options.deps).inline ?? (_a.inline = true);
209
258
  } else if (options.deps.inline !== true) {
210
259
  (_b = options.deps).inline ?? (_b.inline = []);
211
260
  const inline = options.deps.inline;
212
- options.deps.inline.push(...utils.toArray(ssrOptions.noExternal).filter((dep) => !inline.includes(dep)));
261
+ options.deps.inline.push(
262
+ ...utils.toArray(ssrOptions.noExternal).filter(
263
+ (dep) => !inline.includes(dep)
264
+ )
265
+ );
213
266
  }
214
267
  }
215
268
  if (process.env.VITE_NODE_DEBUG_DUMP) {
216
- options.debug = Object.assign({
217
- dumpModules: !!process.env.VITE_NODE_DEBUG_DUMP,
218
- loadDumppedModules: process.env.VITE_NODE_DEBUG_DUMP === "load"
219
- }, options.debug ?? {});
269
+ options.debug = Object.assign(
270
+ {
271
+ dumpModules: !!process.env.VITE_NODE_DEBUG_DUMP,
272
+ loadDumppedModules: process.env.VITE_NODE_DEBUG_DUMP === "load"
273
+ },
274
+ options.debug ?? {}
275
+ );
220
276
  }
221
- if (options.debug)
277
+ if (options.debug) {
222
278
  this.debugger = new Debugger(server.config.root, options.debug);
279
+ }
223
280
  (_c = options.deps).moduleDirectories ?? (_c.moduleDirectories = []);
224
281
  const envValue = process.env.VITE_NODE_DEPS_MODULE_DIRECTORIES || process.env.npm_config_VITE_NODE_DEPS_MODULE_DIRECTORIES;
225
282
  const customModuleDirectories = envValue == null ? void 0 : envValue.split(",");
226
- if (customModuleDirectories)
283
+ if (customModuleDirectories) {
227
284
  options.deps.moduleDirectories.push(...customModuleDirectories);
228
- options.deps.moduleDirectories = options.deps.moduleDirectories.map((dir) => {
229
- if (!dir.startsWith("/"))
230
- dir = `/${dir}`;
231
- if (!dir.endsWith("/"))
232
- dir += "/";
233
- return pathe.normalize(dir);
234
- });
235
- if (!options.deps.moduleDirectories.includes("/node_modules/"))
285
+ }
286
+ options.deps.moduleDirectories = options.deps.moduleDirectories.map(
287
+ (dir) => {
288
+ if (!dir.startsWith("/")) {
289
+ dir = `/${dir}`;
290
+ }
291
+ if (!dir.endsWith("/")) {
292
+ dir += "/";
293
+ }
294
+ return pathe.normalize(dir);
295
+ }
296
+ );
297
+ if (!options.deps.moduleDirectories.includes("/node_modules/")) {
236
298
  options.deps.moduleDirectories.push("/node_modules/");
299
+ }
237
300
  }
238
301
  fetchPromiseMap = {
239
302
  ssr: /* @__PURE__ */ new Map(),
@@ -264,8 +327,9 @@ class ViteNodeServer {
264
327
  return [...ssrDurations, ...webDurations].reduce((a, b) => a + b, 0);
265
328
  }
266
329
  async ensureExists(id) {
267
- if (this.existingOptimizedDeps.has(id))
330
+ if (this.existingOptimizedDeps.has(id)) {
268
331
  return true;
332
+ }
269
333
  if (fs.existsSync(id)) {
270
334
  this.existingOptimizedDeps.add(id);
271
335
  return true;
@@ -279,21 +343,28 @@ class ViteNodeServer {
279
343
  });
280
344
  }
281
345
  async resolveId(id, importer, transformMode) {
282
- if (importer && !importer.startsWith(utils.withTrailingSlash(this.server.config.root)))
346
+ if (importer && !importer.startsWith(utils.withTrailingSlash(this.server.config.root))) {
283
347
  importer = pathe.resolve(this.server.config.root, importer);
348
+ }
284
349
  const mode = transformMode ?? (importer && this.getTransformMode(importer) || "ssr");
285
- return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
350
+ return this.server.pluginContainer.resolveId(id, importer, {
351
+ ssr: mode === "ssr"
352
+ });
286
353
  }
287
354
  getSourceMap(source) {
288
355
  var _a, _b;
289
356
  const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
290
- if (fetchResult == null ? void 0 : fetchResult.map)
357
+ if (fetchResult == null ? void 0 : fetchResult.map) {
291
358
  return fetchResult.map;
359
+ }
292
360
  const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
293
361
  return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
294
362
  }
295
363
  assertMode(mode) {
296
- assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
364
+ assert(
365
+ mode === "web" || mode === "ssr",
366
+ `"transformMode" can only be "web" or "ssr", received "${mode}".`
367
+ );
297
368
  }
298
369
  async fetchModule(id, transformMode) {
299
370
  const mode = transformMode || this.getTransformMode(id);
@@ -306,9 +377,12 @@ class ViteNodeServer {
306
377
  this.assertMode(mode);
307
378
  const promiseMap = this.fetchPromiseMap[mode];
308
379
  if (!promiseMap.has(moduleId)) {
309
- promiseMap.set(moduleId, this._fetchModule(moduleId, mode).finally(() => {
310
- promiseMap.delete(moduleId);
311
- }));
380
+ promiseMap.set(
381
+ moduleId,
382
+ this._fetchModule(moduleId, mode).finally(() => {
383
+ promiseMap.delete(moduleId);
384
+ })
385
+ );
312
386
  }
313
387
  return promiseMap.get(moduleId);
314
388
  }
@@ -317,15 +391,21 @@ class ViteNodeServer {
317
391
  this.assertMode(mode);
318
392
  const promiseMap = this.transformPromiseMap[mode];
319
393
  if (!promiseMap.has(id)) {
320
- promiseMap.set(id, this._transformRequest(id, filepath, mode).finally(() => {
321
- promiseMap.delete(id);
322
- }));
394
+ promiseMap.set(
395
+ id,
396
+ this._transformRequest(id, filepath, mode).finally(() => {
397
+ promiseMap.delete(id);
398
+ })
399
+ );
323
400
  }
324
401
  return promiseMap.get(id);
325
402
  }
326
403
  async transformModule(id, transformMode) {
327
- if (transformMode !== "web")
328
- throw new Error('`transformModule` only supports `transformMode: "web"`.');
404
+ if (transformMode !== "web") {
405
+ throw new Error(
406
+ '`transformModule` only supports `transformMode: "web"`.'
407
+ );
408
+ }
329
409
  const normalizedId = utils.normalizeModuleId(id);
330
410
  const mod = this.server.moduleGraph.getModuleById(normalizedId);
331
411
  const result = (mod == null ? void 0 : mod.transformResult) || await this.server.transformRequest(normalizedId);
@@ -336,26 +416,34 @@ class ViteNodeServer {
336
416
  getTransformMode(id) {
337
417
  var _a, _b, _c, _d;
338
418
  const withoutQuery = id.split("?")[0];
339
- if ((_b = (_a = this.options.transformMode) == null ? void 0 : _a.web) == null ? void 0 : _b.some((r) => withoutQuery.match(r)))
419
+ if ((_b = (_a = this.options.transformMode) == null ? void 0 : _a.web) == null ? void 0 : _b.some((r) => withoutQuery.match(r))) {
340
420
  return "web";
341
- if ((_d = (_c = this.options.transformMode) == null ? void 0 : _c.ssr) == null ? void 0 : _d.some((r) => withoutQuery.match(r)))
421
+ }
422
+ if ((_d = (_c = this.options.transformMode) == null ? void 0 : _c.ssr) == null ? void 0 : _d.some((r) => withoutQuery.match(r))) {
342
423
  return "ssr";
343
- if (withoutQuery.match(/\.([cm]?[jt]sx?|json)$/))
424
+ }
425
+ if (withoutQuery.match(/\.([cm]?[jt]sx?|json)$/)) {
344
426
  return "ssr";
427
+ }
345
428
  return "web";
346
429
  }
347
430
  getChangedModule(id, file) {
348
431
  const module = this.server.moduleGraph.getModuleById(id) || this.server.moduleGraph.getModuleById(file);
349
- if (module)
432
+ if (module) {
350
433
  return module;
434
+ }
351
435
  const _modules = this.server.moduleGraph.getModulesByFile(file);
352
- if (!_modules || !_modules.size)
436
+ if (!_modules || !_modules.size) {
353
437
  return null;
438
+ }
354
439
  const modules = [..._modules];
355
440
  let mod = modules[0];
356
441
  let latestMax = -1;
357
442
  for (const m of _modules) {
358
- const timestamp = Math.max(m.lastHMRTimestamp, m.lastInvalidationTimestamp);
443
+ const timestamp = Math.max(
444
+ m.lastHMRTimestamp,
445
+ m.lastInvalidationTimestamp
446
+ );
359
447
  if (timestamp > latestMax) {
360
448
  latestMax = timestamp;
361
449
  mod = m;
@@ -368,10 +456,13 @@ class ViteNodeServer {
368
456
  let result;
369
457
  const cacheDir = (_a = this.options.deps) == null ? void 0 : _a.cacheDir;
370
458
  if (cacheDir && id.includes(cacheDir)) {
371
- if (!id.startsWith(utils.withTrailingSlash(this.server.config.root)))
459
+ if (!id.startsWith(utils.withTrailingSlash(this.server.config.root))) {
372
460
  id = pathe.join(this.server.config.root, id);
461
+ }
373
462
  const timeout = setTimeout(() => {
374
- throw new Error(`ViteNodeServer: ${id} not found. This is a bug, please report it.`);
463
+ throw new Error(
464
+ `ViteNodeServer: ${id} not found. This is a bug, please report it.`
465
+ );
375
466
  }, 5e3);
376
467
  await this.ensureExists(id);
377
468
  clearTimeout(timeout);
@@ -379,9 +470,13 @@ class ViteNodeServer {
379
470
  const { path: filePath } = utils.toFilePath(id, this.server.config.root);
380
471
  const moduleNode = this.getChangedModule(id, filePath);
381
472
  const cache = this.fetchCaches[transformMode].get(filePath);
382
- const timestamp = moduleNode ? Math.max(moduleNode.lastHMRTimestamp, moduleNode.lastInvalidationTimestamp) : 0;
383
- if (cache && (timestamp === 0 || cache.timestamp >= timestamp))
473
+ const timestamp = moduleNode ? Math.max(
474
+ moduleNode.lastHMRTimestamp,
475
+ moduleNode.lastInvalidationTimestamp
476
+ ) : 0;
477
+ if (cache && (timestamp === 0 || cache.timestamp >= timestamp)) {
384
478
  return cache.result;
479
+ }
385
480
  const time = Date.now();
386
481
  const externalize = await this.shouldExternalize(filePath);
387
482
  let duration;
@@ -400,10 +495,7 @@ class ViteNodeServer {
400
495
  result
401
496
  };
402
497
  const durations = this.durations[transformMode].get(filePath) || [];
403
- this.durations[transformMode].set(
404
- filePath,
405
- [...durations, duration ?? 0]
406
- );
498
+ this.durations[transformMode].set(filePath, [...durations, duration ?? 0]);
407
499
  this.fetchCaches[transformMode].set(filePath, cacheEntry);
408
500
  this.fetchCache.set(filePath, cacheEntry);
409
501
  return result;
@@ -421,21 +513,25 @@ class ViteNodeServer {
421
513
  let result = null;
422
514
  if ((_a = this.options.debug) == null ? void 0 : _a.loadDumppedModules) {
423
515
  result = await ((_b = this.debugger) == null ? void 0 : _b.loadDump(id)) ?? null;
424
- if (result)
516
+ if (result) {
425
517
  return result;
518
+ }
426
519
  }
427
520
  if (transformMode === "web") {
428
521
  result = await this.server.transformRequest(id);
429
- if (result)
522
+ if (result) {
430
523
  result = await this.server.ssrTransform(result.code, result.map, id);
524
+ }
431
525
  } else {
432
526
  result = await this.server.transformRequest(id, { ssr: true });
433
527
  }
434
528
  const sourcemap = this.options.sourcemap ?? "inline";
435
- if (sourcemap === "inline" && result && !id.includes("node_modules"))
529
+ if (sourcemap === "inline" && result && !id.includes("node_modules")) {
436
530
  result = await this.processTransformResult(filepath, result);
437
- if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
531
+ }
532
+ if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules) {
438
533
  await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
534
+ }
439
535
  return result;
440
536
  }
441
537
  }
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TransformResult, ViteDevServer } from 'vite';
2
- import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-C38RQo3J.js';
2
+ import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-D1EszD4V.js';
3
3
  import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
4
4
 
5
5
  declare class Debugger {