diff --git a/package-lock.json b/package-lock.json index c75d7ee1d1..e54ca35dbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9142,8 +9142,7 @@ "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" }, "process-nextick-args": { "version": "2.0.1", diff --git a/package.json b/package.json index d4101e9937..ab173219ba 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "joi-browser": "^13.4.0", "libsodium-wrappers-sumo": "0.7.9", "path-browserify": "^1.0.1", + "process": "^0.11.10", "ramda": "^0.27.1", "rlp": "2.2.6", "sha.js": "^2.4.11", diff --git a/webpack.config.js b/webpack.config.js index b47fad0148..a5fd19b12d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,9 @@ +const webpack = require('webpack') const path = require('path') -const R = require('ramda') -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') function configure (filename, opts = {}) { - return (env, argv) => R.mergeDeepRight({ + return (env, argv) => ({ entry: './src/index.js', mode: 'development', // automatically overriden by production flag devtool: argv.mode === 'production' ? 'source-map' : 'eval-source-map', @@ -13,12 +13,6 @@ function configure (filename, opts = {}) { test: /\.(js|ts)$/, include: path.resolve(__dirname, 'src'), loader: 'babel-loader' - }, - { - test: /\.js$/, - include: path.resolve(__dirname, 'node_modules/rlp'), - loader: 'babel-loader', - options: { presets: ['@babel/preset-env'] } } ] }, @@ -29,20 +23,29 @@ function configure (filename, opts = {}) { path: require.resolve('path-browserify'), stream: require.resolve('stream-browserify'), crypto: require.resolve('crypto-browserify') + }, + alias: { + 'js-yaml': false } }, - plugins: argv.report ? [ - new BundleAnalyzerPlugin({ + plugins: [ + ...opts.target === 'node' ? [] : [new webpack.ProvidePlugin({ + process: 'process', + Buffer: ['buffer', 'Buffer'] + })], + ...argv.report ? [new BundleAnalyzerPlugin({ analyzerMode: 'static', reportFilename: filename + '.html', openAnalyzer: false - }) - ] : [], + })] : [] + ], output: { path: path.resolve(__dirname, 'dist'), filename, - library: 'Ae', - libraryTarget: 'umd' + library: { + name: 'Ae', + type: 'umd' + } }, externals: Object .keys(require('./package').dependencies) @@ -52,8 +55,9 @@ function configure (filename, opts = {}) { commonjs: dependency, commonjs2: dependency } - }), {}) - }, opts) + }), {}), + ...opts + }) } module.exports = [