Skip to content

Commit

Permalink
Enables advanced hot reloading in monaco playground server.
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet committed Jul 2, 2024
1 parent 0a16d3c commit ad50f01
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/playground-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,15 @@ function handleGetFileChangesRequest(watcher: DirWatcher, fileServer: FileServer
function makeLoaderJsHotReloadable(loaderJsCode: string, fileChangesUrl: URL): string {
loaderJsCode = loaderJsCode.replace(
/constructor\(env, scriptLoader, defineFunc, requireFunc, loaderAvailableTimestamp = 0\) {/,
'$&globalThis.___globalModuleManager = this;'
'$&globalThis.___globalModuleManager = this; globalThis.vscode = { process: { env: { VSCODE_DEV: true } } }'
);

const ___globalModuleManager: any = undefined;

// This code will be appended to loader.js
function $watchChanges(fileChangesUrl: string) {
interface HotReloadConfig { }

let reloadFn;
if (globalThis.$sendMessageToParent) {
reloadFn = () => globalThis.$sendMessageToParent({ kind: 'reload' });
Expand Down Expand Up @@ -345,7 +347,7 @@ function makeLoaderJsHotReloadable(loaderJsCode: string, fileChangesUrl: URL): s
}

// Check if we can reload
const g: GlobalThisAddition = globalThis as any;
const g = globalThis as any;

// A frozen copy of the previous exports
const oldExports = Object.freeze({ ...oldModule.exports });
Expand Down

0 comments on commit ad50f01

Please sign in to comment.