diff --git a/desktop-shell/tauri-skeleton/scripts/build-backend-runtime.cjs b/desktop-shell/tauri-skeleton/scripts/build-backend-runtime.cjs index 7e3a0cc3..9f6262fe 100644 --- a/desktop-shell/tauri-skeleton/scripts/build-backend-runtime.cjs +++ b/desktop-shell/tauri-skeleton/scripts/build-backend-runtime.cjs @@ -395,10 +395,14 @@ function verifyRelocatableWindowsRuntime() { const env = { ...process.env }; delete env.PYTHONHOME; delete env.PYTHONPATH; + // -B: the probe must not leave .pyc files behind; they record this + // machine's build path and would ship in the bundle. + env.PYTHONDONTWRITEBYTECODE = '1'; result = spawnSync( path.join(probeDir, 'python', 'python.exe'), [ '-I', + '-B', '-c', [ 'import sys', diff --git a/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs b/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs index 502a00da..ea6f4cd2 100644 --- a/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs +++ b/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs @@ -1,7 +1,9 @@ #!/usr/bin/env node const fs = require('node:fs'); +const os = require('node:os'); const path = require('node:path'); +const { pathToFileURL } = require('node:url'); const { spawnSync } = require('node:child_process'); const scriptDir = __dirname; @@ -100,10 +102,40 @@ function runExportBuild() { } } +// Webpack turns `import.meta.url` into a file:// URL of this machine's +// checkout (maplibre-gl's worker fallback does this). That URL never resolves +// on a user's machine, so a neutral root changes nothing at runtime and keeps +// the build path out of the shipped bundle. +function scrubBuildPaths(dir) { + const replacements = [ + [pathToFileURL(repoRoot).href, 'file:///shadowbroker'], + [pathToFileURL(os.homedir()).href, 'file:///~'], + ]; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) { + scrubBuildPaths(full); + continue; + } + if (!/\.(?:js|mjs|html|json|txt|map|css)$/i.test(entry.name)) { + continue; + } + const text = fs.readFileSync(full, 'utf8'); + let scrubbed = text; + for (const [from, to] of replacements) { + scrubbed = scrubbed.split(from).join(to); + } + if (scrubbed !== text) { + fs.writeFileSync(full, scrubbed); + } + } +} + function syncBuildOutput() { if (!fs.existsSync(buildOutDir)) { throw new Error(`Desktop export did not produce ${buildOutDir}`); } + scrubBuildPaths(buildOutDir); fs.rmSync(liveOutDir, { recursive: true, force: true }); fs.cpSync(buildOutDir, liveOutDir, { recursive: true,