| @@ -90,6 +90,34 @@ const resolveQuickJsWasmPath = (): string => { · 89 unmodified lines |
| 90 | return wasmPath; | 90 | return wasmPath; |
| 91 | }; | 91 | }; |
| 92 | | 92 | |
| | 93 | const resolvePGliteAssetPaths = (): { |
| | 94 | dataPath: string; |
| | 95 | wasmPath: string; |
| | 96 | } => { |
| | 97 | const requireFromControlPlane = createRequire( |
| | 98 | join(repoRoot, "packages/control-plane/package.json"), |
| | 99 | ); |
| | 100 | const pglitePackagePath = requireFromControlPlane.resolve( |
| | 101 | "@electric-sql/pglite/package.json", |
| | 102 | ); |
| | 103 | const pgliteDistDir = join(dirname(pglitePackagePath), "dist"); |
| | 104 | const dataPath = join(pgliteDistDir, "pglite.data"); |
| | 105 | const wasmPath = join(pgliteDistDir, "pglite.wasm"); |
| | 106 | |
| | 107 | if (!existsSync(dataPath)) { |
| | 108 | throw new Error(`Unable to locate PGlite data asset at ${dataPath}`); |
| | 109 | } |
| | 110 | |
| | 111 | if (!existsSync(wasmPath)) { |
| | 112 | throw new Error(`Unable to locate PGlite wasm asset at ${wasmPath}`); |
| | 113 | } |
| | 114 | |
| | 115 | return { |
| | 116 | dataPath, |
| | 117 | wasmPath, |
| | 118 | }; |
| | 119 | }; |
| | 120 | |
| 93 | const createPackageJson = (input: { | 121 | const createPackageJson = (input: { |
| 94 | packageName: string; | 122 | packageName: string; |
| 95 | packageVersion: string; | 123 | packageVersion: string; |
| @@ -150,6 +178,7 @@ export const buildDistributionPackage = async ( · 54 unmodified lines |
| 150 | const bundlePath = join(binDir, "executor.mjs"); | 178 | const bundlePath = join(binDir, "executor.mjs"); |
| 151 | const launcherPath = join(binDir, "executor.js"); | 179 | const launcherPath = join(binDir, "executor.js"); |
| 152 | const quickJsWasmPath = resolveQuickJsWasmPath(); | 180 | const quickJsWasmPath = resolveQuickJsWasmPath(); |
| | 181 | const pgliteAssets = resolvePGliteAssetPaths(); |
| 153 | const webDistDir = join(repoRoot, "apps/web/dist"); | 182 | const webDistDir = join(repoRoot, "apps/web/dist"); |
| 154 | const readmePath = join(repoRoot, "README.md"); | 183 | const readmePath = join(repoRoot, "README.md"); |
| 155 | const packageName = options.packageName ?? defaults.name; | 184 | const packageName = options.packageName ?? defaults.name; |
| @@ -185,6 +214,8 @@ export const buildDistributionPackage = async ( · 29 unmodified lines |
| 185 | | 214 | |
| 186 | await cp(webDistDir, webDir, { recursive: true }); | 215 | await cp(webDistDir, webDir, { recursive: true }); |
| 187 | await cp(quickJsWasmPath, join(binDir, "emscripten-module.wasm")); | 216 | await cp(quickJsWasmPath, join(binDir, "emscripten-module.wasm")); |
| | 217 | await cp(pgliteAssets.dataPath, join(binDir, "pglite.data")); |
| | 218 | await cp(pgliteAssets.wasmPath, join(binDir, "pglite.wasm")); |
| 188 | await mkdir(join(binDir, "openapi-extractor-wasm"), { recursive: true }); | 219 | await mkdir(join(binDir, "openapi-extractor-wasm"), { recursive: true }); |
| 189 | await cp( | 220 | await cp( |
| 190 | join(repoRoot, "packages/codemode-openapi/src/openapi-extractor-wasm/openapi_extractor_bg.wasm"), | 221 | join(repoRoot, "packages/codemode-openapi/src/openapi-extractor-wasm/openapi_extractor_bg.wasm"), |