Skip to content

Commit

Permalink
refactor: removed most of the polyfills from config-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Feb 24, 2025
1 parent ea644ef commit 73595cf
Show file tree
Hide file tree
Showing 4 changed files with 835 additions and 1,628 deletions.
30 changes: 17 additions & 13 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const webpack = require('webpack');
const LavaMoatPlugin = require('@lavamoat/webpack')
const fs = require('fs');
const path = require('path');
const stdLibBrowser = require('node-stdlib-browser');

module.exports = function override(config, env) {
// Enable source maps for better debugging
Expand All @@ -17,17 +18,20 @@ module.exports = function override(config, env) {
config.resolve = {
...config.resolve,
fallback: {
url: require.resolve('url'),
// Modern polyfills from node-stdlib-browser
assert: stdLibBrowser.assert,
buffer: require.resolve('buffer/'),
crypto: stdLibBrowser.crypto,
path: stdLibBrowser.path,
process: stdLibBrowser.process,
stream: stdLibBrowser.stream,
os: stdLibBrowser.os,
// Disabled polyfills
url: false,
fs: false,
assert: require.resolve('assert'),
crypto: require.resolve('crypto-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
buffer: require.resolve('buffer'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
path: require.resolve("path-browserify"),
http: false,
https: false,
vm: false,
worker_threads: false,
perf_hooks: false,
tls: false,
Expand Down Expand Up @@ -77,9 +81,9 @@ module.exports = function override(config, env) {
const basePlugins = [
...config.plugins.filter(p => !(p instanceof webpack.ProvidePlugin)),
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer-shim', 'default']
}),
Buffer: ['buffer', 'Buffer'],
process: stdLibBrowser.process
})
];

// Only add LavaMoat in production because LavaMoat does not work with the
Expand Down
Loading

0 comments on commit 73595cf

Please sign in to comment.