nodeExternals
Simple modern alternative to webpack-node-externals.
This utility function marks all dependencies from node_modules as external.
It means that such dependencies will not be included to bundle.
Typically it can be useful when you bundle server application for running in Node.js.
Usage
rspack.config.js
import { nodeExternals } from '@kruoo/utils/rspack';
export default {
mode: 'development',
target: 'node',
output: {
filename: 'index.js'
}
externalsPresets: {
node: true,
},
externals: [
nodeExternals(),
],
};
Option allow
To force add some dependencies to bundle you can use allow option:
nodeExternals({
allow: ['@my-org/my-components', /(react|react-dom)/],
});
By default it contains css-loader because it injects some code into runtime.