vite-node 0.26.0 → 0.26.2
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/chunk-hmr.cjs +2 -2
- package/dist/chunk-hmr.mjs +1 -1
- package/dist/cli.cjs +3 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +8 -7
- package/dist/client.cjs +42 -36
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +44 -38
- package/dist/hmr.cjs +1 -1
- package/dist/hmr.d.ts +2 -2
- package/dist/hmr.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +3 -3
- package/dist/source-map.d.ts +1 -1
- package/dist/{types-aaf02e1c.d.ts → types-6a15e0b9.d.ts} +13 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +10 -5
- package/dist/utils.d.ts +1 -1
- package/dist/utils.mjs +10 -5
- package/package.json +1 -1
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var node_events = require('node:events');
|
|
4
4
|
var picocolors = require('./chunk-picocolors.cjs');
|
|
5
5
|
var createDebug = require('debug');
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
10
10
|
|
|
11
11
|
function createHmrEmitter() {
|
|
12
|
-
const emitter = new
|
|
12
|
+
const emitter = new node_events.EventEmitter();
|
|
13
13
|
return emitter;
|
|
14
14
|
}
|
|
15
15
|
function viteNodeHmrPlugin() {
|
package/dist/chunk-hmr.mjs
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -14,11 +14,12 @@ require('pathe');
|
|
|
14
14
|
require('debug');
|
|
15
15
|
require('fs');
|
|
16
16
|
require('mlly');
|
|
17
|
-
require('url');
|
|
17
|
+
require('node:url');
|
|
18
18
|
require('source-map-support');
|
|
19
19
|
require('module');
|
|
20
20
|
require('path');
|
|
21
21
|
require('vm');
|
|
22
|
+
require('node:events');
|
|
22
23
|
|
|
23
24
|
function toArr(any) {
|
|
24
25
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -633,7 +634,7 @@ class CAC extends events.EventEmitter {
|
|
|
633
634
|
|
|
634
635
|
const cac = (name = "") => new CAC(name);
|
|
635
636
|
|
|
636
|
-
var version = "0.26.
|
|
637
|
+
var version = "0.26.2";
|
|
637
638
|
|
|
638
639
|
const cli = cac("vite-node");
|
|
639
640
|
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.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -7,16 +7,17 @@ import { toArray } from './utils.mjs';
|
|
|
7
7
|
import { v as viteNodeHmrPlugin, c as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
8
8
|
import { installSourcemapsSupport } from './source-map.mjs';
|
|
9
9
|
import 'tty';
|
|
10
|
-
import 'perf_hooks';
|
|
10
|
+
import 'node:perf_hooks';
|
|
11
11
|
import 'pathe';
|
|
12
12
|
import 'debug';
|
|
13
|
-
import 'fs';
|
|
13
|
+
import 'node:fs';
|
|
14
14
|
import 'mlly';
|
|
15
|
-
import 'url';
|
|
15
|
+
import 'node:url';
|
|
16
16
|
import 'source-map-support';
|
|
17
|
-
import 'module';
|
|
18
|
-
import 'path';
|
|
19
|
-
import 'vm';
|
|
17
|
+
import 'node:module';
|
|
18
|
+
import 'node:path';
|
|
19
|
+
import 'node:vm';
|
|
20
|
+
import 'node:events';
|
|
20
21
|
|
|
21
22
|
function toArr(any) {
|
|
22
23
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -631,7 +632,7 @@ class CAC extends EventEmitter {
|
|
|
631
632
|
|
|
632
633
|
const cac = (name = "") => new CAC(name);
|
|
633
634
|
|
|
634
|
-
var version = "0.26.
|
|
635
|
+
var version = "0.26.2";
|
|
635
636
|
|
|
636
637
|
const cli = cac("vite-node");
|
|
637
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/client.cjs
CHANGED
|
@@ -4,8 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var module$1 = require('module');
|
|
6
6
|
var path = require('path');
|
|
7
|
-
var
|
|
7
|
+
var node_url = require('node:url');
|
|
8
8
|
var vm = require('vm');
|
|
9
|
+
var mlly = require('mlly');
|
|
9
10
|
var pathe = require('pathe');
|
|
10
11
|
var createDebug = require('debug');
|
|
11
12
|
var utils = require('./utils.cjs');
|
|
@@ -38,40 +39,42 @@ var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
|
38
39
|
|
|
39
40
|
const debugExecute = createDebug__default["default"]("vite-node:client:execute");
|
|
40
41
|
const debugNative = createDebug__default["default"]("vite-node:client:native");
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
head == null ? void 0 : head.appendChild(style);
|
|
72
|
-
}
|
|
42
|
+
const clientStub = {
|
|
43
|
+
injectQuery: (id) => id,
|
|
44
|
+
createHotContext() {
|
|
45
|
+
return {
|
|
46
|
+
accept: () => {
|
|
47
|
+
},
|
|
48
|
+
prune: () => {
|
|
49
|
+
},
|
|
50
|
+
dispose: () => {
|
|
51
|
+
},
|
|
52
|
+
decline: () => {
|
|
53
|
+
},
|
|
54
|
+
invalidate: () => {
|
|
55
|
+
},
|
|
56
|
+
on: () => {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
updateStyle(id, css) {
|
|
61
|
+
if (typeof document === "undefined")
|
|
62
|
+
return;
|
|
63
|
+
const element = document.getElementById(id);
|
|
64
|
+
if (element)
|
|
65
|
+
element.remove();
|
|
66
|
+
const head = document.querySelector("head");
|
|
67
|
+
const style = document.createElement("style");
|
|
68
|
+
style.setAttribute("type", "text/css");
|
|
69
|
+
style.id = id;
|
|
70
|
+
style.innerHTML = css;
|
|
71
|
+
head == null ? void 0 : head.appendChild(style);
|
|
73
72
|
}
|
|
74
73
|
};
|
|
74
|
+
const DEFAULT_REQUEST_STUBS = {
|
|
75
|
+
"/@vite/client": clientStub,
|
|
76
|
+
"@vite/client": clientStub
|
|
77
|
+
};
|
|
75
78
|
class ModuleCacheMap extends Map {
|
|
76
79
|
normalizePath(fsPath) {
|
|
77
80
|
return utils.normalizeModuleId(fsPath);
|
|
@@ -175,8 +178,11 @@ class ViteNodeRunner {
|
|
|
175
178
|
mod.evaluated = true;
|
|
176
179
|
}
|
|
177
180
|
}
|
|
181
|
+
shouldResolveId(id, _importee) {
|
|
182
|
+
return !utils.isInternalRequest(id) && !mlly.isNodeBuiltin(id);
|
|
183
|
+
}
|
|
178
184
|
async resolveUrl(id, importee) {
|
|
179
|
-
if (
|
|
185
|
+
if (!this.shouldResolveId(id))
|
|
180
186
|
return [id, id];
|
|
181
187
|
if (importee && id.startsWith(utils.VALID_ID_PREFIX))
|
|
182
188
|
importee = void 0;
|
|
@@ -232,7 +238,7 @@ ${getStack()}`), 2e3);
|
|
|
232
238
|
if (transformed == null)
|
|
233
239
|
throw new Error(`[vite-node] Failed to load "${id}" imported from ${callstack[callstack.length - 2]}`);
|
|
234
240
|
const modulePath = utils.cleanUrl(moduleId);
|
|
235
|
-
const href =
|
|
241
|
+
const href = node_url.pathToFileURL(modulePath).href;
|
|
236
242
|
const meta = { url: href };
|
|
237
243
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
238
244
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
@@ -260,7 +266,7 @@ ${getStack()}`), 2e3);
|
|
|
260
266
|
}
|
|
261
267
|
});
|
|
262
268
|
Object.assign(mod, { code: transformed, exports });
|
|
263
|
-
const __filename =
|
|
269
|
+
const __filename = node_url.fileURLToPath(href);
|
|
264
270
|
const moduleProxy = {
|
|
265
271
|
set exports(value) {
|
|
266
272
|
exportAll(cjsExports, value);
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
1
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-6a15e0b9.js';
|
package/dist/client.mjs
CHANGED
|
@@ -1,50 +1,53 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
import { dirname } from 'path';
|
|
3
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
4
|
-
import vm from 'vm';
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
4
|
+
import vm from 'node:vm';
|
|
5
|
+
import { isNodeBuiltin } from 'mlly';
|
|
5
6
|
import { resolve } from 'pathe';
|
|
6
7
|
import createDebug from 'debug';
|
|
7
8
|
import { normalizeModuleId, slash, isInternalRequest, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
8
9
|
import { extractSourceMap } from './source-map.mjs';
|
|
9
|
-
import 'fs';
|
|
10
|
+
import 'node:fs';
|
|
10
11
|
import 'source-map-support';
|
|
11
12
|
|
|
12
13
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
13
14
|
const debugNative = createDebug("vite-node:client:native");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
head == null ? void 0 : head.appendChild(style);
|
|
45
|
-
}
|
|
15
|
+
const clientStub = {
|
|
16
|
+
injectQuery: (id) => id,
|
|
17
|
+
createHotContext() {
|
|
18
|
+
return {
|
|
19
|
+
accept: () => {
|
|
20
|
+
},
|
|
21
|
+
prune: () => {
|
|
22
|
+
},
|
|
23
|
+
dispose: () => {
|
|
24
|
+
},
|
|
25
|
+
decline: () => {
|
|
26
|
+
},
|
|
27
|
+
invalidate: () => {
|
|
28
|
+
},
|
|
29
|
+
on: () => {
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
updateStyle(id, css) {
|
|
34
|
+
if (typeof document === "undefined")
|
|
35
|
+
return;
|
|
36
|
+
const element = document.getElementById(id);
|
|
37
|
+
if (element)
|
|
38
|
+
element.remove();
|
|
39
|
+
const head = document.querySelector("head");
|
|
40
|
+
const style = document.createElement("style");
|
|
41
|
+
style.setAttribute("type", "text/css");
|
|
42
|
+
style.id = id;
|
|
43
|
+
style.innerHTML = css;
|
|
44
|
+
head == null ? void 0 : head.appendChild(style);
|
|
46
45
|
}
|
|
47
46
|
};
|
|
47
|
+
const DEFAULT_REQUEST_STUBS = {
|
|
48
|
+
"/@vite/client": clientStub,
|
|
49
|
+
"@vite/client": clientStub
|
|
50
|
+
};
|
|
48
51
|
class ModuleCacheMap extends Map {
|
|
49
52
|
normalizePath(fsPath) {
|
|
50
53
|
return normalizeModuleId(fsPath);
|
|
@@ -148,8 +151,11 @@ class ViteNodeRunner {
|
|
|
148
151
|
mod.evaluated = true;
|
|
149
152
|
}
|
|
150
153
|
}
|
|
154
|
+
shouldResolveId(id, _importee) {
|
|
155
|
+
return !isInternalRequest(id) && !isNodeBuiltin(id);
|
|
156
|
+
}
|
|
151
157
|
async resolveUrl(id, importee) {
|
|
152
|
-
if (
|
|
158
|
+
if (!this.shouldResolveId(id))
|
|
153
159
|
return [id, id];
|
|
154
160
|
if (importee && id.startsWith(VALID_ID_PREFIX))
|
|
155
161
|
importee = void 0;
|
package/dist/hmr.cjs
CHANGED
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-
|
|
3
|
+
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-6a15e0b9.js';
|
|
4
4
|
|
|
5
5
|
type EventType = string | symbol;
|
|
6
6
|
type Handler<T = unknown> = (event: T) => void;
|
package/dist/hmr.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { a as createHmrEmitter, c as createHotContext, g as getCache, h as handleMessage, r as reload, s as sendMessageBuffer, v as viteNodeHmrPlugin } from './chunk-hmr.mjs';
|
|
2
|
-
import 'events';
|
|
2
|
+
import 'node:events';
|
|
3
3
|
import './chunk-picocolors.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'debug';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-6a15e0b9.js';
|
package/dist/server.cjs
CHANGED
|
@@ -10,7 +10,7 @@ var mlly = require('mlly');
|
|
|
10
10
|
var utils = require('./utils.cjs');
|
|
11
11
|
var picocolors = require('./chunk-picocolors.cjs');
|
|
12
12
|
var sourceMap = require('./source-map.cjs');
|
|
13
|
-
require('url');
|
|
13
|
+
require('node:url');
|
|
14
14
|
require('tty');
|
|
15
15
|
require('source-map-support');
|
|
16
16
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-
|
|
2
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-6a15e0b9.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
package/dist/server.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { performance } from 'perf_hooks';
|
|
1
|
+
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { resolve, join } from 'pathe';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
|
-
import { existsSync, promises } from 'fs';
|
|
4
|
+
import { existsSync, promises } from 'node:fs';
|
|
5
5
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
6
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
|
-
import 'url';
|
|
9
|
+
import 'node:url';
|
|
10
10
|
import 'tty';
|
|
11
11
|
import 'source-map-support';
|
|
12
12
|
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { R as RawSourceMap } from './types-
|
|
2
|
+
import { R as RawSourceMap } from './types-6a15e0b9.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => RawSourceMap | null | undefined;
|
|
@@ -121,6 +121,18 @@ declare const DEFAULT_REQUEST_STUBS: {
|
|
|
121
121
|
};
|
|
122
122
|
updateStyle(id: string, css: string): void;
|
|
123
123
|
};
|
|
124
|
+
'@vite/client': {
|
|
125
|
+
injectQuery: (id: string) => string;
|
|
126
|
+
createHotContext(): {
|
|
127
|
+
accept: () => void;
|
|
128
|
+
prune: () => void;
|
|
129
|
+
dispose: () => void;
|
|
130
|
+
decline: () => void;
|
|
131
|
+
invalidate: () => void;
|
|
132
|
+
on: () => void;
|
|
133
|
+
};
|
|
134
|
+
updateStyle(id: string, css: string): void;
|
|
135
|
+
};
|
|
124
136
|
};
|
|
125
137
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
126
138
|
normalizePath(fsPath: string): string;
|
|
@@ -159,6 +171,7 @@ declare class ViteNodeRunner {
|
|
|
159
171
|
getSourceMap(id: string): RawSourceMap | null;
|
|
160
172
|
/** @internal */
|
|
161
173
|
cachedRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
|
174
|
+
shouldResolveId(id: string, _importee?: string): boolean;
|
|
162
175
|
resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
|
|
163
176
|
/** @internal */
|
|
164
177
|
dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-6a15e0b9.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var node_url = require('node:url');
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var pathe = require('pathe');
|
|
8
8
|
|
|
@@ -17,16 +17,21 @@ const VALID_ID_PREFIX = "/@id/";
|
|
|
17
17
|
function normalizeRequestId(id, base) {
|
|
18
18
|
if (base && id.startsWith(base))
|
|
19
19
|
id = `/${id.slice(base.length)}`;
|
|
20
|
-
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^
|
|
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
22
|
const queryRE = /\?.*$/s;
|
|
23
23
|
const hashRE = /#.*$/s;
|
|
24
24
|
const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
|
|
25
|
+
const internalRequests = [
|
|
26
|
+
"@vite/client",
|
|
27
|
+
"@vite/env"
|
|
28
|
+
];
|
|
29
|
+
const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
|
|
25
30
|
const isInternalRequest = (id) => {
|
|
26
|
-
return
|
|
31
|
+
return internalRequestRegexp.test(id);
|
|
27
32
|
};
|
|
28
33
|
function normalizeModuleId(id) {
|
|
29
|
-
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
|
|
34
|
+
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
30
35
|
}
|
|
31
36
|
function isPrimitive(v) {
|
|
32
37
|
return v !== Object(v);
|
|
@@ -44,7 +49,7 @@ function toFilePath(id, root) {
|
|
|
44
49
|
})();
|
|
45
50
|
if (absolute.startsWith("//"))
|
|
46
51
|
absolute = absolute.slice(1);
|
|
47
|
-
return isWindows && absolute.startsWith("/") ? slash(
|
|
52
|
+
return isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute;
|
|
48
53
|
}
|
|
49
54
|
function toArray(array) {
|
|
50
55
|
if (array === null || array === void 0)
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'pathe';
|
|
4
4
|
|
|
5
5
|
const isWindows = process.platform === "win32";
|
|
@@ -13,16 +13,21 @@ const VALID_ID_PREFIX = "/@id/";
|
|
|
13
13
|
function normalizeRequestId(id, base) {
|
|
14
14
|
if (base && id.startsWith(base))
|
|
15
15
|
id = `/${id.slice(base.length)}`;
|
|
16
|
-
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^
|
|
16
|
+
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(/\?+$/, "");
|
|
17
17
|
}
|
|
18
18
|
const queryRE = /\?.*$/s;
|
|
19
19
|
const hashRE = /#.*$/s;
|
|
20
20
|
const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
|
|
21
|
+
const internalRequests = [
|
|
22
|
+
"@vite/client",
|
|
23
|
+
"@vite/env"
|
|
24
|
+
];
|
|
25
|
+
const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
|
|
21
26
|
const isInternalRequest = (id) => {
|
|
22
|
-
return
|
|
27
|
+
return internalRequestRegexp.test(id);
|
|
23
28
|
};
|
|
24
29
|
function normalizeModuleId(id) {
|
|
25
|
-
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
|
|
30
|
+
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
26
31
|
}
|
|
27
32
|
function isPrimitive(v) {
|
|
28
33
|
return v !== Object(v);
|