2013-02-14 00:00:07 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2018-07-30 23:08:51 +08:00
|
|
|
|
2017-01-11 20:09:19 +08:00
|
|
|
"use strict";
|
2013-02-14 00:00:07 +08:00
|
|
|
|
2017-01-11 20:09:19 +08:00
|
|
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
|
|
|
2018-11-09 05:59:19 +08:00
|
|
|
/** @typedef {import("../Compiler")} Compiler */
|
|
|
|
|
2020-08-28 07:09:12 +08:00
|
|
|
const builtins = [
|
|
|
|
"assert",
|
|
|
|
"async_hooks",
|
|
|
|
"buffer",
|
|
|
|
"child_process",
|
|
|
|
"cluster",
|
|
|
|
"console",
|
|
|
|
"constants",
|
|
|
|
"crypto",
|
|
|
|
"dgram",
|
2021-10-07 21:28:48 +08:00
|
|
|
"diagnostics_channel",
|
2020-08-28 07:09:12 +08:00
|
|
|
"dns",
|
2020-12-15 02:17:39 +08:00
|
|
|
"dns/promises",
|
2020-08-28 07:09:12 +08:00
|
|
|
"domain",
|
|
|
|
"events",
|
|
|
|
"fs",
|
|
|
|
"fs/promises",
|
|
|
|
"http",
|
|
|
|
"http2",
|
|
|
|
"https",
|
|
|
|
"inspector",
|
|
|
|
"module",
|
|
|
|
"net",
|
|
|
|
"os",
|
|
|
|
"path",
|
2021-10-28 02:48:34 +08:00
|
|
|
"path/posix",
|
|
|
|
"path/win32",
|
2020-08-28 07:09:12 +08:00
|
|
|
"perf_hooks",
|
|
|
|
"process",
|
|
|
|
"punycode",
|
|
|
|
"querystring",
|
|
|
|
"readline",
|
|
|
|
"repl",
|
|
|
|
"stream",
|
2020-12-15 02:17:39 +08:00
|
|
|
"stream/promises",
|
2021-09-12 14:52:45 +08:00
|
|
|
"stream/web",
|
2020-08-28 07:09:12 +08:00
|
|
|
"string_decoder",
|
|
|
|
"sys",
|
|
|
|
"timers",
|
2020-12-15 02:17:39 +08:00
|
|
|
"timers/promises",
|
2020-08-28 07:09:12 +08:00
|
|
|
"tls",
|
|
|
|
"trace_events",
|
|
|
|
"tty",
|
|
|
|
"url",
|
|
|
|
"util",
|
|
|
|
"v8",
|
|
|
|
"vm",
|
2021-02-16 12:21:04 +08:00
|
|
|
"wasi",
|
2020-08-28 07:09:12 +08:00
|
|
|
"worker_threads",
|
2021-04-19 16:30:51 +08:00
|
|
|
"zlib",
|
2021-02-17 23:20:33 +08:00
|
|
|
/^node:/,
|
2021-04-19 16:30:51 +08:00
|
|
|
|
|
|
|
// cspell:word pnpapi
|
|
|
|
// Yarn PnP adds pnpapi as "builtin"
|
|
|
|
"pnpapi"
|
2020-08-28 07:09:12 +08:00
|
|
|
];
|
2020-08-26 04:16:50 +08:00
|
|
|
|
2017-01-11 20:09:19 +08:00
|
|
|
class NodeTargetPlugin {
|
2018-11-09 05:59:19 +08:00
|
|
|
/**
|
2020-04-23 16:48:36 +08:00
|
|
|
* Apply the plugin
|
2018-11-09 05:59:19 +08:00
|
|
|
* @param {Compiler} compiler the compiler instance
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-01-11 20:09:19 +08:00
|
|
|
apply(compiler) {
|
2021-06-25 17:22:55 +08:00
|
|
|
new ExternalsPlugin("node-commonjs", builtins).apply(compiler);
|
2017-01-11 20:09:19 +08:00
|
|
|
}
|
|
|
|
}
|
2014-03-06 02:56:53 +08:00
|
|
|
|
2013-02-14 00:00:07 +08:00
|
|
|
module.exports = NodeTargetPlugin;
|