Skip to content

Better support for monorepos in server bundle externals #153

@eirikurn

Description

@eirikurn

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/] },
        ],
      },
    ],
  ],
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions