From ac362a9a105a19d987d64f3f07fb38d4c187e780 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Fri, 24 Jul 2026 18:36:45 +0700 Subject: [PATCH] Fix native build: keep signer plugin external, bundle only @capacitor/core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v1.0.65 fixed the runtime crash (bundling @capacitor/core) but broke the CAPACITOR_BUILD by also un-externalizing nostr-signer-capacitor-plugin — which is installed from GitHub with a broken package entry point and cannot be bundled ("Failed to resolve entry for package"). Correct split: - BUNDLE @capacitor/core & @capacitor/camera (installed, statically imported, real JS the WebView needs) — this is the white-screen fix. - KEEP EXTERNAL nostr-signer-capacitor-plugin — no valid entry point; only used via a guarded dynamic import() at runtime on native (try/catch → null on failure), so external is correct and safe. - KEEP EXTERNAL the four non-installed @capacitor/* plugins. Verified: built bundle has no bare static @capacitor/core specifier; signer plugin remains an external dynamic import. Bump to 1.0.66. Co-authored-by: shakespeare.diy --- package.json | 2 +- vite.config.ts | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a921640..df1eee2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "skate-spots", "private": true, - "version": "1.0.65", + "version": "1.0.66", "type": "module", "homepage": "https://skate-spots.com", "scripts": { diff --git a/vite.config.ts b/vite.config.ts index 0168f83..443af0b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -44,17 +44,23 @@ export default defineConfig(() => ({ transformMixedEsModules: true, }, rollupOptions: { - // IMPORTANT: installed Capacitor packages (@capacitor/core, @capacitor/camera) - // and the signer plugin MUST be bundled. Their JS API layer is real code that - // the WebView needs — the *native* implementation is injected at runtime via - // window.Capacitor, but the JS imports have to resolve. Externalizing them - // leaves bare `import "@capacitor/core"` specifiers in the output, which a - // native WebView cannot resolve → "Failed to resolve module specifier" crash. + // IMPORTANT: @capacitor/core and @capacitor/camera MUST be bundled (they are + // installed, statically imported, and their JS API layer is real code the + // WebView needs). Leaving them external emitted a bare `import "@capacitor/core"` + // specifier that a native WebView cannot resolve → white-screen boot crash. + // They are therefore intentionally ABSENT from this list. // - // Only the Capacitor packages that are NOT installed are kept external, so a - // stray import can't break the build. If one of these is ever added to - // package.json, remove it from this list so it gets bundled. + // Kept external: + // - nostr-signer-capacitor-plugin: installed from GitHub with a broken package + // entry point, so it CANNOT be bundled. It's only ever used via a guarded + // dynamic import() at runtime on native (see lib/capacitorAmberSigner.ts, + // wrapped in try/catch → returns null on failure), so external is correct + // and safe — a resolution failure degrades gracefully instead of crashing. + // - @capacitor/app|haptics|keyboard|status-bar: NOT installed and never + // statically imported (accessed via window.Capacitor.Plugins), so keeping + // them external prevents a stray import from breaking the build. external: [ + 'nostr-signer-capacitor-plugin', '@capacitor/app', '@capacitor/haptics', '@capacitor/keyboard',