mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-01-12 17:52:41 +08:00
build(deps): dedupe deps
This commit is contained in:
@@ -4,11 +4,13 @@ const path = require('path');
|
||||
// Run with ANALYZE ENV to show bundle size (only works with cjs)
|
||||
// e.g.: ANALYZE=true lerna run --scope @stacks/wallet-sdk build
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const { DuplicatesPlugin } = require('inspectpack/plugin');
|
||||
|
||||
const NODE_ENV_PRODUCTION = 'production';
|
||||
const NODE_ENV_DEVELOPMENT = 'development';
|
||||
|
||||
const isAnalyze = !!process.env.ANALYZE;
|
||||
const isDedupe = !!process.env.DEDUPE;
|
||||
const isProduction = process.env.NODE_ENV === NODE_ENV_PRODUCTION;
|
||||
|
||||
module.exports = {
|
||||
@@ -28,6 +30,7 @@ module.exports = {
|
||||
Buffer: ['buffer', 'Buffer'],
|
||||
process: require.resolve('process/browser'), // unclear which @stacks package dependencies introduce this (not common, not network)
|
||||
}),
|
||||
isDedupe && new DuplicatesPlugin(),
|
||||
isAnalyze && new BundleAnalyzerPlugin(),
|
||||
].filter(Boolean),
|
||||
optimization: {
|
||||
@@ -54,17 +57,17 @@ module.exports = {
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js'],
|
||||
alias: {
|
||||
'@stacks/auth': '@stacks/auth/dist/umd',
|
||||
'@stacks/bns': '@stacks/bns/dist/umd',
|
||||
'@stacks/common': '@stacks/common/dist/umd',
|
||||
'@stacks/encryption': '@stacks/encryption/dist/umd',
|
||||
'@stacks/keychain': '@stacks/keychain/dist/umd',
|
||||
'@stacks/network': '@stacks/network/dist/umd',
|
||||
'@stacks/profile': '@stacks/profile/dist/umd',
|
||||
'@stacks/stacking': '@stacks/stacking/dist/umd',
|
||||
'@stacks/storage': '@stacks/storage/dist/umd',
|
||||
'@stacks/transactions': '@stacks/transactions/dist/umd',
|
||||
'@stacks/wallet-sdk': '@stacks/wallet-sdk/dist/umd',
|
||||
'@stacks/auth': '@stacks/auth/dist/esm',
|
||||
'@stacks/bns': '@stacks/bns/dist/esm',
|
||||
'@stacks/common': '@stacks/common/dist/esm',
|
||||
'@stacks/encryption': '@stacks/encryption/dist/esm',
|
||||
'@stacks/keychain': '@stacks/keychain/dist/esm',
|
||||
'@stacks/network': '@stacks/network/dist/esm',
|
||||
'@stacks/profile': '@stacks/profile/dist/esm',
|
||||
'@stacks/stacking': '@stacks/stacking/dist/esm',
|
||||
'@stacks/storage': '@stacks/storage/dist/esm',
|
||||
'@stacks/transactions': '@stacks/transactions/dist/esm',
|
||||
'@stacks/wallet-sdk': '@stacks/wallet-sdk/dist/esm',
|
||||
},
|
||||
// fallback: is set in package config
|
||||
},
|
||||
|
||||
3175
package-lock.json
generated
3175
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"inspectpack": "^4.7.1",
|
||||
"lerna": "^4.0.0",
|
||||
"lerna-from-npm": "^1.0.0",
|
||||
"madge": "^5.0.1",
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
|
||||
// Run with ANALYZE ENV to show bundle size (only works with cjs)
|
||||
// e.g.: ANALYZE=true lerna run --scope @stacks/wallet-sdk build
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
|
||||
const NODE_ENV_PRODUCTION = 'production';
|
||||
const NODE_ENV_DEVELOPMENT = 'development';
|
||||
|
||||
const isAnalyze = !!process.env.ANALYZE;
|
||||
const isProduction = process.env.NODE_ENV === NODE_ENV_PRODUCTION;
|
||||
|
||||
module.exports = {
|
||||
mode: isProduction ? NODE_ENV_PRODUCTION : NODE_ENV_DEVELOPMENT,
|
||||
entry: ['./src/index.ts'],
|
||||
output: {
|
||||
library: {
|
||||
// name: SET IN INDIVIDUAL `webpack.config.js` FILE
|
||||
type: isAnalyze ? 'commonjs' : 'umd',
|
||||
},
|
||||
filename: 'index.js',
|
||||
path: path.resolve(process.cwd(), 'dist/umd'),
|
||||
globalObject: 'this', // recommended for umd bundles in webpack
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProvidePlugin({
|
||||
Buffer: ['buffer', 'Buffer'],
|
||||
process: require.resolve('process/browser'), // unclear which @stacks package dependencies introduce this (not common, not network)
|
||||
}),
|
||||
isAnalyze && new BundleAnalyzerPlugin(),
|
||||
].filter(Boolean),
|
||||
optimization: {
|
||||
minimize: isProduction,
|
||||
},
|
||||
devtool: 'source-map',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'esbuild-loader',
|
||||
options: {
|
||||
loader: 'tsx',
|
||||
target: 'es2017',
|
||||
tsconfigRaw: require(path.resolve(process.cwd(), 'tsconfig.build.json')),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user