{{post.title}}
+{{post.excerpt}}
+ +diff --git a/.github/workflows/ci-jobs.yml b/.github/workflows/ci-jobs.yml index 0cafa28c79d..716194715cf 100644 --- a/.github/workflows/ci-jobs.yml +++ b/.github/workflows/ci-jobs.yml @@ -37,8 +37,6 @@ jobs: run: pnpm build:types - name: Check internal types run: pnpm type-check:internals - - name: Check @handlebars/parser types - run: pnpm type-check:handlebars - name: Check published types run: pnpm type-check:types @@ -222,7 +220,7 @@ jobs: SHOULD_TRANSPILE_FOR_NODE: true run: pnpm build - name: test - run: pnpm test:node && pnpm --filter "@handlebars/parser" test + run: pnpm test:node blueprint-test: name: Blueprint Tests diff --git a/.github/workflows/glimmer-syntax-prettier-smoke-test.yml b/.github/workflows/glimmer-syntax-prettier-smoke-test.yml index 3b87973841f..391af75c8f9 100644 --- a/.github/workflows/glimmer-syntax-prettier-smoke-test.yml +++ b/.github/workflows/glimmer-syntax-prettier-smoke-test.yml @@ -17,7 +17,6 @@ on: - "packages/@glimmer/interfaces/**" - "packages/@glimmer/util/**" - "packages/@glimmer/wire-format/**" - - "packages/@handlebars/parser/**" pull_request: paths: - ".github/workflows/glimmer-syntax-prettier-smoke-test.yml" @@ -27,7 +26,6 @@ on: - "packages/@glimmer/interfaces/**" - "packages/@glimmer/util/**" - "packages/@glimmer/wire-format/**" - - "packages/@handlebars/parser/**" workflow_dispatch: permissions: @@ -63,6 +61,10 @@ jobs: working-directory: prettier-repo run: yarn add "@glimmer/syntax@file:${{ github.workspace }}/glimmer-syntax.tgz" + - name: Update error snapshots (our error messages differ from Jison's verbose format) + working-directory: prettier-repo + run: yarn jest --updateSnapshot tests/format/handlebars/_errors_/ + - name: Run prettier handlebars tests working-directory: prettier-repo run: yarn jest tests/format/handlebars diff --git a/bench-cli.mjs b/bench-cli.mjs new file mode 100644 index 00000000000..57674d3b176 --- /dev/null +++ b/bench-cli.mjs @@ -0,0 +1,291 @@ +/** + * CLI/build-style benchmark: simulates a real build pass over a project. + * + * IDE benchmark: same template, many iterations (measures JIT-warmed throughput) + * CLI benchmark: many distinct templates, one pass (cold-ish JIT, one-time init cost) + * + * Run: node bench-cli.mjs + */ + +import { join, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const currentDistPath = join(__dirname, 'packages/@glimmer/syntax/dist/es/index.js'); +const prDistPath = '/tmp/pr-21313/packages/@glimmer/syntax/dist/es/index.js'; + +// ─── Realistic template corpus ──────────────────────────────────────────────── +// ~50 distinct templates of varying complexity, simulating a real Ember project. + +const TEMPLATES = [ + `
{{this.description}}
`, + `{{#let (hash name=@name age=@age) as |person|}}{{person.name}}{{/let}}`, + ``, + + `| + {{col.label}} + {{#if (eq this.sortKey col.key)}} + + {{/if}} + | + {{/each}} +
|---|
| {{get row col.key}} | + {{/each}} +
{{@subtitle}}
{{/if}} +{{item.description}}
+ {{/if}} + +\\\\\\
', b.template([element('p', ['body', b.text('\\\\\\')])])); + }); + + test('triple backslash + \\\\{{ in element text (backslashes.hbs)', () => { + astEqual( + '\\\\\\ \\\\{{foo}}
', + b.template([element('p', ['body', b.text('\\\\\\ \\'), b.mustache(b.path('foo'))])]) + ); + }); + + test('plain backslash in attribute value is preserved (backslashes-in-attributes.hbs)', (assert) => { + const ast = parse(''); + const attr = (ast.body[0] as ASTv1.ElementNode).attributes[0] as ASTv1.AttrNode; + assert.strictEqual((attr.value as ASTv1.TextNode).chars, 'backslash \\\\ in an attribute'); + }); + + test('\\{{ in quoted class attribute value (mustache.hbs)', (assert) => { + const ast = parse(''); + const attr = (ast.body[0] as ASTv1.ElementNode).attributes[0] as ASTv1.AttrNode; + assert.strictEqual((attr.value as ASTv1.TextNode).chars, ' bar {{'); + }); + + // Unclosed escape + + test('\\{{ without closing }} emits {{ and following text up to end', () => { + astEqual('\\{{ unclosed', b.template([b.text('{{ unclosed')])); + }); + + test('\\{{ without closing }} stops at < (HTML element boundary)', () => { + astEqual( + '