-
Notifications
You must be signed in to change notification settings - Fork 301
Expand file tree
/
Copy pathbitgojs.config.js
More file actions
85 lines (81 loc) · 2.84 KB
/
bitgojs.config.js
File metadata and controls
85 lines (81 loc) · 2.84 KB
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
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const mode = process.env.NODE_ENV ?? 'production';
// The following configuration is required in order to run BitGoJS in the browser.
// This file is assumed to be loaded by a package within the modules directory
module.exports = {
mode,
resolve: {
alias: {
// this is only required if using bitgo instead of just the sdk-api
'@hashgraph/sdk': path.resolve('../../node_modules/@hashgraph/sdk/src/browser.js'),
// use the default version here since we're webpacking ourselves
'@bitgo/sdk-api': path.resolve('../sdk-api/dist/src/index.js'),
async: path.resolve('../../node_modules/async/index.js'),
// Force ESM versions for browser bundles - required for proper WASM initialization.
// Note: We can't use global `conditionNames: ['browser', 'import', ...]` because
// third-party packages like @solana/spl-token and @bufbuild/protobuf have broken ESM builds.
'@bitgo/wasm-dot': path.resolve('../../node_modules/@bitgo/wasm-dot/dist/esm/js/index.js'),
'@bitgo/wasm-utxo': path.resolve('../../node_modules/@bitgo/wasm-utxo/dist/esm/js/index.js'),
'@bitgo/wasm-solana': path.resolve('../../node_modules/@bitgo/wasm-solana/dist/esm/js/index.js'),
'@bitgo/utxo-ord': path.resolve('../utxo-ord/dist/esm/index.js'),
},
fallback: {
constants: false,
crypto: require.resolve('crypto-browserify'),
dns: false,
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
http2: require.resolve('stream-http'),
net: false,
os: false,
path: false,
stream: require.resolve('stream-browserify'),
tls: false,
url: require.resolve('url/'),
vm: false,
zlib: false,
async: require.resolve('async'),
},
},
externals: ['morgan', 'wasmer_wasi_js_bg.wasm'],
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
new webpack.NormalModuleReplacementPlugin(
/\@emurgo\/cardano-serialization-lib-nodejs/,
'@emurgo/cardano-serialization-lib-browser'
),
new webpack.NormalModuleReplacementPlugin(
/\@silencelaboratories\/dkls-wasm-ll-node/,
'@silencelaboratories/dkls-wasm-ll-web'
),
new webpack.ContextReplacementPlugin(/cardano-serialization-lib-browser/),
],
node: {
global: true,
},
experiments: {
backCompat: false,
asyncWebAssembly: true,
syncWebAssembly: true,
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6,
warnings: true,
mangle: false,
keep_classnames: true,
keep_fnames: true,
},
}),
],
},
};