From 6196ec5f74faa0b783a1b3d75eadcd6cad5f651e Mon Sep 17 00:00:00 2001
From: memdmp <memdmp@estrogen.zone>
Date: Mon, 24 Feb 2025 04:42:53 +0100
Subject: fix: split bundles, reproducible builds (hopefully)

---
 src/routes/Monaco.svelte | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

(limited to 'src/routes/Monaco.svelte')

diff --git a/src/routes/Monaco.svelte b/src/routes/Monaco.svelte
index 409ab39..cfe9767 100644
--- a/src/routes/Monaco.svelte
+++ b/src/routes/Monaco.svelte
@@ -1,11 +1,11 @@
 <script lang="ts">
   import type monaco from 'monaco-editor';
   import { onDestroy, onMount } from 'svelte';
-  import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
-  import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
-  import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
-  import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
-  import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
+  // import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
+  // import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
+  // import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
+  // import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
+  // import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
   // @ts-ignore
   import wrqTypes from '@types/webextension-polyfill/namespaces/webRequest.d.ts?raw';
   // @ts-ignore
@@ -37,20 +37,29 @@ declare global {
   onMount(async () => {
     // @ts-ignore
     globalThis.MonacoEnvironment = {
-      getWorker: function (_moduleId: any, label: string) {
+      getWorker: async (_moduleId: any, label: string) => {
         if (label === 'json') {
-          return new jsonWorker();
-        }
-        if (label === 'css' || label === 'scss' || label === 'less') {
-          return new cssWorker();
-        }
-        if (label === 'html' || label === 'handlebars' || label === 'razor') {
-          return new htmlWorker();
+          return new (
+            await import(
+              'monaco-editor/esm/vs/language/json/json.worker?worker'
+            )
+          ).default();
         }
+        // if (label === 'css' || label === 'scss' || label === 'less') {
+        //   return new cssWorker();
+        // }
+        // if (label === 'html' || label === 'handlebars' || label === 'razor') {
+        //   return new htmlWorker();
+        // }
         if (label === 'typescript' || label === 'javascript') {
-          return new tsWorker();
+          return await (
+            await import('./ts-worker')
+          ).default;
         }
-        return new editorWorker();
+        // return new editorWorker();
+        return new (
+          await import('monaco-editor/esm/vs/editor/editor.worker?worker')
+        ).default();
       },
     };
 
-- 
cgit v1.2.3

