webpack.config.js
const {TsconfigPathsPlugin} = require('tsconfig-paths-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const path = require('path');
module.exports = {
mode: 'production',
node: {
global: true,
__filename: true,
__dirname: true,
},
entry: './index.ts',
output: {
path: `${path.resolve(__dirname)}/dist`,
filename: 'index.js',
library: {
type: 'commonjs',
},
},
resolve: {
plugins: [new NodePolyfillPlugin({
include: ['path'],
}), new TsconfigPathsPlugin()],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
},
},
},
},
},
],
},
};
log output
11:42:29 AM ✖1 » /Users/daniel/.nvm/versions/node/v16.13.2/bin/webpack
assets by status 0 bytes [cached] 1 asset
ERROR in Cannot read properties of undefined (reading 'fallback')
webpack 5.74.0 compiled with 1 error in 72 ms
webpack.config.js
log output