Files
xahau.js/webpack.config.js
Caleb Kniffen 38b385969b feat: remove Buffer support and bundle polyfill (#2526)
- Removes need for bundlers to polyfill the `Buffer` class. `UInt8Array` are used instead which are native to the browser and node.
- Reduces bundle size 7.1kb gzipped and eliminates 4 runtime dependencies: `base-x`, `base64-js`, `buffer`, and `ieee754`.

BREAKING CHANGE: All methods that previously took a `Buffer` now accept a `UInt8Array`.

---------

Co-authored-by: Jackson Mills <jmills@ripple.com>
2024-02-01 13:53:41 -06:00

68 lines
1.6 KiB
JavaScript

"use strict";
const webpack = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { merge } = require("webpack-merge");
function getDefaultConfiguration() {
return {
cache: true,
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
stats: "errors-only",
devtool: "source-map",
module: {
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
},
],
},
resolve: {
extensions: [".js", ".json"],
// We don't want to webpack any of the local dependencies:
// ripple-address-codec, ripple-binary-codec, ripple-keypairs, which are
// symlinked together via lerna
symlinks: false,
},
};
}
module.exports = {
getDefaultConfiguration,
wrapForEnv: (filename, config) => {
return [
(env, argv) => {
const localConfig = merge(config, {
mode: "development",
output: {
filename: `${filename}-latest.js`,
},
});
return localConfig;
},
(env, argv) => {
const localConfig = merge(config, {
mode: "production",
output: {
filename: `${filename}-latest.min.js`,
},
});
if (process.argv.includes("--analyze")) {
localConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerPort: `auto`,
analyzerMode: "static",
}),
);
}
return localConfig;
},
];
},
};