-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
115 lines (114 loc) · 3.27 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import webpack from "webpack";
import * as path from "node:path";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
import LicensePlugin from "webpack-license-plugin";
/**
* @type {import('webpack').Configuration}
*/
export default {
entry: {
"unmangled-source-do-not-use-this": "./src/main.ts",
},
devtool: false,
optimization: {
minimize: false,
// We do not want to replace "process.env.NODE_ENV" since we virtualize "process" itself
nodeEnv: false,
},
output: {
path: path.resolve("dist"),
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-typescript"],
},
},
],
},
resolve: {
alias: {
"node-gyp": false,
"timers/promises": false,
esbuild: false,
"fs/promises": require.resolve("./src/shims/fs__promises.cjs"),
fs: require.resolve("./src/shims/fs.cjs"),
module: false,
worker_threads: false,
path: require.resolve("./src/shims/path.cjs"),
inspector: false,
process: require.resolve("./src/shims/process.cjs"),
console: require.resolve("./src/shims/console.cjs"),
os: require.resolve("./src/shims/os.cjs"),
child_process: false,
pnpapi: false,
crypto: require.resolve("crypto-browserify"),
util: require.resolve("npm-in-browser-shim-util"),
zlib: require.resolve("browserify-zlib"),
stream: require.resolve("stream-browserify"),
buffer: require.resolve("npm-in-browser-shim-buffer"),
http: require.resolve("./src/shims/http.cjs"),
https: require.resolve("./src/shims/https.cjs"),
assert: require.resolve("npm-in-browser-shim-assert"),
querystring: require.resolve("querystring-es3"),
vm: false,
constants: require.resolve("constants-browserify"),
url: require.resolve("./src/shims/url.cjs"),
"make-fetch-happen": require.resolve("./src/shims/make-fetch-happen.cjs"),
"uglify-js": false,
"@swc/core": false,
readline: false,
tty: false,
tls: false,
dns: false,
net: false,
},
fallback: {
bluebird: false,
},
extensionAlias: {
".js": [".ts", ".tsx", ".js"],
},
},
plugins: [
new LicensePlugin.default({
outputFilename: "third-party-licenses.json",
unacceptableLicenseTest: (licenseIdentifier) => {
// We use allow list to avoid accidentally vendoring sources with an incompatible license
return ![
"(MIT AND BSD-3-Clause)",
"(MIT AND Zlib)",
"Apache-2.0",
"Artistic-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"BlueOak-1.0.0",
"CC-BY-3.0",
"CC0-1.0",
"ISC",
"MIT",
].includes(licenseIdentifier);
},
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: ["process"],
console: ["console"],
setImmediate: [
require.resolve("./src/shims/set-immediate.cjs"),
"setImmediate",
],
clearImmediate: [
require.resolve("./src/shims/set-immediate.cjs"),
"clearImmediate",
],
}),
],
};