Skip to content

gxt: a precompiled compat app ships no template compiler - #35

Merged
lifeart merged 2 commits into
glimmer-next-freshfrom
gxt-compat-precompiled
Nov 19, 2026
Merged

lifeart merged 2 commits into
glimmer-next-freshfrom
gxt-compat-precompiled

Conversation

@lifeart

@lifeart lifeart commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

A compat app (EMBER_RENDER_BACKEND=gxt) that compiles no template at runtime no longer ships a template compiler. Needs @lifeart/gxt 0.0.89 (the previous change of this stack).

Ember's own templates compile at build time

  • The module-level precompileTemplate(…) calls of the route managers (classic outlet, classic manager, root outlet) and of <LinkTo>, <Input> and <Textarea> ran the gxt runtime compiler when their modules loaded. The compat vite pipeline and the compat rollup dist now compile them with the gxt compiler, under the flags of the compat runtime compile (COMPAT_TEMPLATE_FLAGS, scripts/gxt-alias-map.mjs), through 0.0.89's precompileTemplate plugin option. Compat precompileTemplate(maker, options) makes the template on its first render, with the call's scope read then.
  • The three templates the compat backend compiled as it rendered (<ember-outlet />, a wrapper invocation per route manager, an invocation per build-time component resolved by name) are gxt-backend/templates.gts, which takes the wrapper or the invoker through its lexical scope.
  • The compat dist used to precompile Ember's own templates to Glimmer wire format, which the compat backend does not render; babel-plugin-ember-template-compilation no longer runs for it. A compiled module sees Ember's $_tag / $_maybeHelper / $_dc wrappers of the gxt runtime, as an app's templates do.
  • An app's own templates keep the app flags.

The template compiler leaves a precompiled app

  • The render layer reads the compiler through a seam. The runtime symbol table and setupGlobalScope come from 0.0.89's compiler-free @lifeart/gxt/runtime-scope.
  • The entries an app compiles templates through at runtime install the compiler: the published @ember/template-compilation, @ember/template-compiler, @ember/template-compiler/runtime and ember-template-compiler. Each installs it when it loads and from each export that compiles, so a bundler that drops what an unlisted module does on load still keeps it.
  • A template that reaches runtime compilation without a compiler throws, naming those entries.
  • scripts/bundle-modern-app.mjs --assert-no-runtime-compiler fails a precompiled app whose bundle holds a template compiler module: gxt's compiler, @glimmer/syntax, @handlebars/parser, simple-html-tokenizer. The modern-app job gates the compat strict app with it, and boots the compat loose app, which compiles its templates at runtime through the published entry.

Verification

The checks of this PR, and GXT Full dispatched on its head, all against the npm @lifeart/gxt 0.0.89:

suite result run
GXT Full baseline gate OK, 10,250 / 10,482 pass across 1,065 modules, no new failures, none fixed 44477570786
GXT native baseline gate OK, 7,204 / 7,216 pass across 684 modules, no new failures, none fixed; the compat strict app built from source boots 17/17 and --assert-no-runtime-compiler passes (271 source modules); the compat loose app boots 17/17; the native apps are unchanged; package consumer 15/15 44477554401
GXT Smoke contract OK (@lifeart/gxt/runtime-scope among the entries), 4 shards OK 44477554279
dual build the classic dist is byte-identical to the base (diff -rq, 290 files); the compat and native dists are within budget 44477554379
CI 64 jobs passed; "Perf script still works" failed because it compares against origin/main, which this fork does not have 44477554416

Bytes, brotli, against the previous change of this stack (44477546646, 44477546833):

before this branch
compat strict app built from source 224,575 164,582 (−59,993, −26.7%)
compat loose app built from source (compiles its templates at runtime) — 224,856
compat dist, prod (whole tree) 249,552 250,395 (+843: the entry facades, the install module and the build-time templates arrive, Ember's wire-format templates leave)
gxt-native dist, prod 110,094 110,094
gxt-native strict / loose / lists apps 74,559 / 74,846 / 74,431 74,559 / 74,846 / 74,431

The compat strict app no longer carries gxt's compiler (131,630 B minified), @handlebars/parser and simple-html-tokenizer (73,511) or @glimmer/syntax (47,663).

🤖 Generated with Claude Code

lifeart and others added 2 commits November 19, 2026 10:08
…time

A compat app built from source compiled Ember's own templates at runtime: the
module-level `precompileTemplate(…)` calls of the route managers (classic
outlet, classic manager, root outlet), and of LinkTo, Input and Textarea, ran
the gxt runtime compiler when their modules loaded, and the compat backend
compiled three templates as it rendered: `<ember-outlet />`, a wrapper
invocation per route manager, and an invocation per build-time component
resolved by name. The compat rollup dist precompiled the module-level ones to
Glimmer wire format instead, which the compat backend does not render.

The compat vite pipeline and the compat rollup dist now compile them with the
gxt compiler, under the flags of the compat runtime compile
(COMPAT_TEMPLATE_FLAGS, scripts/gxt-alias-map.mjs), and the compat dist skips
the classic precompile pass:
- a `precompileTemplate` call site of an Ember module is compiled with gxt's
  `precompileTemplate` option: its template string becomes a template maker,
  and compat `precompileTemplate(maker, options)` makes the template on its
  first render, with the call's `scope` read then, and renders it as a
  runtime-compiled template renders gxt's own template function;
- the three synthesized templates are gxt-backend/templates.gts, which takes
  the outlet wrapper or the build-time component's invoker through its lexical
  scope; `{{outlet}}`'s host component is its `<ember-outlet />` template;
- a compiled module sees Ember's `$_tag` / `$_maybeHelper` / `$_dc` wrappers of
  the gxt runtime, as an app's templates do (the vite redirect; in the rollup
  dist a facade module).

An app's own templates keep the app flags. Ember modules that are not
templates, the tests and the test helpers are compiled as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The compat render layer (compile.ts) imported the gxt runtime compiler at
module init, so every compat app carried it, with `@glimmer/syntax` and the
Handlebars parser, although a precompiled app compiles no template at runtime
now that Ember's own templates compile at build time.

The render layer reads the compiler through a seam. The entries an app
compiles templates through at runtime install it: the published
`@ember/template-compilation` (Ember's own modules import the render layer
itself, the `shim` of the alias table), `@ember/template-compiler`,
`@ember/template-compiler/runtime` and `ember-template-compiler`. Each installs
it when it loads and from each export that compiles, so a bundler that leaves
out what an unlisted module does on load still keeps it. The runtime symbol
table and `setupGlobalScope` come from gxt's compiler-free
`@lifeart/gxt/runtime-scope`. A template that reaches runtime compilation
without a compiler loaded throws, naming the entries.

The compat app built from source resolves `@ember/template-compilation` as the
dist does. `--assert-no-runtime-compiler` fails a precompiled app whose
closure holds a template compiler module (gxt's compiler, `@glimmer/syntax`,
`@handlebars/parser`, `simple-html-tokenizer`); the modern-app job gates the
compat strict app with it, and boots the compat loose app, which compiles its
templates at runtime through the published entry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown

📊 Size report

Tarball size — 1.2 MB → 1.2 MB

dist/dev   No changes

File Before (Size / Brotli) After (Size / Brotli)
./packages/shared-chunks/api-{hash}.js 27 kB / 6.1 kB -61.4%↓10.4 kB / -60.7%↓2.4 kB
Total (Includes all files) 2.2 MB / 523.1 kB 2.2 MB / 523.1 kB

dist/prod   No changes

File Before (Size / Brotli) After (Size / Brotli)
./packages/shared-chunks/cache-{hash}.js 8 kB / 2 kB -92.3%↓619 B / -88%↓234 B
Total (Includes all files) 1.2 MB / 278.2 kB 1.2 MB / 278.2 kB

smoke-tests/v2-app-template/dist   No changes

File Before (Size / Brotli) After (Size / Brotli)
Total (Includes all files) 361.2 kB / 97.5 kB 361.2 kB / 97.5 kB

smoke-tests/v2-app-hello-world-template/dist   No changes

File Before (Size / Brotli) After (Size / Brotli)
Total (Includes all files) 129.7 kB / 35.5 kB 129.7 kB / 35.5 kB

🤖 This report was automatically generated by wyvox/pkg-size

@lifeart
lifeart changed the base branch from gxt-use-0089 to glimmer-next-fresh November 19, 2026 12:10
@lifeart
lifeart merged commit 2063496 into glimmer-next-fresh Nov 19, 2026
90 of 91 checks passed
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