1.3.0-beta.1: introduce typescript, webpack, better overall browser support, deprecate assert calls

This commit is contained in:
tiagosiebler
2020-12-13 17:19:18 +00:00
parent 6f30c2d659
commit 0606525e96
18 changed files with 3351 additions and 660 deletions

69
webpack/webpack.config.js Normal file
View File

@@ -0,0 +1,69 @@
const webpack = require('webpack');
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
function generateConfig(name) {
var config = {
entry: './lib/index.js',
output: {
path: path.resolve(__dirname, '../dist'),
filename: name + '.js',
sourceMapFilename: name + '.map',
library: 'bybitapi',
libraryTarget: 'umd'
},
devtool: "source-map",
mode: 'production',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
fallback: {
"crypto": require.resolve("crypto-browserify"),
"buffer": require.resolve("buffer/"),
"stream": require.resolve("stream-browserify")
}
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{ test: /\.tsx?$/, loader: "ts-loader" },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, loader: "source-map-loader" },
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components|samples|lib|test|coverage)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
'targets': {
'node': 'current'
}
}]]
}
}
}
]
}
};
config.plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new BundleAnalyzerPlugin({
defaultSizes: 'stat',
analyzerMode: 'static',
reportFilename: '../doc/bundleReport.html',
openAnalyzer: false,
})
];
return config;
};
module.exports = generateConfig('bybitapi');