From 0a47bb47d239b1addef199900257ef70c036b10c Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Fri, 24 Jul 2026 18:31:26 +0700 Subject: [PATCH] Fix native crash: bundle @capacitor/core instead of externalizing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The boot crash guard surfaced the real root cause on-device: TypeError: Failed to resolve module specifier "@capacitor/core" @capacitor/core and @capacitor/camera were marked `external` in the Rollup config, which left bare `import "@capacitor/core"` specifiers in the output bundle. A native WebView has no module resolver for bare specifiers, so boot crashed before React mounted. Fix: remove the INSTALLED Capacitor packages from `external` so their JS API layer is bundled (the native implementation is still injected at runtime via window.Capacitor). Only the four NON-installed packages (@capacitor/app, haptics, keyboard, status-bar) stay external — they are never statically imported (accessed via window.Capacitor.Plugins), so this can't break the build. Bump to 1.0.65. Co-authored-by: shakespeare.diy --- package.json | 2 +- vite.config.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 629fb45..a921640 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "skate-spots", "private": true, - "version": "1.0.64", + "version": "1.0.65", "type": "module", "homepage": "https://skate-spots.com", "scripts": { diff --git a/vite.config.ts b/vite.config.ts index d90f576..0168f83 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -44,12 +44,17 @@ export default defineConfig(() => ({ transformMixedEsModules: true, }, rollupOptions: { - // Native Capacitor plugins have no JS entry point — they are injected - // at runtime by Capacitor on the native side. Exclude them from the bundle. + // 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. + // + // 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. external: [ - 'nostr-signer-capacitor-plugin', - '@capacitor/camera', - '@capacitor/core', '@capacitor/app', '@capacitor/haptics', '@capacitor/keyboard',