Fix native build: keep signer plugin external, bundle only @capacitor/core

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 <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy 2026-07-24 18:36:45 +07:00
parent 0a47bb47d2
commit ac362a9a10
2 changed files with 16 additions and 10 deletions

View file

@ -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": {

View file

@ -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',