Repository navigation
gxt: a precompiled compat app ships no template compiler - #35
Merged
Merged
Conversation
…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]>
📊 Size reportTarball size — dist/dev No changes
dist/prod No changes
smoke-tests/v2-app-template/dist No changes
smoke-tests/v2-app-hello-world-template/dist No changes
🤖 This report was automatically generated by wyvox/pkg-size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A compat app (
EMBER_RENDER_BACKEND=gxt) that compiles no template at runtime no longer ships a template compiler. Needs@lifeart/gxt0.0.89 (the previous change of this stack).Ember's own templates compile at build time
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'sprecompileTemplateplugin option. CompatprecompileTemplate(maker, options)makes the template on its first render, with the call'sscoperead then.<ember-outlet />, a wrapper invocation per route manager, an invocation per build-time component resolved by name) aregxt-backend/templates.gts, which takes the wrapper or the invoker through its lexical scope.babel-plugin-ember-template-compilationno longer runs for it. A compiled module sees Ember's$_tag/$_maybeHelper/$_dcwrappers of the gxt runtime, as an app's templates do.The template compiler leaves a precompiled app
setupGlobalScopecome from 0.0.89's compiler-free@lifeart/gxt/runtime-scope.@ember/template-compilation,@ember/template-compiler,@ember/template-compiler/runtimeandember-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.scripts/bundle-modern-app.mjs --assert-no-runtime-compilerfails 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/gxt0.0.89:--assert-no-runtime-compilerpasses (271 source modules); the compat loose app boots 17/17; the native apps are unchanged; package consumer 15/15@lifeart/gxt/runtime-scopeamong the entries), 4 shards OKdiff -rq, 290 files); the compat and native dists are within budgetorigin/main, which this fork does not haveBytes, brotli, against the previous change of this stack (44477546646, 44477546833):
The compat strict app no longer carries gxt's compiler (131,630 B minified),
@handlebars/parserandsimple-html-tokenizer(73,511) or@glimmer/syntax(47,663).🤖 Generated with Claude Code