What is the current behavior?
When building a library in dev mode (via webpack-dev-server) the dev server client is being returned as a library (which is actually an empty object as the client does not export anything).
If the current behavior is a bug, please provide the steps to reproduce.
Use library: 'MainLib' for example and run npx webpack-dev-server.
Observe returned library is an empty object.
Running npx webpack does not have this issue.
Repro:
https://github.com/dmitrysteblyuk/webpack-entry-point-bug-repro
When you run npx webpack-dev-server you can check the ./dist/main.js..
It will be like this (dev client entry is returned):
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ __webpack_require__("./main-entry.js");
/******/ return __webpack_require__("./node_modules/webpack-dev-server/client/index.js?http://localhost:8080");
/******/ })()
;
What is the expected behavior?
The provided main entry is returned as a library.
Other relevant information:
webpack version: ^5.0.0-beta.28
Node.js version: v13.12.0
Operating System: Mac OS X 10.15.5
Additional tools:
webpack-dev-server: ^3.11.0
webpack-cli: ^3.3.12
Feel free to send a PR
I managed to make it work when I moved addEntries from updateCompiler to before webpack compiler is instantiated (in ./bin/webpack-dev-server.js).
So apparently changing entry option after initialization is not okay with webpack 5 anymore.
I understand it's not a solution since it will only work when running dev server from cli (and Server accepts webpack compiler as an argument - so it's late to change entries at this point).
I'd welcome any ideas on how to make it work with both cli and api.
Or maybe just moving this bug to wepback after all, bc it used to work fine.
Can you try #2699?
It's wrong to prepend original entry points to additional ones like done in this pr.
Bc webpack exports the last entry point in case of library.
But I did check it anyways and it's indeed broken for both webpack 5 and 4.
Possible duplicate of #2484?
Possible duplicate of #2484?
Indeed it is.
Most helpful comment
Feel free to send a PR