7

Webpack 5 deprecated null-loader, which was helpful for excluding certain imports from client-side bundles. Now, the docs say that I should use the resolve.alias option with false instead, however, this thing doesn't accept regex keys like null-loader did. But I want to deliberately exclude specific imports matching a regex. I've tried IgnorePlugin, but that simply prevents the module from being added to the bundle but keeps the import, which breaks in the browser.

What's the intended solution here? Should I write my own loader to do what null-loader used to do?

DavidsKanal
  • 655
  • 11
  • 15

1 Answers1

2

The deprecation note suggests that you can use regex. See xyz$: https://webpack.js.org/blog/2020-10-10-webpack-5-release/#deprecated-loaders

Try wrapping the regex key in single quotes if necessary. This seems to have worked for me.

Ian Walter
  • 882
  • 2
  • 8
  • 23