mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 07:35:52 +00:00
Switch to using `@noble/hashes`, `@noble/curves`, `@scure/base`, `@scure/bip32`, and `@scure/bip39`. This replaces `crypto` polyfills (such as `crypto-browserify`), `create-hash`, `elliptic`, `hash.js`, `bn.js` (both versions), and their many dependencies. This also means there are 33 less dependencies downloaded when running a fresh `npm install` and will make the project much easier to maintain. This reduces the bundle size by 44% (82kb minified and gzipped) over the current 3.0 branch as well as reducing the amount of configuration required to bundle. Closes #1814, #1817, #2272, and #2306 Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
75 lines
1.8 KiB
JavaScript
75 lines
1.8 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",
|
|
plugins: [
|
|
new webpack.ProvidePlugin({ process: "process/browser" }),
|
|
new webpack.ProvidePlugin({ Buffer: ["buffer", "Buffer"] }),
|
|
],
|
|
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,
|
|
fallback: {
|
|
buffer: require.resolve("buffer"),
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
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;
|
|
},
|
|
];
|
|
},
|
|
};
|