NodeTargetPlugin.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ExternalsPlugin = require("../ExternalsPlugin");
  7. /** @typedef {import("../Compiler")} Compiler */
  8. const builtins = [
  9. "assert",
  10. "assert/strict",
  11. "async_hooks",
  12. "buffer",
  13. "child_process",
  14. "cluster",
  15. "console",
  16. "constants",
  17. "crypto",
  18. "dgram",
  19. "diagnostics_channel",
  20. "dns",
  21. "dns/promises",
  22. "domain",
  23. "events",
  24. "fs",
  25. "fs/promises",
  26. "http",
  27. "http2",
  28. "https",
  29. "inspector",
  30. "inspector/promises",
  31. "module",
  32. "net",
  33. "os",
  34. "path",
  35. "path/posix",
  36. "path/win32",
  37. "perf_hooks",
  38. "process",
  39. "punycode",
  40. "querystring",
  41. "readline",
  42. "readline/promises",
  43. "repl",
  44. "stream",
  45. "stream/consumers",
  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. // cspell:word pnpapi
  65. // Yarn PnP adds pnpapi as "builtin"
  66. "pnpapi"
  67. ];
  68. class NodeTargetPlugin {
  69. /**
  70. * Apply the plugin
  71. * @param {Compiler} compiler the compiler instance
  72. * @returns {void}
  73. */
  74. apply(compiler) {
  75. new ExternalsPlugin("node-commonjs", builtins).apply(compiler);
  76. }
  77. }
  78. module.exports = NodeTargetPlugin;