Fix monaco chunk errors during development
What does this MR do and why?
Fix monaco chunk errors during development
Sometimes, when trying to view a page which prefetches monaco, like viewing a snippet or the WebIDE, this error would be displayed:
Can’t find entry point ‘monaco’ in webpack manifest
This was happening because:
- Incremental webpack compilation is enabled by default, meaning that only a subset of all possible chunks are compiled.
- The monaco chunk is only split out if two or more chunks depend on it. (See [minChunks]).
So, if the user doesn't have two or more chunks in their webpack compilation history (likely, especially on fresh installs), the monaco chunk isn't split out, so it's not listed as a chunk in the manifest, causing the prefetch to fail.
The fix is to ignore AssetMissingErrors in the prefetch function when the webpack dev server is being used in development or test environments, where incremental compilation may be enabled. This is done to mitigate this problem occuring due to potentially other chunks not getting split out for a similar reason.
An earlier iteration of this fix also reduced
optimization.splitChunks.cacheGroups.monaco.minChunks
option in
webpack.config.js
from 2 to 1, to make sure the monaco chunk was
always produced. However, that had the side-effect of inflating the size
of various entry points, so was reverted. See the MR for more details.
Screenshots or screen recordings
n/a
How to set up and validate locally
- Clear or rename your
tmp/cache/incremental-webpack-compiler-history.json
filemv tmp/cache/incremental-webpack-compiler-history.json{,.$(date --iso)}
- Visit a page which prefetches monaco, e.g., a snippet, or the WebIDE
- On
master
, this should fail with the error messageCan’t find entry point ‘monaco’ in webpack manifest
- On this branch, the page (and monaco) should load correctly
- On
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.