I would like to treeshake rxjs in my TypeScript application that is bundled via WebPack:
rxjs@7.5.7 webpack@5.74.0
According to https://rxjs.dev/guide/installation I would have to use the ES2015
exports of rxjs
, but I cannot find out how to do that.
Are you aware of an example or a link to some documentation?
My current webpack config is:
const path = require('path');
module.exports = {
entry: './src/index.ts',
devtool: 'source-map',
target: 'node16',
mode: 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};
This config has successfully tree shaken the rxjs@6
version (which has the module
entry point) but it fails to tree shake rxjs@7
and uses the full CJS version instead.
Thanks for any pointers!