vite-node 0.9.3 → 0.10.1
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 +3 -3
- package/dist/cli.js +3 -3
- package/dist/client-b20a0596.js +214 -0
- package/dist/client-e24a0d42.js +240 -0
- package/dist/client.cjs +10 -233
- package/dist/client.js +7 -212
- package/dist/server-4791181c.js +195 -0
- package/dist/server-d9fc65e0.js +191 -0
- package/dist/server.cjs +8 -190
- package/dist/server.js +5 -191
- package/dist/utils-0290448b.js +39 -0
- package/dist/utils-5d86aff6.js +47 -0
- package/dist/utils.cjs +10 -42
- package/dist/utils.js +3 -39
- package/package.json +5 -6
package/dist/cli.cjs
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
var minimist = require('minimist');
|
|
4
4
|
var kolorist = require('kolorist');
|
|
5
5
|
var vite = require('vite');
|
|
6
|
-
var server = require('./server.
|
|
7
|
-
var client = require('./client.
|
|
6
|
+
var server = require('./server-4791181c.js');
|
|
7
|
+
var client = require('./client-e24a0d42.js');
|
|
8
8
|
require('pathe');
|
|
9
9
|
require('fs');
|
|
10
10
|
require('mlly');
|
|
11
|
-
require('./utils.
|
|
11
|
+
require('./utils-5d86aff6.js');
|
|
12
12
|
require('url');
|
|
13
13
|
require('module');
|
|
14
14
|
require('vm');
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import minimist from 'minimist';
|
|
2
2
|
import { red, dim } from 'kolorist';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
|
-
import { ViteNodeServer } from './server.js';
|
|
5
|
-
import { ViteNodeRunner } from './client.js';
|
|
4
|
+
import { V as ViteNodeServer } from './server-d9fc65e0.js';
|
|
5
|
+
import { V as ViteNodeRunner } from './client-b20a0596.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import 'fs';
|
|
8
8
|
import 'mlly';
|
|
9
|
-
import './utils.js';
|
|
9
|
+
import './utils-0290448b.js';
|
|
10
10
|
import 'url';
|
|
11
11
|
import 'module';
|
|
12
12
|
import 'vm';
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
|
+
import vm from 'vm';
|
|
4
|
+
import { resolve, dirname, isAbsolute, extname } from 'pathe';
|
|
5
|
+
import { isNodeBuiltin } from 'mlly';
|
|
6
|
+
import { n as normalizeModuleId, s as slash, a as normalizeRequestId, t as toFilePath, i as isPrimitive } from './utils-0290448b.js';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_REQUEST_STUBS = {
|
|
9
|
+
"/@vite/client": {
|
|
10
|
+
injectQuery: (id) => id,
|
|
11
|
+
createHotContext() {
|
|
12
|
+
return {
|
|
13
|
+
accept: () => {
|
|
14
|
+
},
|
|
15
|
+
prune: () => {
|
|
16
|
+
},
|
|
17
|
+
dispose: () => {
|
|
18
|
+
},
|
|
19
|
+
decline: () => {
|
|
20
|
+
},
|
|
21
|
+
invalidate: () => {
|
|
22
|
+
},
|
|
23
|
+
on: () => {
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
updateStyle() {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
class ModuleCacheMap extends Map {
|
|
32
|
+
normalizePath(fsPath) {
|
|
33
|
+
return normalizeModuleId(fsPath);
|
|
34
|
+
}
|
|
35
|
+
set(fsPath, mod) {
|
|
36
|
+
fsPath = this.normalizePath(fsPath);
|
|
37
|
+
if (!super.has(fsPath))
|
|
38
|
+
super.set(fsPath, mod);
|
|
39
|
+
else
|
|
40
|
+
Object.assign(super.get(fsPath), mod);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
get(fsPath) {
|
|
44
|
+
fsPath = this.normalizePath(fsPath);
|
|
45
|
+
return super.get(fsPath);
|
|
46
|
+
}
|
|
47
|
+
delete(fsPath) {
|
|
48
|
+
fsPath = this.normalizePath(fsPath);
|
|
49
|
+
return super.delete(fsPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class ViteNodeRunner {
|
|
53
|
+
constructor(options) {
|
|
54
|
+
this.options = options;
|
|
55
|
+
this.root = options.root ?? process.cwd();
|
|
56
|
+
this.moduleCache = options.moduleCache ?? new ModuleCacheMap();
|
|
57
|
+
this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG : false);
|
|
58
|
+
}
|
|
59
|
+
async executeFile(file) {
|
|
60
|
+
return await this.cachedRequest(`/@fs/${slash(resolve(file))}`, []);
|
|
61
|
+
}
|
|
62
|
+
async executeId(id) {
|
|
63
|
+
return await this.cachedRequest(id, []);
|
|
64
|
+
}
|
|
65
|
+
async cachedRequest(rawId, callstack) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const id = normalizeRequestId(rawId, this.options.base);
|
|
68
|
+
const fsPath = toFilePath(id, this.root);
|
|
69
|
+
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
70
|
+
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
71
|
+
const promise = this.directRequest(id, fsPath, callstack);
|
|
72
|
+
this.moduleCache.set(fsPath, { promise });
|
|
73
|
+
return await promise;
|
|
74
|
+
}
|
|
75
|
+
async directRequest(id, fsPath, _callstack) {
|
|
76
|
+
const callstack = [..._callstack, normalizeModuleId(id)];
|
|
77
|
+
const request = async (dep) => {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
const getStack = () => {
|
|
80
|
+
return `stack:
|
|
81
|
+
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
82
|
+
};
|
|
83
|
+
if (this.options.resolveId && this.shouldResolveId(dep)) {
|
|
84
|
+
const resolvedDep = await this.options.resolveId(dep, id);
|
|
85
|
+
dep = ((_a = resolvedDep == null ? void 0 : resolvedDep.id) == null ? void 0 : _a.replace(this.root, "")) || dep;
|
|
86
|
+
}
|
|
87
|
+
let debugTimer;
|
|
88
|
+
if (this.debug)
|
|
89
|
+
debugTimer = setTimeout(() => this.debugLog(() => `module ${dep} takes over 2s to load.
|
|
90
|
+
${getStack()}`), 2e3);
|
|
91
|
+
try {
|
|
92
|
+
if (callstack.includes(normalizeModuleId(dep))) {
|
|
93
|
+
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
94
|
+
const depExports = (_b = this.moduleCache.get(dep)) == null ? void 0 : _b.exports;
|
|
95
|
+
if (depExports)
|
|
96
|
+
return depExports;
|
|
97
|
+
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
98
|
+
}
|
|
99
|
+
const mod = await this.cachedRequest(dep, callstack);
|
|
100
|
+
return mod;
|
|
101
|
+
} finally {
|
|
102
|
+
if (debugTimer)
|
|
103
|
+
clearTimeout(debugTimer);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
107
|
+
if (id in requestStubs)
|
|
108
|
+
return requestStubs[id];
|
|
109
|
+
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
110
|
+
if (externalize) {
|
|
111
|
+
const mod = await this.interopedImport(externalize);
|
|
112
|
+
this.moduleCache.set(fsPath, { exports: mod });
|
|
113
|
+
return mod;
|
|
114
|
+
}
|
|
115
|
+
if (transformed == null)
|
|
116
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
117
|
+
const url = pathToFileURL(fsPath).href;
|
|
118
|
+
const exports = /* @__PURE__ */ Object.create(null);
|
|
119
|
+
exports[Symbol.toStringTag] = "Module";
|
|
120
|
+
this.moduleCache.set(id, { code: transformed, exports });
|
|
121
|
+
const __filename = fileURLToPath(url);
|
|
122
|
+
const moduleProxy = {
|
|
123
|
+
set exports(value) {
|
|
124
|
+
exportAll(exports, value);
|
|
125
|
+
exports.default = value;
|
|
126
|
+
},
|
|
127
|
+
get exports() {
|
|
128
|
+
return exports.default;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const context = this.prepareContext({
|
|
132
|
+
__vite_ssr_import__: request,
|
|
133
|
+
__vite_ssr_dynamic_import__: request,
|
|
134
|
+
__vite_ssr_exports__: exports,
|
|
135
|
+
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
136
|
+
__vite_ssr_import_meta__: { url },
|
|
137
|
+
require: createRequire(url),
|
|
138
|
+
exports,
|
|
139
|
+
module: moduleProxy,
|
|
140
|
+
__filename,
|
|
141
|
+
__dirname: dirname(__filename)
|
|
142
|
+
});
|
|
143
|
+
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(",")})=>{{${transformed}
|
|
144
|
+
}}`, {
|
|
145
|
+
filename: fsPath,
|
|
146
|
+
lineOffset: 0
|
|
147
|
+
});
|
|
148
|
+
await fn(...Object.values(context));
|
|
149
|
+
return exports;
|
|
150
|
+
}
|
|
151
|
+
prepareContext(context) {
|
|
152
|
+
return context;
|
|
153
|
+
}
|
|
154
|
+
shouldResolveId(dep) {
|
|
155
|
+
if (isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS))
|
|
156
|
+
return false;
|
|
157
|
+
return !isAbsolute(dep) || !extname(dep);
|
|
158
|
+
}
|
|
159
|
+
shouldInterop(path, mod) {
|
|
160
|
+
if (this.options.interopDefault === false)
|
|
161
|
+
return false;
|
|
162
|
+
return !path.endsWith(".mjs") && "default" in mod;
|
|
163
|
+
}
|
|
164
|
+
async interopedImport(path) {
|
|
165
|
+
const mod = await import(path);
|
|
166
|
+
if (this.shouldInterop(path, mod)) {
|
|
167
|
+
const tryDefault = this.hasNestedDefault(mod);
|
|
168
|
+
return new Proxy(mod, {
|
|
169
|
+
get: proxyMethod("get", tryDefault),
|
|
170
|
+
set: proxyMethod("set", tryDefault),
|
|
171
|
+
has: proxyMethod("has", tryDefault),
|
|
172
|
+
deleteProperty: proxyMethod("deleteProperty", tryDefault)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return mod;
|
|
176
|
+
}
|
|
177
|
+
hasNestedDefault(target) {
|
|
178
|
+
return "__esModule" in target && target.__esModule && "default" in target.default;
|
|
179
|
+
}
|
|
180
|
+
debugLog(msg) {
|
|
181
|
+
if (this.debug)
|
|
182
|
+
console.log(`[vite-node] ${msg()}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function proxyMethod(name, tryDefault) {
|
|
186
|
+
return function(target, key, ...args) {
|
|
187
|
+
const result = Reflect[name](target, key, ...args);
|
|
188
|
+
if (isPrimitive(target.default))
|
|
189
|
+
return result;
|
|
190
|
+
if (tryDefault && key === "default" || typeof result === "undefined")
|
|
191
|
+
return Reflect[name](target.default, key, ...args);
|
|
192
|
+
return result;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function exportAll(exports, sourceModule) {
|
|
196
|
+
if (exports === sourceModule)
|
|
197
|
+
return;
|
|
198
|
+
for (const key in sourceModule) {
|
|
199
|
+
if (key !== "default") {
|
|
200
|
+
try {
|
|
201
|
+
Object.defineProperty(exports, key, {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
get() {
|
|
205
|
+
return sourceModule[key];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
} catch (_err) {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { DEFAULT_REQUEST_STUBS as D, ModuleCacheMap as M, ViteNodeRunner as V };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var module$1 = require('module');
|
|
4
|
+
var url = require('url');
|
|
5
|
+
var vm = require('vm');
|
|
6
|
+
var pathe = require('pathe');
|
|
7
|
+
var mlly = require('mlly');
|
|
8
|
+
var utils = require('./utils-5d86aff6.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n["default"] = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var vm__default = /*#__PURE__*/_interopDefaultLegacy(vm);
|
|
31
|
+
|
|
32
|
+
const DEFAULT_REQUEST_STUBS = {
|
|
33
|
+
"/@vite/client": {
|
|
34
|
+
injectQuery: (id) => id,
|
|
35
|
+
createHotContext() {
|
|
36
|
+
return {
|
|
37
|
+
accept: () => {
|
|
38
|
+
},
|
|
39
|
+
prune: () => {
|
|
40
|
+
},
|
|
41
|
+
dispose: () => {
|
|
42
|
+
},
|
|
43
|
+
decline: () => {
|
|
44
|
+
},
|
|
45
|
+
invalidate: () => {
|
|
46
|
+
},
|
|
47
|
+
on: () => {
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
updateStyle() {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
class ModuleCacheMap extends Map {
|
|
56
|
+
normalizePath(fsPath) {
|
|
57
|
+
return utils.normalizeModuleId(fsPath);
|
|
58
|
+
}
|
|
59
|
+
set(fsPath, mod) {
|
|
60
|
+
fsPath = this.normalizePath(fsPath);
|
|
61
|
+
if (!super.has(fsPath))
|
|
62
|
+
super.set(fsPath, mod);
|
|
63
|
+
else
|
|
64
|
+
Object.assign(super.get(fsPath), mod);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
get(fsPath) {
|
|
68
|
+
fsPath = this.normalizePath(fsPath);
|
|
69
|
+
return super.get(fsPath);
|
|
70
|
+
}
|
|
71
|
+
delete(fsPath) {
|
|
72
|
+
fsPath = this.normalizePath(fsPath);
|
|
73
|
+
return super.delete(fsPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class ViteNodeRunner {
|
|
77
|
+
constructor(options) {
|
|
78
|
+
this.options = options;
|
|
79
|
+
this.root = options.root ?? process.cwd();
|
|
80
|
+
this.moduleCache = options.moduleCache ?? new ModuleCacheMap();
|
|
81
|
+
this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG : false);
|
|
82
|
+
}
|
|
83
|
+
async executeFile(file) {
|
|
84
|
+
return await this.cachedRequest(`/@fs/${utils.slash(pathe.resolve(file))}`, []);
|
|
85
|
+
}
|
|
86
|
+
async executeId(id) {
|
|
87
|
+
return await this.cachedRequest(id, []);
|
|
88
|
+
}
|
|
89
|
+
async cachedRequest(rawId, callstack) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const id = utils.normalizeRequestId(rawId, this.options.base);
|
|
92
|
+
const fsPath = utils.toFilePath(id, this.root);
|
|
93
|
+
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
94
|
+
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
95
|
+
const promise = this.directRequest(id, fsPath, callstack);
|
|
96
|
+
this.moduleCache.set(fsPath, { promise });
|
|
97
|
+
return await promise;
|
|
98
|
+
}
|
|
99
|
+
async directRequest(id, fsPath, _callstack) {
|
|
100
|
+
const callstack = [..._callstack, utils.normalizeModuleId(id)];
|
|
101
|
+
const request = async (dep) => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
const getStack = () => {
|
|
104
|
+
return `stack:
|
|
105
|
+
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
106
|
+
};
|
|
107
|
+
if (this.options.resolveId && this.shouldResolveId(dep)) {
|
|
108
|
+
const resolvedDep = await this.options.resolveId(dep, id);
|
|
109
|
+
dep = ((_a = resolvedDep == null ? void 0 : resolvedDep.id) == null ? void 0 : _a.replace(this.root, "")) || dep;
|
|
110
|
+
}
|
|
111
|
+
let debugTimer;
|
|
112
|
+
if (this.debug)
|
|
113
|
+
debugTimer = setTimeout(() => this.debugLog(() => `module ${dep} takes over 2s to load.
|
|
114
|
+
${getStack()}`), 2e3);
|
|
115
|
+
try {
|
|
116
|
+
if (callstack.includes(utils.normalizeModuleId(dep))) {
|
|
117
|
+
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
118
|
+
const depExports = (_b = this.moduleCache.get(dep)) == null ? void 0 : _b.exports;
|
|
119
|
+
if (depExports)
|
|
120
|
+
return depExports;
|
|
121
|
+
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
122
|
+
}
|
|
123
|
+
const mod = await this.cachedRequest(dep, callstack);
|
|
124
|
+
return mod;
|
|
125
|
+
} finally {
|
|
126
|
+
if (debugTimer)
|
|
127
|
+
clearTimeout(debugTimer);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
131
|
+
if (id in requestStubs)
|
|
132
|
+
return requestStubs[id];
|
|
133
|
+
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
134
|
+
if (externalize) {
|
|
135
|
+
const mod = await this.interopedImport(externalize);
|
|
136
|
+
this.moduleCache.set(fsPath, { exports: mod });
|
|
137
|
+
return mod;
|
|
138
|
+
}
|
|
139
|
+
if (transformed == null)
|
|
140
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
141
|
+
const url$1 = url.pathToFileURL(fsPath).href;
|
|
142
|
+
const exports = /* @__PURE__ */ Object.create(null);
|
|
143
|
+
exports[Symbol.toStringTag] = "Module";
|
|
144
|
+
this.moduleCache.set(id, { code: transformed, exports });
|
|
145
|
+
const __filename = url.fileURLToPath(url$1);
|
|
146
|
+
const moduleProxy = {
|
|
147
|
+
set exports(value) {
|
|
148
|
+
exportAll(exports, value);
|
|
149
|
+
exports.default = value;
|
|
150
|
+
},
|
|
151
|
+
get exports() {
|
|
152
|
+
return exports.default;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const context = this.prepareContext({
|
|
156
|
+
__vite_ssr_import__: request,
|
|
157
|
+
__vite_ssr_dynamic_import__: request,
|
|
158
|
+
__vite_ssr_exports__: exports,
|
|
159
|
+
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
160
|
+
__vite_ssr_import_meta__: { url: url$1 },
|
|
161
|
+
require: module$1.createRequire(url$1),
|
|
162
|
+
exports,
|
|
163
|
+
module: moduleProxy,
|
|
164
|
+
__filename,
|
|
165
|
+
__dirname: pathe.dirname(__filename)
|
|
166
|
+
});
|
|
167
|
+
const fn = vm__default["default"].runInThisContext(`'use strict';async (${Object.keys(context).join(",")})=>{{${transformed}
|
|
168
|
+
}}`, {
|
|
169
|
+
filename: fsPath,
|
|
170
|
+
lineOffset: 0
|
|
171
|
+
});
|
|
172
|
+
await fn(...Object.values(context));
|
|
173
|
+
return exports;
|
|
174
|
+
}
|
|
175
|
+
prepareContext(context) {
|
|
176
|
+
return context;
|
|
177
|
+
}
|
|
178
|
+
shouldResolveId(dep) {
|
|
179
|
+
if (mlly.isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS))
|
|
180
|
+
return false;
|
|
181
|
+
return !pathe.isAbsolute(dep) || !pathe.extname(dep);
|
|
182
|
+
}
|
|
183
|
+
shouldInterop(path, mod) {
|
|
184
|
+
if (this.options.interopDefault === false)
|
|
185
|
+
return false;
|
|
186
|
+
return !path.endsWith(".mjs") && "default" in mod;
|
|
187
|
+
}
|
|
188
|
+
async interopedImport(path) {
|
|
189
|
+
const mod = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(path);
|
|
190
|
+
if (this.shouldInterop(path, mod)) {
|
|
191
|
+
const tryDefault = this.hasNestedDefault(mod);
|
|
192
|
+
return new Proxy(mod, {
|
|
193
|
+
get: proxyMethod("get", tryDefault),
|
|
194
|
+
set: proxyMethod("set", tryDefault),
|
|
195
|
+
has: proxyMethod("has", tryDefault),
|
|
196
|
+
deleteProperty: proxyMethod("deleteProperty", tryDefault)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return mod;
|
|
200
|
+
}
|
|
201
|
+
hasNestedDefault(target) {
|
|
202
|
+
return "__esModule" in target && target.__esModule && "default" in target.default;
|
|
203
|
+
}
|
|
204
|
+
debugLog(msg) {
|
|
205
|
+
if (this.debug)
|
|
206
|
+
console.log(`[vite-node] ${msg()}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function proxyMethod(name, tryDefault) {
|
|
210
|
+
return function(target, key, ...args) {
|
|
211
|
+
const result = Reflect[name](target, key, ...args);
|
|
212
|
+
if (utils.isPrimitive(target.default))
|
|
213
|
+
return result;
|
|
214
|
+
if (tryDefault && key === "default" || typeof result === "undefined")
|
|
215
|
+
return Reflect[name](target.default, key, ...args);
|
|
216
|
+
return result;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function exportAll(exports, sourceModule) {
|
|
220
|
+
if (exports === sourceModule)
|
|
221
|
+
return;
|
|
222
|
+
for (const key in sourceModule) {
|
|
223
|
+
if (key !== "default") {
|
|
224
|
+
try {
|
|
225
|
+
Object.defineProperty(exports, key, {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
configurable: true,
|
|
228
|
+
get() {
|
|
229
|
+
return sourceModule[key];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
} catch (_err) {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
exports.DEFAULT_REQUEST_STUBS = DEFAULT_REQUEST_STUBS;
|
|
239
|
+
exports.ModuleCacheMap = ModuleCacheMap;
|
|
240
|
+
exports.ViteNodeRunner = ViteNodeRunner;
|