Better support for monorepos in server bundle externals
eirikurn opened this issue · comments
We're using nodeExternals (webpack-node-externals) to externalize node_modules during server build. This is necessary because a lot of node modules (like mongoose) do fancy dynamic imports which are incompatible with webpack.
However, nodeExternals by default only works for standard repos, by scanning a single node_modules folder for packages to externalize. Monorepos often store packages in another folder.
Another issue with monorepos is when you want webpack to build your own package dependencies, you don't want those to be externalized.
I don't know a good way to make this "just work", but we can at least make it configurable in .neutrinorc.js:
module.exports = {
use: [
['tux/neutrino', {
ssr: {
nodeExternals: [
{ modulesDir: 'node_modules' },
{ modulesDir: '../../node_modules', whitelist: [/my-library/] },
],
},
],
],
}