vite-node 0.25.4 → 0.25.6

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/cli.cjs CHANGED
@@ -632,7 +632,7 @@ class CAC extends events.EventEmitter {
632
632
 
633
633
  const cac = (name = "") => new CAC(name);
634
634
 
635
- var version = "0.25.4";
635
+ var version = "0.25.6";
636
636
 
637
637
  const cli = cac("vite-node");
638
638
  cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
package/dist/cli.mjs CHANGED
@@ -630,7 +630,7 @@ class CAC extends EventEmitter {
630
630
 
631
631
  const cac = (name = "") => new CAC(name);
632
632
 
633
- var version = "0.25.4";
633
+ var version = "0.25.6";
634
634
 
635
635
  const cli = cac("vite-node");
636
636
  cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
package/dist/client.cjs CHANGED
@@ -176,10 +176,10 @@ class ViteNodeRunner {
176
176
  }
177
177
  async directRequest(id, fsPath, _callstack) {
178
178
  const callstack = [..._callstack, fsPath];
179
- const mod = this.moduleCache.get(fsPath);
180
- const request = async (dep) => {
179
+ let mod = this.moduleCache.get(fsPath);
180
+ const request = async (dep2) => {
181
181
  var _a;
182
- const depFsPath = utils.toFilePath(utils.normalizeRequestId(dep, this.options.base), this.root);
182
+ const depFsPath = utils.toFilePath(utils.normalizeRequestId(dep2, this.options.base), this.root);
183
183
  const getStack = () => {
184
184
  return `stack:
185
185
  ${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
@@ -195,28 +195,42 @@ ${getStack()}`), 2e3);
195
195
  return depExports;
196
196
  throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
197
197
  }
198
- return await this.cachedRequest(dep, callstack);
198
+ return await this.cachedRequest(dep2, callstack);
199
199
  } finally {
200
200
  if (debugTimer)
201
201
  clearTimeout(debugTimer);
202
202
  }
203
203
  };
204
204
  Object.defineProperty(request, "callstack", { get: () => callstack });
205
- const resolveId = async (dep, callstackPosition = 1) => {
206
- if (this.options.resolveId && this.shouldResolveId(dep)) {
205
+ const resolveId = async (dep2, callstackPosition = 1) => {
206
+ if (this.options.resolveId && this.shouldResolveId(dep2)) {
207
207
  let importer = callstack[callstack.length - callstackPosition];
208
+ if (importer && !dep2.startsWith("."))
209
+ importer = void 0;
208
210
  if (importer && importer.startsWith("mock:"))
209
211
  importer = importer.slice(5);
210
- const { id: id2 } = await this.options.resolveId(dep, importer) || {};
211
- dep = id2 && pathe.isAbsolute(id2) ? utils.mergeSlashes(`/@fs/${id2}`) : id2 || dep;
212
+ const resolved = await this.options.resolveId(utils.normalizeRequestId(dep2), importer);
213
+ return [dep2, resolved == null ? void 0 : resolved.id];
212
214
  }
213
- return dep;
215
+ return [dep2, void 0];
214
216
  };
215
- id = await resolveId(id, 2);
217
+ const [dep, resolvedId] = await resolveId(id, 2);
216
218
  const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
217
219
  if (id in requestStubs)
218
220
  return requestStubs[id];
219
- let { code: transformed, externalize } = await this.options.fetchModule(id);
221
+ let { code: transformed, externalize } = await this.options.fetchModule(resolvedId || dep);
222
+ if (resolvedId && !fsPath.includes("?") && fsPath !== resolvedId) {
223
+ if (this.moduleCache.has(resolvedId)) {
224
+ mod = this.moduleCache.get(resolvedId);
225
+ this.moduleCache.set(fsPath, mod);
226
+ if (mod.promise)
227
+ return mod.promise;
228
+ if (mod.exports)
229
+ return mod.exports;
230
+ } else {
231
+ this.moduleCache.set(resolvedId, mod);
232
+ }
233
+ }
220
234
  if (externalize) {
221
235
  debugNative(externalize);
222
236
  const exports2 = await this.interopedImport(externalize);
@@ -225,7 +239,8 @@ ${getStack()}`), 2e3);
225
239
  }
226
240
  if (transformed == null)
227
241
  throw new Error(`[vite-node] Failed to load ${id}`);
228
- const url$1 = url.pathToFileURL(fsPath).href;
242
+ const file = utils.cleanUrl(resolvedId || fsPath);
243
+ const url$1 = url.pathToFileURL(file).href;
229
244
  const meta = { url: url$1 };
230
245
  const exports = /* @__PURE__ */ Object.create(null);
231
246
  Object.defineProperty(exports, Symbol.toStringTag, {
@@ -234,9 +249,6 @@ ${getStack()}`), 2e3);
234
249
  configurable: false
235
250
  });
236
251
  const cjsExports = new Proxy(exports, {
237
- get(_, p, receiver) {
238
- return Reflect.get(exports, p, receiver);
239
- },
240
252
  set(_, p, value) {
241
253
  if (!Reflect.has(exports, "default"))
242
254
  exports.default = {};
@@ -250,7 +262,7 @@ ${getStack()}`), 2e3);
250
262
  return true;
251
263
  }
252
264
  });
253
- Object.assign(mod, { code: transformed, exports, evaluated: false });
265
+ Object.assign(mod, { code: transformed, exports });
254
266
  const __filename = url.fileURLToPath(url$1);
255
267
  const moduleProxy = {
256
268
  set exports(value) {
@@ -292,7 +304,7 @@ ${getStack()}`), 2e3);
292
304
  const code = `${codeDefinition}${transformed}
293
305
  }}`;
294
306
  const fn = vm__default["default"].runInThisContext(code, {
295
- filename: fsPath,
307
+ filename: __filename,
296
308
  lineOffset: 0,
297
309
  columnOffset: -codeDefinition.length
298
310
  });
package/dist/client.mjs CHANGED
@@ -4,7 +4,7 @@ import vm from 'vm';
4
4
  import { resolve, dirname, isAbsolute, extname } from 'pathe';
5
5
  import { isNodeBuiltin } from 'mlly';
6
6
  import createDebug from 'debug';
7
- import { normalizeModuleId, slash, normalizeRequestId, toFilePath, isPrimitive, mergeSlashes } from './utils.mjs';
7
+ import { normalizeModuleId, slash, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
8
8
  import { extractSourceMap } from './source-map.mjs';
9
9
  import 'fs';
10
10
  import 'source-map-support';
@@ -149,10 +149,10 @@ class ViteNodeRunner {
149
149
  }
150
150
  async directRequest(id, fsPath, _callstack) {
151
151
  const callstack = [..._callstack, fsPath];
152
- const mod = this.moduleCache.get(fsPath);
153
- const request = async (dep) => {
152
+ let mod = this.moduleCache.get(fsPath);
153
+ const request = async (dep2) => {
154
154
  var _a;
155
- const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
155
+ const depFsPath = toFilePath(normalizeRequestId(dep2, this.options.base), this.root);
156
156
  const getStack = () => {
157
157
  return `stack:
158
158
  ${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
@@ -168,28 +168,42 @@ ${getStack()}`), 2e3);
168
168
  return depExports;
169
169
  throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
170
170
  }
171
- return await this.cachedRequest(dep, callstack);
171
+ return await this.cachedRequest(dep2, callstack);
172
172
  } finally {
173
173
  if (debugTimer)
174
174
  clearTimeout(debugTimer);
175
175
  }
176
176
  };
177
177
  Object.defineProperty(request, "callstack", { get: () => callstack });
178
- const resolveId = async (dep, callstackPosition = 1) => {
179
- if (this.options.resolveId && this.shouldResolveId(dep)) {
178
+ const resolveId = async (dep2, callstackPosition = 1) => {
179
+ if (this.options.resolveId && this.shouldResolveId(dep2)) {
180
180
  let importer = callstack[callstack.length - callstackPosition];
181
+ if (importer && !dep2.startsWith("."))
182
+ importer = void 0;
181
183
  if (importer && importer.startsWith("mock:"))
182
184
  importer = importer.slice(5);
183
- const { id: id2 } = await this.options.resolveId(dep, importer) || {};
184
- dep = id2 && isAbsolute(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
185
+ const resolved = await this.options.resolveId(normalizeRequestId(dep2), importer);
186
+ return [dep2, resolved == null ? void 0 : resolved.id];
185
187
  }
186
- return dep;
188
+ return [dep2, void 0];
187
189
  };
188
- id = await resolveId(id, 2);
190
+ const [dep, resolvedId] = await resolveId(id, 2);
189
191
  const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
190
192
  if (id in requestStubs)
191
193
  return requestStubs[id];
192
- let { code: transformed, externalize } = await this.options.fetchModule(id);
194
+ let { code: transformed, externalize } = await this.options.fetchModule(resolvedId || dep);
195
+ if (resolvedId && !fsPath.includes("?") && fsPath !== resolvedId) {
196
+ if (this.moduleCache.has(resolvedId)) {
197
+ mod = this.moduleCache.get(resolvedId);
198
+ this.moduleCache.set(fsPath, mod);
199
+ if (mod.promise)
200
+ return mod.promise;
201
+ if (mod.exports)
202
+ return mod.exports;
203
+ } else {
204
+ this.moduleCache.set(resolvedId, mod);
205
+ }
206
+ }
193
207
  if (externalize) {
194
208
  debugNative(externalize);
195
209
  const exports2 = await this.interopedImport(externalize);
@@ -198,7 +212,8 @@ ${getStack()}`), 2e3);
198
212
  }
199
213
  if (transformed == null)
200
214
  throw new Error(`[vite-node] Failed to load ${id}`);
201
- const url = pathToFileURL(fsPath).href;
215
+ const file = cleanUrl(resolvedId || fsPath);
216
+ const url = pathToFileURL(file).href;
202
217
  const meta = { url };
203
218
  const exports = /* @__PURE__ */ Object.create(null);
204
219
  Object.defineProperty(exports, Symbol.toStringTag, {
@@ -207,9 +222,6 @@ ${getStack()}`), 2e3);
207
222
  configurable: false
208
223
  });
209
224
  const cjsExports = new Proxy(exports, {
210
- get(_, p, receiver) {
211
- return Reflect.get(exports, p, receiver);
212
- },
213
225
  set(_, p, value) {
214
226
  if (!Reflect.has(exports, "default"))
215
227
  exports.default = {};
@@ -223,7 +235,7 @@ ${getStack()}`), 2e3);
223
235
  return true;
224
236
  }
225
237
  });
226
- Object.assign(mod, { code: transformed, exports, evaluated: false });
238
+ Object.assign(mod, { code: transformed, exports });
227
239
  const __filename = fileURLToPath(url);
228
240
  const moduleProxy = {
229
241
  set exports(value) {
@@ -265,7 +277,7 @@ ${getStack()}`), 2e3);
265
277
  const code = `${codeDefinition}${transformed}
266
278
  }}`;
267
279
  const fn = vm.runInThisContext(code, {
268
- filename: fsPath,
280
+ filename: __filename,
269
281
  lineOffset: 0,
270
282
  columnOffset: -codeDefinition.length
271
283
  });
package/dist/server.cjs CHANGED
@@ -175,7 +175,6 @@ ${result.code}`, "utf-8");
175
175
  }
176
176
 
177
177
  const debugRequest = createDebug__default["default"]("vite-node:server:request");
178
- const RealDate = Date;
179
178
  class ViteNodeServer {
180
179
  constructor(server, options = {}) {
181
180
  this.server = server;
@@ -222,6 +221,7 @@ class ViteNodeServer {
222
221
  return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
223
222
  }
224
223
  async fetchModule(id) {
224
+ id = utils.normalizeModuleId(id);
225
225
  if (!this.fetchPromiseMap.has(id)) {
226
226
  this.fetchPromiseMap.set(
227
227
  id,
@@ -261,10 +261,11 @@ class ViteNodeServer {
261
261
  let result;
262
262
  const filePath = utils.toFilePath(id, this.server.config.root);
263
263
  const module = this.server.moduleGraph.getModuleById(id);
264
- const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || RealDate.now();
264
+ const timestamp = module ? module.lastHMRTimestamp : null;
265
265
  const cache = this.fetchCache.get(filePath);
266
- if (timestamp && cache && cache.timestamp >= timestamp)
266
+ if (timestamp !== null && cache && cache.timestamp >= timestamp)
267
267
  return cache.result;
268
+ const time = Date.now();
268
269
  const externalize = await this.shouldExternalize(filePath);
269
270
  let duration;
270
271
  if (externalize) {
@@ -278,7 +279,7 @@ class ViteNodeServer {
278
279
  }
279
280
  this.fetchCache.set(filePath, {
280
281
  duration,
281
- timestamp,
282
+ timestamp: time,
282
283
  result
283
284
  });
284
285
  return result;
package/dist/server.mjs CHANGED
@@ -3,7 +3,7 @@ import { resolve, join } from 'pathe';
3
3
  import createDebug from 'debug';
4
4
  import { existsSync, promises } from 'fs';
5
5
  import { isNodeBuiltin, isValidNodeImport } from 'mlly';
6
- import { slash, toArray, toFilePath } from './utils.mjs';
6
+ import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
7
7
  import { p as picocolors } from './chunk-picocolors.mjs';
8
8
  import { withInlineSourcemap } from './source-map.mjs';
9
9
  import 'url';
@@ -167,7 +167,6 @@ ${result.code}`, "utf-8");
167
167
  }
168
168
 
169
169
  const debugRequest = createDebug("vite-node:server:request");
170
- const RealDate = Date;
171
170
  class ViteNodeServer {
172
171
  constructor(server, options = {}) {
173
172
  this.server = server;
@@ -214,6 +213,7 @@ class ViteNodeServer {
214
213
  return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
215
214
  }
216
215
  async fetchModule(id) {
216
+ id = normalizeModuleId(id);
217
217
  if (!this.fetchPromiseMap.has(id)) {
218
218
  this.fetchPromiseMap.set(
219
219
  id,
@@ -253,10 +253,11 @@ class ViteNodeServer {
253
253
  let result;
254
254
  const filePath = toFilePath(id, this.server.config.root);
255
255
  const module = this.server.moduleGraph.getModuleById(id);
256
- const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || RealDate.now();
256
+ const timestamp = module ? module.lastHMRTimestamp : null;
257
257
  const cache = this.fetchCache.get(filePath);
258
- if (timestamp && cache && cache.timestamp >= timestamp)
258
+ if (timestamp !== null && cache && cache.timestamp >= timestamp)
259
259
  return cache.result;
260
+ const time = Date.now();
260
261
  const externalize = await this.shouldExternalize(filePath);
261
262
  let duration;
262
263
  if (externalize) {
@@ -270,7 +271,7 @@ class ViteNodeServer {
270
271
  }
271
272
  this.fetchCache.set(filePath, {
272
273
  duration,
273
- timestamp,
274
+ timestamp: time,
274
275
  result
275
276
  });
276
277
  return result;
@@ -6,18 +6,22 @@ var sourceMapSupport = require('source-map-support');
6
6
 
7
7
  let SOURCEMAPPING_URL = "sourceMa";
8
8
  SOURCEMAPPING_URL += "ppingURL";
9
- const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;source=vite-node`;
9
+ const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
10
+ const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
10
11
  const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
11
- const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`);
12
12
  async function withInlineSourcemap(result) {
13
- const { code, map } = result;
14
- if (!map || code.includes(VITE_NODE_SOURCEMAPPING_URL))
13
+ const map = result.map;
14
+ let code = result.code;
15
+ if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
15
16
  return result;
16
- if (OTHER_SOURCE_MAP_REGEXP.test(code))
17
- result.code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
18
- result.code = `${code}
17
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
18
+ while (OTHER_SOURCE_MAP_REGEXP.test(code))
19
+ code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
20
+ const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
21
+ result.code = `${code.trimEnd()}
19
22
 
20
- //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
23
+ ${VITE_NODE_SOURCEMAPPING_SOURCE}
24
+ //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
21
25
  `;
22
26
  return result;
23
27
  }
@@ -2,18 +2,22 @@ import { install } from 'source-map-support';
2
2
 
3
3
  let SOURCEMAPPING_URL = "sourceMa";
4
4
  SOURCEMAPPING_URL += "ppingURL";
5
- const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;source=vite-node`;
5
+ const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
6
+ const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
6
7
  const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
7
- const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`);
8
8
  async function withInlineSourcemap(result) {
9
- const { code, map } = result;
10
- if (!map || code.includes(VITE_NODE_SOURCEMAPPING_URL))
9
+ const map = result.map;
10
+ let code = result.code;
11
+ if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
11
12
  return result;
12
- if (OTHER_SOURCE_MAP_REGEXP.test(code))
13
- result.code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
14
- result.code = `${code}
13
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
14
+ while (OTHER_SOURCE_MAP_REGEXP.test(code))
15
+ code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
16
+ const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
17
+ result.code = `${code.trimEnd()}
15
18
 
16
- //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
19
+ ${VITE_NODE_SOURCEMAPPING_SOURCE}
20
+ //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
17
21
  `;
18
22
  return result;
19
23
  }
package/dist/utils.cjs CHANGED
@@ -19,6 +19,9 @@ function normalizeRequestId(id, base) {
19
19
  id = `/${id.slice(base.length)}`;
20
20
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
21
21
  }
22
+ const queryRE = /\?.*$/s;
23
+ const hashRE = /#.*$/s;
24
+ const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
22
25
  function normalizeModuleId(id) {
23
26
  return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
24
27
  }
@@ -59,12 +62,15 @@ function toArray(array) {
59
62
  return [array];
60
63
  }
61
64
 
65
+ exports.cleanUrl = cleanUrl;
66
+ exports.hashRE = hashRE;
62
67
  exports.isPrimitive = isPrimitive;
63
68
  exports.isWindows = isWindows;
64
69
  exports.mergeSlashes = mergeSlashes;
65
70
  exports.normalizeModuleId = normalizeModuleId;
66
71
  exports.normalizeRequestId = normalizeRequestId;
67
72
  exports.pathFromRoot = pathFromRoot;
73
+ exports.queryRE = queryRE;
68
74
  exports.slash = slash;
69
75
  exports.toArray = toArray;
70
76
  exports.toFilePath = toFilePath;
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,9 @@ declare const isWindows: boolean;
4
4
  declare function slash(str: string): string;
5
5
  declare function mergeSlashes(str: string): string;
6
6
  declare function normalizeRequestId(id: string, base?: string): string;
7
+ declare const queryRE: RegExp;
8
+ declare const hashRE: RegExp;
9
+ declare const cleanUrl: (url: string) => string;
7
10
  declare function normalizeModuleId(id: string): string;
8
11
  declare function isPrimitive(v: any): boolean;
9
12
  declare function pathFromRoot(root: string, filename: string): string;
@@ -15,4 +18,4 @@ declare function toFilePath(id: string, root: string): string;
15
18
  */
16
19
  declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
17
20
 
18
- export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, slash, toArray, toFilePath };
21
+ export { cleanUrl, hashRE, isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, queryRE, slash, toArray, toFilePath };
package/dist/utils.mjs CHANGED
@@ -15,6 +15,9 @@ function normalizeRequestId(id, base) {
15
15
  id = `/${id.slice(base.length)}`;
16
16
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
17
17
  }
18
+ const queryRE = /\?.*$/s;
19
+ const hashRE = /#.*$/s;
20
+ const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
18
21
  function normalizeModuleId(id) {
19
22
  return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
20
23
  }
@@ -55,4 +58,4 @@ function toArray(array) {
55
58
  return [array];
56
59
  }
57
60
 
58
- export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, slash, toArray, toFilePath };
61
+ export { cleanUrl, hashRE, isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, queryRE, slash, toArray, toFilePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.25.4",
3
+ "version": "0.25.6",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",