source: frontend/node_modules/webpack/lib/node/NodeTargetPlugin.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
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("../../declarations/WebpackOptions").ExternalsType} ExternalsType */
11/** @typedef {import("../Compiler")} Compiler */
12
13const builtins = [
14 "assert",
15 "assert/strict",
16 "async_hooks",
17 "buffer",
18 "child_process",
19 "cluster",
20 "console",
21 "constants",
22 "crypto",
23 "dgram",
24 "diagnostics_channel",
25 "dns",
26 "dns/promises",
27 "domain",
28 "events",
29 "fs",
30 "fs/promises",
31 "http",
32 "http2",
33 "https",
34 "inspector",
35 "inspector/promises",
36 "module",
37 "net",
38 "os",
39 "path",
40 "path/posix",
41 "path/win32",
42 "perf_hooks",
43 "process",
44 "punycode",
45 "querystring",
46 "readline",
47 "readline/promises",
48 "repl",
49 "stream",
50 "stream/consumers",
51 "stream/promises",
52 "stream/web",
53 "string_decoder",
54 "sys",
55 "timers",
56 "timers/promises",
57 "tls",
58 "trace_events",
59 "tty",
60 "url",
61 "util",
62 "util/types",
63 "v8",
64 "vm",
65 "wasi",
66 "worker_threads",
67 "zlib",
68 /^node:/,
69
70 // cspell:word pnpapi
71 // Yarn PnP adds pnpapi as "builtin"
72 "pnpapi"
73];
74
75class NodeTargetPlugin {
76 /**
77 * Creates an instance of NodeTargetPlugin.
78 * @param {ExternalsType} type default external type
79 */
80 constructor(type = "node-commonjs") {
81 /** @type {ExternalsType} */
82 this.type = type;
83 }
84
85 /**
86 * Applies the plugin by registering its hooks on the compiler.
87 * @param {Compiler} compiler the compiler instance
88 * @returns {void}
89 */
90 apply(compiler) {
91 new ExternalsPlugin((dependency) => {
92 // When `require` node.js built-in modules with module output
93 // we should still emit `createRequire` for compatibility
94 if (dependency.category === "commonjs") {
95 return "node-commonjs";
96 }
97
98 return this.type;
99 }, builtins).apply(compiler);
100 }
101}
102
103module.exports = NodeTargetPlugin;
Note: See TracBrowser for help on using the repository browser.