From ec9e44ee0c0eba882370e4964e9015ace2bc3fb5 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 4 Jan 2025 04:04:37 +0100 Subject: [PATCH] before esbuild --- frontend/package-lock.json | 12 ++++++++++++ frontend/package.json | 3 ++- .../src/lib/components/raw_apps/EsbuildBundler.ts | 15 +++++++++++++++ .../lib/components/raw_apps/RawAppEditor.svelte | 1 - 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 frontend/src/lib/components/raw_apps/EsbuildBundler.ts diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9498481688be6..e833c76236996 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -40,6 +40,7 @@ "date-fns": "^2.30.0", "diff": "^5.1.0", "driver.js": "^1.3.0", + "esbuild-wasm": "0.24.2", "esm-env": "^1.0.0", "fast-equals": "^5.0.1", "graphql": "^16.7.1", @@ -6783,6 +6784,17 @@ "@esbuild/win32-x64": "0.21.5" } }, + "node_modules/esbuild-wasm": { + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.24.2.tgz", + "integrity": "sha512-03/7Z1gD+ohDnScFztvI4XddTAbKVmMEzCvvkBpQdWKEXJ+73dTyeNrmdxP1Q0zpDMFjzUJwtK4rLjqwiHbzkw==", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 862f7715cf99a..adc7cfa70e68a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,10 +17,10 @@ "filter-classes": "node filterTailwindClasses.js" }, "devDependencies": { + "@codesandbox/sandpack-client": "^2.19.8", "@floating-ui/core": "^1.3.1", "@hey-api/openapi-ts": "^0.43.0", "@playwright/test": "^1.34.3", - "@codesandbox/sandpack-client": "^2.19.8", "@rgossiaux/svelte-headlessui": "^2.0.0", "@sveltejs/adapter-static": "^3.0.6", "@sveltejs/kit": "^2.9.0", @@ -114,6 +114,7 @@ "date-fns": "^2.30.0", "diff": "^5.1.0", "driver.js": "^1.3.0", + "esbuild-wasm": "0.24.2", "esm-env": "^1.0.0", "fast-equals": "^5.0.1", "graphql": "^16.7.1", diff --git a/frontend/src/lib/components/raw_apps/EsbuildBundler.ts b/frontend/src/lib/components/raw_apps/EsbuildBundler.ts new file mode 100644 index 0000000000000..117b7d14b2d77 --- /dev/null +++ b/frontend/src/lib/components/raw_apps/EsbuildBundler.ts @@ -0,0 +1,15 @@ +import * as esbuild from 'esbuild-wasm' + +let initialized = false + +export async function initializeEsbuild() { + if (!initialized) { + await esbuild.initialize({ + wasmURL: 'https://unpkg.com/esbuild-wasm/esbuild.wasm', // Use a CDN for simplicity + worker: true + }) + initialized = true + } +} + +export { esbuild } diff --git a/frontend/src/lib/components/raw_apps/RawAppEditor.svelte b/frontend/src/lib/components/raw_apps/RawAppEditor.svelte index 9da3fa51bdef1..a7cc8e7be0503 100644 --- a/frontend/src/lib/components/raw_apps/RawAppEditor.svelte +++ b/frontend/src/lib/components/raw_apps/RawAppEditor.svelte @@ -457,7 +457,6 @@ export function getJob(id: string): Promise onPackageJsonChange() }} on:change={() => { - console.log('bar') timeout && clearTimeout(timeout) timeout = setTimeout(() => { onContentChange()