Skip to content

fix(app): export Filesystem/Share from build:web native stubs - #12936

Merged
lalalune merged 2 commits into
developfrom
fix/build-web-filesystem-stub
Jul 4, 2026
Merged

lalalune merged 2 commits into
developfrom
fix/build-web-filesystem-stub

Conversation

@NubsCarson

Copy link
Copy Markdown
Member

Problem

bun run --cwd packages/app build:web failed with:

"Filesystem" is not exported by "native-stub:@capacitor/filesystem"

src/ios-attachment-smoke.ts (the iOS attachment save/share smoke path shipped in #11009) statically imports { Filesystem } from @capacitor/filesystem and { Share } from @capacitor/share. main.tsx pulls it in statically (it only runs behind an isIOS gate), so the web bundle must still resolve those named exports — but the native-module stub plugin emitted only a default noop object for both packages.

Fix

packages/app/vite/native-module-stub-plugin.ts: add explicit named Filesystem / Share exports to the web stubs for @capacitor/filesystem and @capacitor/share.

Deliberately throwing stubs (Proxy where every method throws mobile-only) rather than silent no-ops: a silent no-op here would fabricate a successful file write or share if a web/desktop code path ever called it.

Verification

  • bun run --cwd packages/app build:web passes clean on this branch merged with current develop (424 assets, chunk-safety verifier OK) — previously failed at the Rollup export-resolution step.
  • Net diff vs develop is 18 lines in the stub plugin only (the branch's index.browser.ts redact-export hunk was already superseded by develop's export * from "./security/redact" fix(#12229): route Feed A2A fetch through SSRF guard + converge log redaction #12572 follow-up and resolved away at merge).

Finishing + shipping uncommitted sibling-agent work from the shared worktree.

— nubs-cloud [cloud-frontdoor]

build:web failed with 'Filesystem is not exported by native-stub:@capacitor/filesystem'
because src/ios-attachment-smoke.ts statically imports { Filesystem } from
@capacitor/filesystem and { Share } from @capacitor/share, but the native-module
stub plugin emitted only a default noop object for those packages.

Add explicit named Filesystem/Share exports to the stubs. Every method throws
(mobile-only) rather than silently no-opping, so a web/desktop code path can
never fabricate a successful file write or share.

Also export isSensitiveKeyName/redactLogArgs from core index.browser.ts
(superseded by develop's export * from ./security/redact — resolved at merge).
…system-stub

# Conflicts:
#	packages/core/src/index.browser.ts

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a67f16f-44be-4125-bc3c-66e308d5d1f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/build-web-filesystem-stub

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lalalune

lalalune commented Jul 4, 2026

Copy link
Copy Markdown
Member

Local validation from isolated checkout /tmp/eliza-pr-12936.

Passed:

bun run --cwd packages/app test -- test/native-module-stub-plugin.test.ts
git diff --check github-develop...HEAD

Result: focused app test passed (1 test).

I also directly exercised nativeModuleStubPlugin for the two affected virtual modules:

bun -e 'import { nativeModuleStubPlugin } from "./packages/app/vite/native-module-stub-plugin.ts"; const p = nativeModuleStubPlugin({ command: "build", mode: "production" }); const plugin = Array.isArray(p) ? p[0] : p; for (const id of ["@capacitor/filesystem", "@capacitor/share"]) { const resolved = await plugin.resolveId.call({}, id, "/tmp/entry.ts", {}); const loaded = await plugin.load.call({}, resolved); if (id.includes("filesystem") && !loaded.includes("export const Filesystem")) throw new Error("missing Filesystem export"); if (id.includes("share") && !loaded.includes("export const Share")) throw new Error("missing Share export"); }'

Result: both virtual modules resolved and loaded; @capacitor/filesystem exports Filesystem, and @capacitor/share exports Share, both as throwing mobile-only proxies.

Could not complete locally:

bun run --cwd packages/app build:web

It fails before this stub path because the linked temp install cannot resolve @tailwindcss/vite while loading packages/app/vite.config.ts. I would rely on CI or a complete install for the full build:web confirmation.

@lalalune lalalune left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the effective diff against current develop: only packages/app/vite/native-module-stub-plugin.ts changes. The added Filesystem and Share named exports match the static imports in src/ios-attachment-smoke.ts, and using throwing mobile-only stubs is the right failure mode for accidental web/desktop calls.

Local checks: git diff --check origin/develop...pr-12936 passed; bunx @biomejs/biome check packages/app/vite/native-module-stub-plugin.ts passed. I also retried bun run --cwd packages/app build:web after building packages/shared; it passed the original Capacitor export-resolution blocker, then hit unrelated local checkout/dist dependency issues (@elizaos/core dist/browser missing warnings and a three-vrm/three.webgpu mismatch), so I’m relying on the attached clean build evidence for the full app build.

@lalalune
lalalune merged commit a06ad22 into develop Jul 4, 2026
20 of 41 checks passed
@lalalune
lalalune deleted the fix/build-web-filesystem-stub branch July 4, 2026 05:26
@lalalune

lalalune commented Jul 4, 2026

Copy link
Copy Markdown
Member

Added a focused regression test for this fix in packages/app/test/native-module-stub-plugin.test.ts.

Local validation after applying the PR branch:

  • bun test packages/app/test/native-module-stub-plugin.test.ts — passes, 2 tests / 11 expects. The new test imports the generated virtual @capacitor/filesystem and @capacitor/share modules and verifies named Filesystem / Share exports exist, default exports match, and calls throw mobile-only rather than silently no-oping.
  • bunx @biomejs/biome check packages/app/vite/native-module-stub-plugin.ts packages/app/test/native-module-stub-plugin.test.ts — passes.

Local blockers not caused by this PR:

  • bun run --cwd packages/app build:web fails before Rollup reaches the Capacitor export resolution path because this sparse checkout's node_modules is missing @tailwindcss/vite while packages/app/package.json and bun.lock declare it.
  • bun run --cwd packages/app typecheck is blocked by the sparse checkout / install state with missing workspace packages and native package declarations across packages/agent, @elizaos/ui, Capacitor packages, etc.

I did not run audit:app: this change is limited to Vite's web-build native module stubs and does not alter rendered app UI.

lalalune pushed a commit that referenced this pull request Jul 4, 2026
#12985)

build:web failed with 'Filesystem is not exported by native-stub:@capacitor/filesystem'
because src/ios-attachment-smoke.ts statically imports { Filesystem } from
@capacitor/filesystem and { Share } from @capacitor/share, but the native-module
stub plugin emitted only a default noop object for those packages.

Add explicit named Filesystem/Share exports to the stubs. Every method throws
(mobile-only) rather than silently no-opping, so a web/desktop code path can
never fabricate a successful file write or share.

Also export isSensitiveKeyName/redactLogArgs from core index.browser.ts
(superseded by develop's export * from ./security/redact — resolved at merge).

(cherry picked from commit a06ad22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants