[Bug] contenthash generated for the monaco-editor chunk when using monaco-webpack-plugin differs between linux and windows
#3,021 opened on Mar 13, 2022
Repository metrics
- Stars
- (14,836 stars)
- PR merge metrics
- (Avg merge 6h 26m) (15 merged PRs in 30d)
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 Code
No response
Actual Behavior
Using webpack with the monaco-webpack-plugin the contenthash of the chunk containing the monaco-editor code differs between linux and windows.
Expected Behavior
The Chunks containing the monaco-editor should have the same contenthash regardless of whether they have been built on linux or windows using the monaco-webpack-plugin.
Additional Context
I first asked about this on the webpack discussion forum: https://github.com/webpack/webpack/discussions/15504
A minimal example that you can checkout and build on windows and linux (via npm run build) can be found here: https://github.com/momesana/unstable-contenthash-when-using-monaco-webpack-plugin
The difference in the contenthash only pertains to the chunk containing the monaco-editor code and seems to be caused by a different order of attributes in the object inside the generated module.
Once built under windows and linux (both via npm run build) there are only two sets of chunks with non-matching hashes:
windows:
594.990f43d1632048ca16e1.chunk.js // contains the monaco-editor chunk
594.990f43d1632048ca16e1.chunk.js.LICENSE.txt
main.3e9baec4388838c4a569.js
main.3e9baec4388838c4a569.js.LICENSE.txt
linux or mac:
594.ae364e61732aa00da899.chunk.js // contains the monaco-editor chunk
594.ae364e61732aa00da899.chunk.js.LICENSE.txt
main.69cf259c81fb831bb4e6.js
main.69cf259c81fb831bb4e6.js.LICENSE.txt
The license files are identical and yield the same md5sum and the only difference in the main.*.js files once formatted is the hash of the referenced monaco-chunk:
1c1
< /*! For license information please see main.3e9baec4388838c4a569.js.LICENSE.txt */
---
> /*! For license information please see main.69cf259c81fb831bb4e6.js.LICENSE.txt */
6097c6097
< 594: "990f43d1632048ca16e1",
---
> 594: "ae364e61732aa00da899",
The chunks containing the monaco code itself however do deviate but only in the order in which two attributes appear in the code. Apart from that they are identical:
1c1
< /*! For license information please see 594.ae364e61732aa00da899.chunk.js.LICENSE.txt */
---
> /*! For license information please see 594.990f43d1632048ca16e1.chunk.js.LICENSE.txt */
178c178
< }, 9565: (e, t, i) => {
---
> }, 4444: (e, t, i) => {
182c182
< r.push([e.id, "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/* Uncomment to see lines flashing when they're painted */\n/*.monaco-editor .view-lines > .view-line {\n\tbackground-color: none;\n\tanimation-name: flash-background;\n\tanimation-duration: 800ms;\n}\n@keyframes flash-background {\n\t0% { background-color: lightgreen; }\n\t100% { background-color: none }\n}*/\n\n.mtkcontrol {\n\tcolor: rgb(255, 255, 255) !important;\n\tbackground: rgb(150, 0, 0) !important;\n}\n\n.monaco-editor.no-user-select .lines-content,\n.monaco-editor.no-user-select .view-line,\n.monaco-editor.no-user-select .view-lines {\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n.monaco-editor .view-lines {\n\twhite-space: nowrap;\n}\n\n.monaco-editor .view-line {\n\tposition: absolute;\n\twidth: 100%;\n}\n\n.monaco-editor .mtkz {\n\tdisplay: inline-block;\n}\n\n/* TODO@tokenization bootstrap fix */\n/*.monaco-editor .view-line > span > span {\n\tfloat: none;\n\tmin-height: inherit;\n\tmargin-left: inherit;\n}*/\n", ""]);
---
> r.push([e.id, "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n.monaco-editor .lines-decorations {\n\tposition: absolute;\n\ttop: 0;\n\tbackground: white;\n}\n\n/*\n\tKeeping name short for faster parsing.\n\tcldr = core lines decorations rendering (div)\n*/\n.monaco-editor .margin-view-overlays .cldr {\n\tposition: absolute;\n\theight: 100%;\n}", ""]);
184c184
< }, 4444: (e, t, i) => {
---
> }, 9565: (e, t, i) => {
188c188
< r.push([e.id, "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n.monaco-editor .lines-decorations {\n\tposition: absolute;\n\ttop: 0;\n\tbackground: white;\n}\n\n/*\n\tKeeping name short for faster parsing.\n\tcldr = core lines decorations rendering (div)\n*/\n.monaco-editor .margin-view-overlays .cldr {\n\tposition: absolute;\n\theight: 100%;\n}", ""]);
---
> r.push([e.id, "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/* Uncomment to see lines flashing when they're painted */\n/*.monaco-editor .view-lines > .view-line {\n\tbackground-color: none;\n\tanimation-name: flash-background;\n\tanimation-duration: 800ms;\n}\n@keyframes flash-background {\n\t0% { background-color: lightgreen; }\n\t100% { background-color: none }\n}*/\n\n.mtkcontrol {\n\tcolor: rgb(255, 255, 255) !important;\n\tbackground: rgb(150, 0, 0) !important;\n}\n\n.monaco-editor.no-user-select .lines-content,\n.monaco-editor.no-user-select .view-line,\n.monaco-editor.no-user-select .view-lines {\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n.monaco-editor .view-lines {\n\twhite-space: nowrap;\n}\n\n.monaco-editor .view-line {\n\tposition: absolute;\n\twidth: 100%;\n}\n\n.monaco-editor .mtkz {\n\tdisplay: inline-block;\n}\n\n/* TODO@tokenization bootstrap fix */\n/*.monaco-editor .view-line > span > span {\n\tfloat: none;\n\tmin-height: inherit;\n\tmargin-left: inherit;\n}*/\n", ""]);