vite-node 0.25.4 → 0.25.5
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 +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +17 -9
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +17 -9
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +14 -5
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +15 -6
- package/dist/source-map.cjs +12 -8
- package/dist/source-map.d.ts +1 -1
- package/dist/source-map.mjs +12 -8
- package/dist/{types-60eb9672.d.ts → types-de49c638.d.ts} +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +6 -0
- package/dist/utils.d.ts +5 -2
- package/dist/utils.mjs +4 -1
- package/package.json +1 -1
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.
|
|
635
|
+
var version = "0.25.5";
|
|
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.d.ts
CHANGED
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.
|
|
633
|
+
var version = "0.25.5";
|
|
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,7 +176,7 @@ class ViteNodeRunner {
|
|
|
176
176
|
}
|
|
177
177
|
async directRequest(id, fsPath, _callstack) {
|
|
178
178
|
const callstack = [..._callstack, fsPath];
|
|
179
|
-
|
|
179
|
+
let mod = this.moduleCache.get(fsPath);
|
|
180
180
|
const request = async (dep) => {
|
|
181
181
|
var _a;
|
|
182
182
|
const depFsPath = utils.toFilePath(utils.normalizeRequestId(dep, this.options.base), this.root);
|
|
@@ -212,11 +212,22 @@ ${getStack()}`), 2e3);
|
|
|
212
212
|
}
|
|
213
213
|
return dep;
|
|
214
214
|
};
|
|
215
|
-
id = await resolveId(id, 2);
|
|
216
215
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
217
216
|
if (id in requestStubs)
|
|
218
217
|
return requestStubs[id];
|
|
219
|
-
let { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
218
|
+
let { code: transformed, externalize, file } = await this.options.fetchModule(id);
|
|
219
|
+
if (file && !fsPath.includes("?") && fsPath !== file) {
|
|
220
|
+
if (this.moduleCache.has(file)) {
|
|
221
|
+
mod = this.moduleCache.get(file);
|
|
222
|
+
this.moduleCache.set(fsPath, mod);
|
|
223
|
+
if (mod.promise)
|
|
224
|
+
return mod.promise;
|
|
225
|
+
if (mod.exports)
|
|
226
|
+
return mod.exports;
|
|
227
|
+
} else {
|
|
228
|
+
this.moduleCache.set(file, mod);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
220
231
|
if (externalize) {
|
|
221
232
|
debugNative(externalize);
|
|
222
233
|
const exports2 = await this.interopedImport(externalize);
|
|
@@ -225,7 +236,7 @@ ${getStack()}`), 2e3);
|
|
|
225
236
|
}
|
|
226
237
|
if (transformed == null)
|
|
227
238
|
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
228
|
-
const url$1 = url.pathToFileURL(fsPath).href;
|
|
239
|
+
const url$1 = url.pathToFileURL(file || fsPath).href;
|
|
229
240
|
const meta = { url: url$1 };
|
|
230
241
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
231
242
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
@@ -234,9 +245,6 @@ ${getStack()}`), 2e3);
|
|
|
234
245
|
configurable: false
|
|
235
246
|
});
|
|
236
247
|
const cjsExports = new Proxy(exports, {
|
|
237
|
-
get(_, p, receiver) {
|
|
238
|
-
return Reflect.get(exports, p, receiver);
|
|
239
|
-
},
|
|
240
248
|
set(_, p, value) {
|
|
241
249
|
if (!Reflect.has(exports, "default"))
|
|
242
250
|
exports.default = {};
|
|
@@ -250,7 +258,7 @@ ${getStack()}`), 2e3);
|
|
|
250
258
|
return true;
|
|
251
259
|
}
|
|
252
260
|
});
|
|
253
|
-
Object.assign(mod, { code: transformed, exports
|
|
261
|
+
Object.assign(mod, { code: transformed, exports });
|
|
254
262
|
const __filename = url.fileURLToPath(url$1);
|
|
255
263
|
const moduleProxy = {
|
|
256
264
|
set exports(value) {
|
|
@@ -292,7 +300,7 @@ ${getStack()}`), 2e3);
|
|
|
292
300
|
const code = `${codeDefinition}${transformed}
|
|
293
301
|
}}`;
|
|
294
302
|
const fn = vm__default["default"].runInThisContext(code, {
|
|
295
|
-
filename:
|
|
303
|
+
filename: __filename,
|
|
296
304
|
lineOffset: 0,
|
|
297
305
|
columnOffset: -codeDefinition.length
|
|
298
306
|
});
|
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-de49c638.js';
|
package/dist/client.mjs
CHANGED
|
@@ -149,7 +149,7 @@ class ViteNodeRunner {
|
|
|
149
149
|
}
|
|
150
150
|
async directRequest(id, fsPath, _callstack) {
|
|
151
151
|
const callstack = [..._callstack, fsPath];
|
|
152
|
-
|
|
152
|
+
let mod = this.moduleCache.get(fsPath);
|
|
153
153
|
const request = async (dep) => {
|
|
154
154
|
var _a;
|
|
155
155
|
const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
|
|
@@ -185,11 +185,22 @@ ${getStack()}`), 2e3);
|
|
|
185
185
|
}
|
|
186
186
|
return dep;
|
|
187
187
|
};
|
|
188
|
-
id = await resolveId(id, 2);
|
|
189
188
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
190
189
|
if (id in requestStubs)
|
|
191
190
|
return requestStubs[id];
|
|
192
|
-
let { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
191
|
+
let { code: transformed, externalize, file } = await this.options.fetchModule(id);
|
|
192
|
+
if (file && !fsPath.includes("?") && fsPath !== file) {
|
|
193
|
+
if (this.moduleCache.has(file)) {
|
|
194
|
+
mod = this.moduleCache.get(file);
|
|
195
|
+
this.moduleCache.set(fsPath, mod);
|
|
196
|
+
if (mod.promise)
|
|
197
|
+
return mod.promise;
|
|
198
|
+
if (mod.exports)
|
|
199
|
+
return mod.exports;
|
|
200
|
+
} else {
|
|
201
|
+
this.moduleCache.set(file, mod);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
193
204
|
if (externalize) {
|
|
194
205
|
debugNative(externalize);
|
|
195
206
|
const exports2 = await this.interopedImport(externalize);
|
|
@@ -198,7 +209,7 @@ ${getStack()}`), 2e3);
|
|
|
198
209
|
}
|
|
199
210
|
if (transformed == null)
|
|
200
211
|
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
201
|
-
const url = pathToFileURL(fsPath).href;
|
|
212
|
+
const url = pathToFileURL(file || fsPath).href;
|
|
202
213
|
const meta = { url };
|
|
203
214
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
204
215
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
@@ -207,9 +218,6 @@ ${getStack()}`), 2e3);
|
|
|
207
218
|
configurable: false
|
|
208
219
|
});
|
|
209
220
|
const cjsExports = new Proxy(exports, {
|
|
210
|
-
get(_, p, receiver) {
|
|
211
|
-
return Reflect.get(exports, p, receiver);
|
|
212
|
-
},
|
|
213
221
|
set(_, p, value) {
|
|
214
222
|
if (!Reflect.has(exports, "default"))
|
|
215
223
|
exports.default = {};
|
|
@@ -223,7 +231,7 @@ ${getStack()}`), 2e3);
|
|
|
223
231
|
return true;
|
|
224
232
|
}
|
|
225
233
|
});
|
|
226
|
-
Object.assign(mod, { code: transformed, exports
|
|
234
|
+
Object.assign(mod, { code: transformed, exports });
|
|
227
235
|
const __filename = fileURLToPath(url);
|
|
228
236
|
const moduleProxy = {
|
|
229
237
|
set exports(value) {
|
|
@@ -265,7 +273,7 @@ ${getStack()}`), 2e3);
|
|
|
265
273
|
const code = `${codeDefinition}${transformed}
|
|
266
274
|
}}`;
|
|
267
275
|
const fn = vm.runInThisContext(code, {
|
|
268
|
-
filename:
|
|
276
|
+
filename: __filename,
|
|
269
277
|
lineOffset: 0,
|
|
270
278
|
columnOffset: -codeDefinition.length
|
|
271
279
|
});
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from '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-de49c638.js';
|
|
4
4
|
|
|
5
5
|
declare type EventType = string | symbol;
|
|
6
6
|
declare type Handler<T = unknown> = (event: T) => void;
|
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-de49c638.js';
|
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,24 +261,33 @@ 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 =
|
|
264
|
+
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
265
265
|
const cache = this.fetchCache.get(filePath);
|
|
266
|
-
if (
|
|
266
|
+
if (cache == null ? void 0 : cache.result.id)
|
|
267
|
+
id = cache.result.id;
|
|
268
|
+
if (timestamp !== null && cache && cache.timestamp >= timestamp)
|
|
267
269
|
return cache.result;
|
|
270
|
+
const time = Date.now();
|
|
268
271
|
const externalize = await this.shouldExternalize(filePath);
|
|
269
272
|
let duration;
|
|
270
273
|
if (externalize) {
|
|
271
274
|
result = { externalize };
|
|
272
275
|
(_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
|
|
273
276
|
} else {
|
|
277
|
+
let file = module == null ? void 0 : module.file;
|
|
278
|
+
if (!file) {
|
|
279
|
+
const [, resolvedId] = await this.server.moduleGraph.resolveUrl(id, true);
|
|
280
|
+
id = resolvedId;
|
|
281
|
+
file = utils.cleanUrl(resolvedId);
|
|
282
|
+
}
|
|
274
283
|
const start = perf_hooks.performance.now();
|
|
275
284
|
const r = await this._transformRequest(id);
|
|
276
285
|
duration = perf_hooks.performance.now() - start;
|
|
277
|
-
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
286
|
+
result = { file, id, code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
278
287
|
}
|
|
279
288
|
this.fetchCache.set(filePath, {
|
|
280
289
|
duration,
|
|
281
|
-
timestamp,
|
|
290
|
+
timestamp: time,
|
|
282
291
|
result
|
|
283
292
|
});
|
|
284
293
|
return result;
|
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-de49c638.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
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, cleanUrl } 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,24 +253,33 @@ 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 =
|
|
256
|
+
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
257
257
|
const cache = this.fetchCache.get(filePath);
|
|
258
|
-
if (
|
|
258
|
+
if (cache == null ? void 0 : cache.result.id)
|
|
259
|
+
id = cache.result.id;
|
|
260
|
+
if (timestamp !== null && cache && cache.timestamp >= timestamp)
|
|
259
261
|
return cache.result;
|
|
262
|
+
const time = Date.now();
|
|
260
263
|
const externalize = await this.shouldExternalize(filePath);
|
|
261
264
|
let duration;
|
|
262
265
|
if (externalize) {
|
|
263
266
|
result = { externalize };
|
|
264
267
|
(_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
|
|
265
268
|
} else {
|
|
269
|
+
let file = module == null ? void 0 : module.file;
|
|
270
|
+
if (!file) {
|
|
271
|
+
const [, resolvedId] = await this.server.moduleGraph.resolveUrl(id, true);
|
|
272
|
+
id = resolvedId;
|
|
273
|
+
file = cleanUrl(resolvedId);
|
|
274
|
+
}
|
|
266
275
|
const start = performance.now();
|
|
267
276
|
const r = await this._transformRequest(id);
|
|
268
277
|
duration = performance.now() - start;
|
|
269
|
-
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
278
|
+
result = { file, id, code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
270
279
|
}
|
|
271
280
|
this.fetchCache.set(filePath, {
|
|
272
281
|
duration,
|
|
273
|
-
timestamp,
|
|
282
|
+
timestamp: time,
|
|
274
283
|
result
|
|
275
284
|
});
|
|
276
285
|
return result;
|
package/dist/source-map.cjs
CHANGED
|
@@ -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
|
|
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
|
|
14
|
-
|
|
13
|
+
const map = result.map;
|
|
14
|
+
let code = result.code;
|
|
15
|
+
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
15
16
|
return result;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
+
${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
24
|
+
//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
|
|
21
25
|
`;
|
|
22
26
|
return result;
|
|
23
27
|
}
|
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-de49c638.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => RawSourceMap | null | undefined;
|
package/dist/source-map.mjs
CHANGED
|
@@ -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
|
|
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
|
|
10
|
-
|
|
9
|
+
const map = result.map;
|
|
10
|
+
let code = result.code;
|
|
11
|
+
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
11
12
|
return result;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
+
${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
20
|
+
//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
|
|
17
21
|
`;
|
|
18
22
|
return result;
|
|
19
23
|
}
|
|
@@ -201,6 +201,8 @@ interface FetchResult {
|
|
|
201
201
|
code?: string;
|
|
202
202
|
externalize?: string;
|
|
203
203
|
map?: RawSourceMap;
|
|
204
|
+
id?: string;
|
|
205
|
+
file?: string;
|
|
204
206
|
}
|
|
205
207
|
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
206
208
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
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-de49c638.js';
|
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
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './types-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './types-de49c638.js';
|
|
2
2
|
|
|
3
3
|
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 };
|