NodeTargetPlugin.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. "async_hooks",
  11. "buffer",
  12. "child_process",
  13. "cluster",
  14. "console",
  15. "constants",
  16. "crypto",
  17. "dgram",
  18. "diagnostics_channel",
  19. "dns",
  20. "dns/promises",
  21. "domain",
  22. "events",
  23. "fs",
  24. "fs/promises",
  25. "http",
  26. "http2",
  27. "https",
  28. "inspector",
  29. "module",
  30. "net",
  31. "os",
  32. "path",
  33. "path/posix",
  34. "path/win32",
  35. "perf_hooks",
  36. "process",
  37. "punycode",
  38. "querystring",
  39. "readline",
  40. "repl",
  41. "stream",
  42. "stream/promises",
  43. "stream/web",
  44. "string_decoder",
  45. "sys",
  46. "timers",
  47. "timers/promises",
  48. "tls",
  49. "trace_events",
  50. "tty",
  51. "url",
  52. "util",
  53. "util/types",
  54. "v8",
  55. "vm",
  56. "wasi",
  57. "worker_threads",
  58. "zlib",
  59. /^node:/,
  60. // cspell:word pnpapi
  61. // Yarn PnP adds pnpapi as "builtin"
  62. "pnpapi"
  63. ];
  64. class NodeTargetPlugin {
  65. /**
  66. * Apply the plugin
  67. * @param {Compiler} compiler the compiler instance
  68. * @returns {void}
  69. */
  70. apply(compiler) {
  71. new ExternalsPlugin("node-commonjs", builtins).apply(compiler);
  72. }
  73. }
  74. module.exports = NodeTargetPlugin;