Skip to content

Commit 0cb31c2

Browse files
authored
Merge pull request #585 from CodinGame/fix-duplicated-version-detection-hmr-issue
Better duplicated version detection
2 parents 8288e51 + b234341 commit 0cb31c2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

rollup/rollup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export default (args: Record<string, string>): rollup.RollupOptions => {
149149
VSCODE_VERSION: JSON.stringify(vscodeVersion),
150150
VSCODE_REF: JSON.stringify(vscodeRef),
151151
VSCODE_COMMIT: JSON.stringify(vscodeCommit),
152+
BUILD_ID: JSON.stringify(`${vscodeRef}-${crypto.randomUUID()}`),
152153
'globalThis.require': 'undefined',
153154
preventAssignment: true
154155
}),

src/services.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ import getBaseServiceOverride from './service-override/base'
5353

5454
declare global {
5555
interface Window {
56-
monacoVscodeApiInitialized?: boolean
56+
monacoVscodeApiBuildId?: string
5757
}
5858
}
5959

60-
if (window.monacoVscodeApiInitialized ?? false) {
61-
throw new Error('Another version of monaco-vscode-api has already been loaded.')
60+
if (window.monacoVscodeApiBuildId != null && window.monacoVscodeApiBuildId !== BUILD_ID) {
61+
throw new Error(
62+
`Another version of monaco-vscode-api has already been loaded. Trying to load ${BUILD_ID}, ${window.monacoVscodeApiBuildId} is already loaded`
63+
)
6264
}
6365

64-
window.monacoVscodeApiInitialized = true
66+
window.monacoVscodeApiBuildId = BUILD_ID
6567

6668
export async function initialize(
6769
overrides: IEditorOverrideServices,

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare const VSCODE_VERSION: string
22
declare const VSCODE_REF: string
33
declare const VSCODE_COMMIT: string
4+
declare const BUILD_ID: string
45

56
declare module 'vs/platform/accessibilitySignal/browser/media/*.mp3' {
67
const assets: Record<string, string>

0 commit comments

Comments
 (0)