forked from unjs/unenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodeless.ts
62 lines (55 loc) · 1.66 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
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(
[
"buffer",
"crypto",
"events",
"fs",
"fs/promises",
"http",
"net",
"path",
"process",
"stream",
"stream/promises",
"stream/consumers",
"stream/web",
"url",
"util",
"util/types",
].map((m) => [m, `unenv/runtime/node/${m}/index`])
),
// npm
etag: "unenv/runtime/mock/noop",
"mime-db": "unenv/runtime/npm/mime-db",
mime: "unenv/runtime/npm/mime",
"mime/lite": "unenv/runtime/npm/mime",
_mime: "mime/lite.js",
fsevents: "unenv/runtime/npm/fsevents",
"consola/core": "consola/core",
"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: {
process: "unenv/runtime/polyfill/process",
Buffer: ["buffer", "Buffer"],
},
polyfill: ["unenv/runtime/polyfill/process"],
};
// Add node: aliases
for (const m of NodeBuiltinModules) {
nodeless.alias[`node:${m}`] = nodeless.alias[m];
}
export default nodeless;