-
Notifications
You must be signed in to change notification settings - Fork 22
/
nodeless.ts
103 lines (94 loc) · 2.6 KB
/
nodeless.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { NodeBuiltinModules, mapArrToVal } from "../utils";
import type { Preset } from "../types";
const nodeless: Preset & { alias: Map<string, string> } = {
alias: {
// Generic mock for built-ins
...mapArrToVal("unenv/runtime/mock/proxy-cjs", NodeBuiltinModules),
// Built-ins implemented by unenv
"buffer/index.js": "buffer",
...Object.fromEntries(
[
"assert",
"assert/strict",
"async_hooks",
"buffer",
"console",
"child_process",
"constants",
"cluster",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"https",
"http2",
"inspector",
"module",
"net",
"os",
"path",
"punycode",
"perf_hooks",
"process",
"querystring",
"readline",
"readline/promises",
"stream",
"stream/promises",
"stream/consumers",
"stream/web",
"string_decoder",
"trace_events",
"timers",
"timers/promises",
"tls",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
].map((m) => [m, `unenv/runtime/node/${m}/index`]),
),
"path/posix": "unenv/runtime/node/path/index",
"path/win32": "unenv/runtime/node/path/index",
"inspector/promises": "unenv/runtime/node/inspector/index",
// The sys module is deprecated and has been renamed util
// https://github.com/nodejs/node/blob/main/lib/sys.js#L27
sys: "unenv/runtime/node/util/index",
// npm
fsevents: "unenv/runtime/npm/fsevents",
"node-fetch": "unenv/runtime/npm/node-fetch",
"node-fetch-native": "unenv/runtime/npm/node-fetch",
"node-fetch-native/polyfill": "unenv/runtime/mock/empty",
"cross-fetch": "unenv/runtime/npm/cross-fetch",
"cross-fetch/polyfill": "unenv/runtime/mock/empty",
"isomorphic-fetch": "unenv/runtime/mock/empty",
inherits: "unenv/runtime/npm/inherits",
},
inject: {
global: "unenv/runtime/node/_global",
process: "unenv/runtime/node/process",
Buffer: ["buffer", "Buffer"],
performance: "unenv/runtime/polyfill/performance",
},
polyfill: [
"unenv/runtime/polyfill/node-global",
"unenv/runtime/polyfill/process",
"unenv/runtime/polyfill/performance",
],
};
// Add node: aliases
for (const m of NodeBuiltinModules) {
nodeless.alias[`node:${m}`] = nodeless.alias[m];
}
export default nodeless;