UNPKG

1.2 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const ExternalsPlugin = require("../ExternalsPlugin");
9
10/** @typedef {import("../Compiler")} Compiler */
11
12const builtins = [
13 "assert",
14 "async_hooks",
15 "buffer",
16 "child_process",
17 "cluster",
18 "console",
19 "constants",
20 "crypto",
21 "dgram",
22 "diagnostics_channel",
23 "dns",
24 "dns/promises",
25 "domain",
26 "events",
27 "fs",
28 "fs/promises",
29 "http",
30 "http2",
31 "https",
32 "inspector",
33 "module",
34 "net",
35 "os",
36 "path",
37 "path/posix",
38 "path/win32",
39 "perf_hooks",
40 "process",
41 "punycode",
42 "querystring",
43 "readline",
44 "repl",
45 "stream",
46 "stream/promises",
47 "stream/web",
48 "string_decoder",
49 "sys",
50 "timers",
51 "timers/promises",
52 "tls",
53 "trace_events",
54 "tty",
55 "url",
56 "util",
57 "util/types",
58 "v8",
59 "vm",
60 "wasi",
61 "worker_threads",
62 "zlib",
63 /^node:/,
64
65 // cspell:word pnpapi
66 // Yarn PnP adds pnpapi as "builtin"
67 "pnpapi"
68];
69
70class NodeTargetPlugin {
71 /**
72 * Apply the plugin
73 * @param {Compiler} compiler the compiler instance
74 * @returns {void}
75 */
76 apply(compiler) {
77 new ExternalsPlugin("node-commonjs", builtins).apply(compiler);
78 }
79}
80
81module.exports = NodeTargetPlugin;