vite-node 2.0.0-beta.2 → 2.0.0-beta.4

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
@@ -20,7 +20,7 @@ require('node:url');
20
20
  require('node:vm');
21
21
  require('node:events');
22
22
 
23
- var version = "2.0.0-beta.2";
23
+ var version = "2.0.0-beta.4";
24
24
 
25
25
  const cli = cac("vite-node");
26
26
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { V as ViteNodeServerOptions } from './index-C38RQo3J.js';
1
+ import { V as ViteNodeServerOptions } from './index-D1EszD4V.js';
2
2
  import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  interface CliOptions {
package/dist/cli.mjs CHANGED
@@ -18,7 +18,7 @@ import 'node:url';
18
18
  import 'node:vm';
19
19
  import 'node:events';
20
20
 
21
- var version = "2.0.0-beta.2";
21
+ var version = "2.0.0-beta.4";
22
22
 
23
23
  const cli = cac("vite-node");
24
24
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/client.cjs CHANGED
@@ -344,7 +344,7 @@ ${getStack()}`), 2e3);
344
344
  });
345
345
  debugExecute(__filename);
346
346
  if (transformed[0] === "#")
347
- transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
347
+ transformed = transformed.replace(/^#!.*/, (s) => " ".repeat(s.length));
348
348
  await this.runModule(context, transformed);
349
349
  return exports;
350
350
  }
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-C38RQo3J.js';
1
+ export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-D1EszD4V.js';
2
2
  import './trace-mapping.d-DLVdEqOp.js';
package/dist/client.mjs CHANGED
@@ -342,7 +342,7 @@ ${getStack()}`), 2e3);
342
342
  });
343
343
  debugExecute(__filename);
344
344
  if (transformed[0] === "#")
345
- transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
345
+ transformed = transformed.replace(/^#!.*/, (s) => " ".repeat(s.length));
346
346
  await this.runModule(context, transformed);
347
347
  return exports;
348
348
  }
package/dist/hmr.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { HMRPayload, Plugin } from 'vite';
3
- import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-C38RQo3J.js';
3
+ import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-D1EszD4V.js';
4
4
  import './trace-mapping.d-DLVdEqOp.js';
5
5
 
6
6
  type EventType = string | symbol;
@@ -274,6 +274,11 @@ interface ViteNodeResolveId {
274
274
  moduleSideEffects?: boolean | 'no-treeshake' | null;
275
275
  syntheticNamedExports?: boolean | string | null;
276
276
  }
277
+ interface ViteNodeResolveModule {
278
+ external: string | null;
279
+ id: string;
280
+ fsPath: string;
281
+ }
277
282
  interface ViteNodeServerOptions {
278
283
  /**
279
284
  * Inject inline sourcemap to modules
@@ -306,4 +311,4 @@ interface DebuggerOptions {
306
311
  loadDumppedModules?: boolean;
307
312
  }
308
313
 
309
- export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type Awaitable as f, type FetchFunction as g, type ResolveIdFunction as h, type CreateHotContextFunction as i, type ModuleCache as j, type ViteNodeRunnerOptions as k };
314
+ export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type Awaitable as f, type FetchFunction as g, type ResolveIdFunction as h, type CreateHotContextFunction as i, type ModuleCache as j, type ViteNodeRunnerOptions as k, type ViteNodeResolveModule as l };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-C38RQo3J.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-D1EszD4V.js';
2
2
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
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 = [
@@ -63,7 +63,7 @@ async function isValidNodeImport(id) {
63
63
  const package_ = await utils.findNearestPackageData(pathe.dirname(id));
64
64
  if (package_.type === "module")
65
65
  return true;
66
- if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id))
66
+ if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id))
67
67
  return false;
68
68
  const code = await fs.promises.readFile(id, "utf8").catch(() => "");
69
69
  return !ESM_SYNTAX_RE.test(code);
@@ -77,7 +77,7 @@ async function shouldExternalize(id, options, cache = _defaultExternalizeCache)
77
77
  async function _shouldExternalize(id, options) {
78
78
  if (utils.isNodeBuiltin(id))
79
79
  return id;
80
- if (id.startsWith("data:") || /^(https?:)?\/\//.test(id))
80
+ if (id.startsWith("data:") || /^(?:https?:)?\/\//.test(id))
81
81
  return id;
82
82
  id = patchWindowsImportPath(id);
83
83
  if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir))
@@ -153,7 +153,7 @@ class Debugger {
153
153
  await fs.promises.mkdir(this.dumpDir, { recursive: true });
154
154
  }
155
155
  encodeId(id) {
156
- return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
156
+ return `${id.replace(/[^\w@\-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
157
157
  }
158
158
  async recordExternalize(id, path) {
159
159
  if (!this.dumpDir)
@@ -179,7 +179,7 @@ ${result.code}`, "utf-8");
179
179
  return null;
180
180
  const code = await fs.promises.readFile(path, "utf-8");
181
181
  return {
182
- code: code.replace(/^\/\/.*?\n/, ""),
182
+ code: code.replace(/^\/\/.*\n/, ""),
183
183
  map: void 0
184
184
  };
185
185
  }
@@ -284,6 +284,20 @@ class ViteNodeServer {
284
284
  const mode = transformMode ?? (importer && this.getTransformMode(importer) || "ssr");
285
285
  return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
286
286
  }
287
+ async resolveModule(rawId, resolved) {
288
+ const id = (resolved == null ? void 0 : resolved.id) || rawId;
289
+ const external = !pathe.isAbsolute(id) || this.isModuleDirectory(id) ? rawId : null;
290
+ return {
291
+ id,
292
+ fsPath: utils.cleanUrl(id),
293
+ external
294
+ };
295
+ }
296
+ isModuleDirectory(path) {
297
+ var _a;
298
+ const moduleDirectories = ((_a = this.options.deps) == null ? void 0 : _a.moduleDirectories) || ["/node_modules/"];
299
+ return moduleDirectories.some((dir) => path.includes(dir));
300
+ }
287
301
  getSourceMap(source) {
288
302
  var _a, _b;
289
303
  const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
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 {
@@ -43,6 +43,12 @@ declare class ViteNodeServer {
43
43
  getTotalDuration(): number;
44
44
  private ensureExists;
45
45
  resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
46
+ resolveModule(rawId: string, resolved: ViteNodeResolveId | null): Promise<{
47
+ id: string;
48
+ fsPath: string;
49
+ external: string | null;
50
+ }>;
51
+ private isModuleDirectory;
46
52
  getSourceMap(source: string): EncodedSourceMap | null;
47
53
  private assertMode;
48
54
  fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
package/dist/server.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { existsSync, promises } from 'node:fs';
3
3
  import assert from 'node:assert';
4
- import { join, extname, dirname, resolve, relative, normalize } from 'pathe';
4
+ import { join, extname, dirname, resolve, relative, normalize, isAbsolute } from 'pathe';
5
5
  import createDebug from 'debug';
6
- import { isNodeBuiltin, slash, findNearestPackageData, toArray, withTrailingSlash, normalizeModuleId, toFilePath } from './utils.mjs';
6
+ import { isNodeBuiltin, slash, findNearestPackageData, toArray, withTrailingSlash, cleanUrl, normalizeModuleId, toFilePath } from './utils.mjs';
7
7
  import { KNOWN_ASSET_TYPES } from './constants.mjs';
8
8
  import c from 'picocolors';
9
9
  import { withInlineSourcemap } from './source-map.mjs';
@@ -12,7 +12,7 @@ import 'node:module';
12
12
  import 'node:path';
13
13
 
14
14
  const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
15
- 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;
15
+ 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;
16
16
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
17
17
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
18
18
  const defaultInline = [
@@ -61,7 +61,7 @@ async function isValidNodeImport(id) {
61
61
  const package_ = await findNearestPackageData(dirname(id));
62
62
  if (package_.type === "module")
63
63
  return true;
64
- if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id))
64
+ if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id))
65
65
  return false;
66
66
  const code = await promises.readFile(id, "utf8").catch(() => "");
67
67
  return !ESM_SYNTAX_RE.test(code);
@@ -75,7 +75,7 @@ async function shouldExternalize(id, options, cache = _defaultExternalizeCache)
75
75
  async function _shouldExternalize(id, options) {
76
76
  if (isNodeBuiltin(id))
77
77
  return id;
78
- if (id.startsWith("data:") || /^(https?:)?\/\//.test(id))
78
+ if (id.startsWith("data:") || /^(?:https?:)?\/\//.test(id))
79
79
  return id;
80
80
  id = patchWindowsImportPath(id);
81
81
  if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir))
@@ -151,7 +151,7 @@ class Debugger {
151
151
  await promises.mkdir(this.dumpDir, { recursive: true });
152
152
  }
153
153
  encodeId(id) {
154
- return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
154
+ return `${id.replace(/[^\w@\-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
155
155
  }
156
156
  async recordExternalize(id, path) {
157
157
  if (!this.dumpDir)
@@ -177,7 +177,7 @@ ${result.code}`, "utf-8");
177
177
  return null;
178
178
  const code = await promises.readFile(path, "utf-8");
179
179
  return {
180
- code: code.replace(/^\/\/.*?\n/, ""),
180
+ code: code.replace(/^\/\/.*\n/, ""),
181
181
  map: void 0
182
182
  };
183
183
  }
@@ -282,6 +282,20 @@ class ViteNodeServer {
282
282
  const mode = transformMode ?? (importer && this.getTransformMode(importer) || "ssr");
283
283
  return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
284
284
  }
285
+ async resolveModule(rawId, resolved) {
286
+ const id = (resolved == null ? void 0 : resolved.id) || rawId;
287
+ const external = !isAbsolute(id) || this.isModuleDirectory(id) ? rawId : null;
288
+ return {
289
+ id,
290
+ fsPath: cleanUrl(id),
291
+ external
292
+ };
293
+ }
294
+ isModuleDirectory(path) {
295
+ var _a;
296
+ const moduleDirectories = ((_a = this.options.deps) == null ? void 0 : _a.moduleDirectories) || ["/node_modules/"];
297
+ return moduleDirectories.some((dir) => path.includes(dir));
298
+ }
285
299
  getSourceMap(source) {
286
300
  var _a, _b;
287
301
  const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
@@ -609,10 +609,10 @@ function supportRelativeURL(file, url) {
609
609
  if (!file)
610
610
  return url;
611
611
  const dir = path.dirname(file);
612
- const match = /^\w+:\/\/[^\/]*/.exec(dir);
612
+ const match = /^\w+:\/\/[^/]*/.exec(dir);
613
613
  let protocol = match ? match[0] : "";
614
614
  const startPath = dir.slice(protocol.length);
615
- if (protocol && /^\/\w\:/.test(startPath)) {
615
+ if (protocol && /^\/\w:/.test(startPath)) {
616
616
  protocol += "/";
617
617
  return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, "/");
618
618
  }
@@ -622,7 +622,7 @@ function retrieveSourceMapURL(source) {
622
622
  const fileData = retrieveFile(source);
623
623
  if (!fileData)
624
624
  return null;
625
- const re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
625
+ const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
626
626
  let lastMatch, match;
627
627
  while (match = re.exec(fileData)) lastMatch = match;
628
628
  if (!lastMatch)
@@ -784,7 +784,7 @@ function wrapCallSite(frame, state) {
784
784
  if (source) {
785
785
  const line = frame.getLineNumber();
786
786
  let column = frame.getColumnNumber() - 1;
787
- const noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
787
+ const noHeader = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
788
788
  const headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
789
789
  if (line === 1 && column > headerLength && !frame.isEval())
790
790
  column -= headerLength;
@@ -607,10 +607,10 @@ function supportRelativeURL(file, url) {
607
607
  if (!file)
608
608
  return url;
609
609
  const dir = path.dirname(file);
610
- const match = /^\w+:\/\/[^\/]*/.exec(dir);
610
+ const match = /^\w+:\/\/[^/]*/.exec(dir);
611
611
  let protocol = match ? match[0] : "";
612
612
  const startPath = dir.slice(protocol.length);
613
- if (protocol && /^\/\w\:/.test(startPath)) {
613
+ if (protocol && /^\/\w:/.test(startPath)) {
614
614
  protocol += "/";
615
615
  return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, "/");
616
616
  }
@@ -620,7 +620,7 @@ function retrieveSourceMapURL(source) {
620
620
  const fileData = retrieveFile(source);
621
621
  if (!fileData)
622
622
  return null;
623
- const re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
623
+ const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
624
624
  let lastMatch, match;
625
625
  while (match = re.exec(fileData)) lastMatch = match;
626
626
  if (!lastMatch)
@@ -782,7 +782,7 @@ function wrapCallSite(frame, state) {
782
782
  if (source) {
783
783
  const line = frame.getLineNumber();
784
784
  let column = frame.getColumnNumber() - 1;
785
- const noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
785
+ const noHeader = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
786
786
  const headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
787
787
  if (line === 1 && column > headerLength && !frame.isEval())
788
788
  column -= headerLength;
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-C38RQo3J.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-D1EszD4V.js';
2
2
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
package/dist/utils.cjs CHANGED
@@ -21,16 +21,15 @@ function normalizeRequestId(id, base) {
21
21
  id = id.replace(driveOppositeRegext, `${drive}$1`);
22
22
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^file:/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
23
23
  }
24
- const queryRE = /\?.*$/s;
25
- const hashRE = /#.*$/s;
24
+ const postfixRE = /[?#].*$/;
26
25
  function cleanUrl(url) {
27
- return url.replace(hashRE, "").replace(queryRE, "");
26
+ return url.replace(postfixRE, "");
28
27
  }
29
28
  const internalRequests = [
30
29
  "@vite/client",
31
30
  "@vite/env"
32
31
  ];
33
- const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
32
+ const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
34
33
  function isInternalRequest(id) {
35
34
  return internalRequestRegexp.test(id);
36
35
  }
@@ -179,14 +178,12 @@ exports.cleanUrl = cleanUrl;
179
178
  exports.createImportMetaEnvProxy = createImportMetaEnvProxy;
180
179
  exports.findNearestPackageData = findNearestPackageData;
181
180
  exports.getCachedData = getCachedData;
182
- exports.hashRE = hashRE;
183
181
  exports.isInternalRequest = isInternalRequest;
184
182
  exports.isNodeBuiltin = isNodeBuiltin;
185
183
  exports.isPrimitive = isPrimitive;
186
184
  exports.isWindows = isWindows;
187
185
  exports.normalizeModuleId = normalizeModuleId;
188
186
  exports.normalizeRequestId = normalizeRequestId;
189
- exports.queryRE = queryRE;
190
187
  exports.setCacheData = setCacheData;
191
188
  exports.slash = slash;
192
189
  exports.toArray = toArray;
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { N as Nullable, A as Arrayable } from './index-C38RQo3J.js';
1
+ import { N as Nullable, A as Arrayable } from './index-D1EszD4V.js';
2
2
  import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  declare const isWindows: boolean;
5
5
  declare function slash(str: string): string;
6
6
  declare const VALID_ID_PREFIX = "/@id/";
7
7
  declare function normalizeRequestId(id: string, base?: string): string;
8
- declare const queryRE: RegExp;
9
- declare const hashRE: RegExp;
10
8
  declare function cleanUrl(url: string): string;
11
9
  declare function isInternalRequest(id: string): boolean;
12
10
  declare function normalizeModuleId(id: string): string;
@@ -30,4 +28,4 @@ declare function findNearestPackageData(basedir: string): Promise<{
30
28
  type?: 'module' | 'commonjs';
31
29
  }>;
32
30
 
33
- export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
31
+ export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
package/dist/utils.mjs CHANGED
@@ -19,16 +19,15 @@ function normalizeRequestId(id, base) {
19
19
  id = id.replace(driveOppositeRegext, `${drive}$1`);
20
20
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^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;
22
+ const postfixRE = /[?#].*$/;
24
23
  function cleanUrl(url) {
25
- return url.replace(hashRE, "").replace(queryRE, "");
24
+ return url.replace(postfixRE, "");
26
25
  }
27
26
  const internalRequests = [
28
27
  "@vite/client",
29
28
  "@vite/env"
30
29
  ];
31
- const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
30
+ const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
32
31
  function isInternalRequest(id) {
33
32
  return internalRequestRegexp.test(id);
34
33
  }
@@ -172,4 +171,4 @@ async function findNearestPackageData(basedir) {
172
171
  return {};
173
172
  }
174
173
 
175
- export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
174
+ export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.2",
4
+ "version": "2.0.0-beta.4",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",