Skip to content

Serve base date/day and date/month modules from the host bundle - #6087

Open
backspace wants to merge 2 commits into
mainfrom
cs-12937-bundle-cardstackbase-modules-into-the-host-so-base-imports
Open

Serve base date/day and date/month modules from the host bundle#6087
backspace wants to merge 2 commits into
mainfrom
cs-12937-bundle-cardstackbase-modules-into-the-host-so-base-imports

Conversation

@backspace

Copy link
Copy Markdown
Contributor

Summary

First step toward shipping @cardstack/base inside the host build. Two base modules, date/day and date/month, are now served from the host bundle: shimExternals registers each with virtualNetwork.shimAsyncModule({ id, resolve: () => import(...) }), the same mechanism that already serves runtime-common and boxel-ui to card code. The lazy import() lets Vite emit each module as its own chunk, so a loader import of either identifier is answered from the bundle rather than a fetch of realm-server-transpiled source.

Supporting changes:

  • The host test helper (tests/helpers/base-realm.ts) imports DayField and MonthField statically instead of through loader.import, so tests exercise the bundled modules.
  • A Vite alias maps @cardstack/boxel-host/tools/* and @cardstack/boxel-host/commands/* to app/tools/, mirroring the virtual network's runtime shim, so a bundled base module that imports host tools resolves them at build time.

One commit per converted module, so the pattern for the next ones is visible in the diff.

What CI is validating

While only some base modules are bundled, a bundled module's ../card-api import is bundled with it, while the rest of the host still loads card-api through the loader. The Integration | date-time fields tests build a card through the loader's card-api with the bundled DayField and MonthField as field types, which is the interaction to watch. The development build succeeds and emits day and month chunks; the test suite has not been run locally.

Next

Widen from per-module entries to a @cardstack/base/ prefix shim with the same lazy import(), so every base module is served from the bundle and card-api has one identity.

🤖 Generated with Claude Code

backspace and others added 2 commits September 10, 2026 22:07
The virtual network's shimAsyncModule resolves the module through a lazy
import(), so Vite emits it as its own chunk and a loader import of
`@cardstack/base/date/day` is answered from the bundle instead of a fetch
of realm-server-transpiled source. The host test helper imports DayField
statically for the same reason.

Base modules import host tools as `@cardstack/boxel-host/tools/*`, which
the virtual network shims at runtime; the Vite alias gives the bundler the
same mapping so a bundled base module resolves them too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Same shape as date/day: a lazy shimAsyncModule entry and a static import
in the host test helper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-11T02:13:31.730249Z 5d86c7e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   1h 59m 52s ⏱️
4 739 tests 4 725 ✅ 14 💤 0 ❌
4 754 runs  4 740 ✅ 14 💤 0 ❌

Results for commit 5d86c7e.

Realm Server Test Results

    1 files    210 suites   1h 12m 8s ⏱️
2 764 tests 2 764 ✅ 0 💤 0 ❌
2 803 runs  2 803 ✅ 0 💤 0 ❌

Results for commit 5d86c7e.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d86c7e5b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +245 to +247
virtualNetwork.shimAsyncModule({
id: '@cardstack/base/date/day',
resolve: () => import('@cardstack/base/date/day'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register base shims before the base-realm import map

In NetworkService.configureVirtualNetwork, the @cardstack/base/ realm mapping is installed before shimExternals, so registering either of these shims resolves its ID to the real base-realm URL. PackageShimHandler.handle only considers requests under PACKAGES_FAKE_ORIGIN, meaning loader imports of these IDs bypass the resolver and continue fetching the realm-server-transpiled modules; the new chunks therefore provide no offline or network-independent fallback. Register these shims before that realm import map or update the handler to serve mapped realm URLs.

Useful? React with 👍 / 👎.

Comment on lines +41 to +42
export { default as DayField } from '@cardstack/base/date/day';
export { default as MonthField } from '@cardstack/base/date/month';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep host test base imports behind the loader

When the date-time tests request DayField or MonthField, these static re-exports are evaluated directly by the host build rather than via loader.import, so the tests no longer exercise either newly added virtual-network shim and can pass even when those shims fall through to the realm server. This is also a host-side static value import from the base realm, which the repository explicitly requires to remain loader-mediated.

AGENTS.md reference: AGENTS.md:L235-L237

Useful? React with 👍 / 👎.

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.

1 participant