Собираю код через Webpack, но после сборки методы, которые используют сетевые запросы - просто зависают. Точнее код доходит до вызова этих методов и дальше не идет. В чем может быть причина?
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const WebpackObfuscator = require('webpack-obfuscator');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
/**
*
* @param {*} env
* @param {*} argv
* @returns {import('webpack').Configuration}
*/
module.exports = (env, argv) => {
return {
mode: 'production' || 'development',
entry: './src/index.ts',
target: 'node',
output: {
filename: 'index.js',
path: path.resolve('./bundle'),
library: {
type: 'commonjs2',
},
libraryTarget: 'commonjs2',
clean: true,
},
resolve: {
extensions: ['.ts', '.js', '.node'],
},
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(node)$/,
loader: path.resolve(__dirname, 'webpack-addons-loader.js'),
options: {
name: '[path][name].[ext]',
},
},
],
},
optimization: {
splitChunks: false,
minimize: true,
minimizer: [
new TerserPlugin({
minify: TerserPlugin.swcMinify,
terserOptions: {
format: { comments: false },
module: true,
},
extractComments: false,
}),
],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
new CopyPlugin({
patterns: [
{
from: path.join('node_modules', 'onnxruntime-node'),
to: path.join('onnxruntime-node'),
},
{
from: path.join('node_modules', 'canvas'),
to: path.join('canvas'),
},
{
from: path.join('config.env'),
to: path.join('config.env'),
},
],
options: {
concurrency: 2,
},
}),
],
};
};