Skip to content

fix(cable_install): pin firebase, and stop re-adding firestore.rules - #17

Merged
mattdrees merged 1 commit into
mainfrom
feat/cable-install-pins
Jul 30, 2026
Merged

mattdrees merged 1 commit into
mainfrom
feat/cable-install-pins

Conversation

@mattdrees

Copy link
Copy Markdown
Member

Closes #12.

1. The pins

0.5.0 stopped vendoring the controller, and the three Firebase pins had been riding along with the vendored file. So an app following the new README from scratch got a registered controller whose import … from "firebase/app" resolved to nothing — the module throws on load. Loud, unlike #9, but broken at install.

cable_install now appends them to config/importmap.rb:

pin "firebase/app", to: "https://www.gstatic.com/firebasejs/12.0.0/firebase-app.js", preload: false
pin "firebase/auth", to: "https://www.gstatic.com/firebasejs/12.0.0/firebase-auth.js", preload: false
pin "firebase/firestore", to: "https://www.gstatic.com/firebasejs/12.0.0/firebase-firestore.js", preload: false

Still the app's file, not an engine pin, so the app keeps control of the Firebase SDK version — the issue's reason for leaving them app-side holds. Idempotent, and it says so plainly when there's no config/importmap.rb (esbuild apps). Listed in the README too, for anyone not using importmap.

2. The rules

--rules now, opt-in. I checked the duplication claim: cru-terraform-modules/applications/solid-gcp/firestore.rules.tftpl is byte-identical to the gem's template except ${collection} where the template hardcodes the default — so for any app on the default collection they really are the same file, and the app's copy is reference material that only looks deployable. Went with inverting rather than --skip-rules because re-running the generator is now the supported upgrade path and should be idempotent for the common case, which at CruGlobal is terraform owning the ruleset.

3. A comment that was wrong

While copying the dummy's pin comment I noticed it claims preload: false means "the cable client only loads them when a stream element is on the page." It doesn't: controllers/index.js imports the controller at boot, so the firebase modules load with it on every page of a cable app; preload: false only keeps them out of the modulepreload set. Comment corrected in both places rather than propagated.

Worth a follow-up if that lazy behavior is actually wanted: the controller would need a dynamic import() inside connect(). That's a real change to the connect path (and to emulator-connect ordering), so I left it alone here. It would also mean non-cable pages stop paying for the SDK.

Tests

Five added to the generator test — pins written, pins not duplicated on re-run, missing-importmap message, no rules by default, --rules writes the starter — and the two existing tests updated for the new default. Gem 125 runs / 320 assertions, dummy 13 runs, system-with-emulators 3 runs (1 credential-gated skip), all green.

Not done here

No version bump; entries under [Unreleased]. I'll cut v0.5.1 after this merges.

🤖 Generated with Claude Code

Both found pre-flighting cru-bot's 0.5.0 upgrade (#12).

The generator registered a controller whose `import ... from "firebase/app"`
had nothing to resolve against: those three pins live in the app's importmap,
and 0.5.0 removed the vendoring step that used to bring them along. Following
the README from scratch produced a module that throws on load. The generator now
writes them (still app-side, so the app owns the SDK version), and the README
lists them for apps that don't use importmap.

firestore.rules is now opt-in (--rules). The cru-terraform solid-gcp module
renders and releases that ruleset -- its template is this file modulo
${collection} -- so a copy in the app is a second source of truth nobody
deploys, and 0.5.0 made re-running the generator the supported upgrade path,
which kept re-adding the file apps had deleted on purpose.

Also drops the claim that preload: false makes the firebase modules load only on
pages with a stream element. index.js imports the controller at boot, so they
load with it; preload: false only keeps them out of the modulepreload set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mattdrees
mattdrees merged commit 170462c into main Jul 30, 2026
3 checks passed
@mattdrees
mattdrees deleted the feat/cable-install-pins branch July 30, 2026 20:45
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.

cable_install: copy_rules re-adds firestore.rules that terraform-managed apps deliberately delete; README omits the app-side firebase pins

1 participant