[Bug] Incorrect `[contenthash]` for filename for worker scripts from monaco-editor-webpack-plugin
#3615 opened on Feb 28, 2023
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
No response
Reproduction Steps
No response
Actual (Problematic) Behavior
The monaco-editor-webpack-plugin uses loaderUtils.interpolateName to produce the file name for worker bundles:
The interpolateName function calculates the value of a [contentHash] placeholder in the provided string by hashing the contents of the contents value passed to it:
[contenthash] the hash of options.content (Buffer) (by default it's the hex digest of the xxhash64 hash)
In the code snippet above, this is fs.readFileSync(resolveMonacoPath(entry, monacoEditorPath)), which ends up loading something like monaco-editor/esm/vs/editor/editor.worker which is this file.
The issue here is that this file itself rarely changes which means that the [contenthash] value doesn't end up changing between releases even though it should.
For example, in a project we have using monaco, we upgraded to 0.35.0 recently, which contains meaningful changes in the worker. However, the [contenthash] value didn't change, so users who had previously loaded our project with an older version of monaco would continue to be served that older worker file via our caching rules.
Does the above make sense? Apologies if anything is misexplained, I haven't necessarily fully investigated how all the details of the webpack plugin work.
Expected Behavior
[contenthash] is a different value whenever anything in the worker bundle is different.
Additional Context
No response