Skip to content

Add an experimental gjs|codegen format: templates compiled straight t… - #2287

Draft
NullVoxPopuli wants to merge 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:nvp/codegen-gjs-flavor
Draft

NullVoxPopuli wants to merge 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:nvp/codegen-gjs-flavor

Conversation

@NullVoxPopuli

Copy link
Copy Markdown
Owner

…o DOM ops

Adds a codegen flavor to the gjs compiler. Instead of compiling s to the wire format (and then to VM bytecode at runtime), the templates are compiled directly to JavaScript that builds and updates DOM, using a small runtime (@glimmer/dom).

The compiler and runtime are vendored from an ember.js branch: https://github.com/NullVoxPopuli-ai-agent/ember.js/tree/claude/gallant-heisenberg-aovzyr

  • repl-sdk: gjs.codegen config, sharing the gjs pipeline, but with the codegen babel plugin, and rendering with @glimmer/dom
  • ember-repl: provides @glimmer/dom to compiled code
  • repl app: 'Glimmer JS (codegen, experimental)' format + a demo

Claude-Session: https://claude.ai/code/session_01H2cNyDMVxZb1xQB6oCzX89

…o DOM ops

Adds a `codegen` flavor to the gjs compiler. Instead of compiling
<template>s to the wire format (and then to VM bytecode at runtime), the
templates are compiled directly to JavaScript that builds and updates
DOM, using a small runtime (`@glimmer/dom`).

The compiler and runtime are vendored from an ember.js branch:
https://github.com/NullVoxPopuli-ai-agent/ember.js/tree/claude/gallant-heisenberg-aovzyr

- repl-sdk: `gjs.codegen` config, sharing the gjs pipeline, but with the
  codegen babel plugin, and rendering with @glimmer/dom
- ember-repl: provides `@glimmer/dom` to compiled code
- repl app: 'Glimmer JS (codegen, experimental)' format + a demo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2cNyDMVxZb1xQB6oCzX89
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Project Preview URL1 Manage
Limber https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev on Cloudflare
Tutorial https://nvp-codegen-gjs-flavor.limber-glimmer-tutorial.pages.dev on Cloudflare

Logs

Footnotes

  1. if these branch preview links are not working, please check the logs for the commit-based preview link. There is a character limit of 28 for the branch subdomain, as well as some other heuristics, described here for the sake of implementation ease in deploy-preview.yml, that algo has been omitted. The URLs are logged in the wrangler output, but it's hard to get outputs from a matrix job. ↩

Vendors @glimmer/dom and the compiler from emberjs/ember.js#21649:

- compile with `vmInterop`, so compiled templates can render components
  that only have a VM template (e.g. from addons), and the other way around
- `@glimmer/dom/vm` is a known module (the VM interop runtime)
- allowed globals (RFC 1070) resolve in compiled templates
- the demo renders ember-primitives' <ExternalLink> from a compiled template

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2cNyDMVxZb1xQB6oCzX89
@NullVoxPopuli

Copy link
Copy Markdown
Owner Author

Count:

import { clone as _clone, html as _html, at as _at, content as _content, get as _get, listen as _listen } from /*"@glimmer/dom"*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/190a098e-aaca-4511-8cf2-3e3dcf49710a';
import { template as _template, setTemplate as _setTemplate } from /*"@glimmer/dom/vm"*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/55ca1836-bc27-4f34-abe1-e39935d3307f';
const $_0_t2 = _html("<p>You have clicked the button <!> times.</p>\n\n<button type=\"button\">Click</button>");
import Component from /*'@glimmer/component'*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/b77d5391-da1e-4779-a569-0b244523d07c';
import { tracked } from /*'@glimmer/tracking'*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/62ba06ac-9fe4-4a2d-8221-c4d4c2d23003';
import { on } from /*'@ember/modifier'*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/c6d78410-ddf1-4133-89ec-6c48eca9b3bc';
import { g, i } from /*"decorator-transforms/runtime-esm"*/'blob:https://nvp-codegen-gjs-flavor.limber-glimdown.pages.dev/14686cdd-3aa5-464e-9221-35a1f369de76';
export default class HelloWorld extends Component {
  static {
    g(this.prototype, "count", [tracked], function () {
      return 0;
    });
  }
  #count = (i(this, "count"), void 0);
  increment = () => this.count += 1;
  static {
    _setTemplate(this, _template(($_b, $_ctx) => {
      const $_s = $_ctx.self,
        $_a = $_ctx.args;
      const $_0_r1 = _clone($_b, $_0_t2);
      const $_0_n3 = _at($_0_r1, 0, 1);
      const $_0_n4 = _at($_0_r1, 2);
      _content($_b, $_0_n3, () => _get($_s, "count"), 0);
      _listen($_b, $_0_n4, "click", () => _get($_s, "increment"));
      return $_0_r1;
    }));
  }
}
//# sourceURL=file:///src/index.gjs?v=4

This branch has not been deployed

No deployments
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