script-loader icon indicating copy to clipboard operation
script-loader copied to clipboard

Reference error when used with webpack-dev-server

Open localjo opened this issue 6 years ago • 0 comments

I'm using script-loader to load some legacy scripts into my app. Everything works fine when I build with webpack, but when I build with webpack-dev-server instead (to enable hot reloading of other, non-legacy scripts in my project), all of my bundles that use script-loader throw an error in the browser;

[Script Loader] ReferenceError: require is not defined
...
at Object../node_modules/webpack-dev-server/client/index.js?http://localhost:8080 (myScriptLoaderBundle.js:338)

Oddly, the legacy scripts seem to still be loading in the browser, and the hot reloading of other resources works. But I'm trying to figure out what causes the error, and see if there's anything I can do to avoid it. I thought it might be related to https://github.com/liady/webpack-node-externals/issues/17 but it doesn't look like script-loader uses webpack-node-externals.

localjo avatar Oct 31 '19 00:10 localjo