Open Arandhras opened 1 month ago
Do you build application or library? What is your target - node
or web
?
Do you build application or library? What is your target -
node
orweb
?
My target is node.
Why do you need runtimeChunk
for node?
Yeah, it is a bug, something wrong with dependOn
and optimization.runtimeChunk
with node target
Feel free to send a fix
We are developing a server architecture where you have a "core bundle" (where the actual entry point of the application is) and several "client" ones, and we want to be able to split this code so that we can deploy the application with zero, one or just a few client bundles instead of all of them.
The rationale is twofold: 1) since we can have different on-premise deployments at different clients, and we do not wish to expose client-specific business logic to someone who isn't the intended user; 2) when updating our application deployments without altering the underlying node_modules, we would like to install only the core or client bundle(s) that actually got modified instead of the entirety of the codebase reduced to a single, monolithic bundle.
Bug report
I have encountered a bug while trying to split code into multiple bundles, while preventing duplication of said code. In other words, I want to create a "main" bundle which is the "true" entry point of the application, and one or more auxiliary bundles. To this end, I have followed the documentation present at this page.
What is the current behavior? The following is the config object contained in my
webpack.config.js
file:After launching the
npx webpack
command and executingnode .\dist\main.js
, node throws the followingError
:If the current behavior is a bug, please provide the steps to reproduce.
I have written a simple test project that is available at this GitHub repository. After downloading the project simply run
npm run dev
to get the required node_modules (webpack, webpack-cli and their dependencies) and then automatically executenode .\dist\main.js
.What is the expected behavior?
It seems that
.\dist\runtime.js
is broken, specifically in two points.Why is this function returning
undefined
regardless of thechunkId
being passed? In development mode, if I change the return line intothe
require()
that is immediately called after, is working.Another issue I've identified, lies within this function:
Sometimes the
chunk
argument being passed is an empty object{}
, thereforechunkIds
isundefined
. In this case when the for loop is reached, accessingchunkIds.length
results in anError
being thrown.Other relevant information: webpack version: 5.91.0 Node.js version: v18.18.0 Operating System: Windows 10 Enterprise 22H2 Additional tools: none