Skip to content

Commit 11d5481

Browse files
NullVoxPopuliclaude
andcommitted
Replace Handlebars parser with Peggy grammar for @glimmer/syntax
Inlines the former @handlebars/parser package into @glimmer/syntax and replaces the Jison-generated parser with a Peggy grammar that produces ASTv1 nodes directly. Drops the runtime simple-html-tokenizer dependency and deletes the separate handlebars-node-visitors pipeline. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 3a55a1e commit 11d5481

43 files changed

Lines changed: 2240 additions & 6426 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-jobs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
run: pnpm build:types
3838
- name: Check internal types
3939
run: pnpm type-check:internals
40-
- name: Check @handlebars/parser types
41-
run: pnpm type-check:handlebars
4240
- name: Check published types
4341
run: pnpm type-check:types
4442

@@ -222,7 +220,7 @@ jobs:
222220
SHOULD_TRANSPILE_FOR_NODE: true
223221
run: pnpm build
224222
- name: test
225-
run: pnpm test:node && pnpm --filter "@handlebars/parser" test
223+
run: pnpm test:node
226224

227225
blueprint-test:
228226
name: Blueprint Tests

.github/workflows/glimmer-syntax-prettier-smoke-test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ on:
1717
- "packages/@glimmer/interfaces/**"
1818
- "packages/@glimmer/util/**"
1919
- "packages/@glimmer/wire-format/**"
20-
- "packages/@handlebars/parser/**"
2120
pull_request:
2221
paths:
2322
- ".github/workflows/glimmer-syntax-prettier-smoke-test.yml"
@@ -27,7 +26,6 @@ on:
2726
- "packages/@glimmer/interfaces/**"
2827
- "packages/@glimmer/util/**"
2928
- "packages/@glimmer/wire-format/**"
30-
- "packages/@handlebars/parser/**"
3129
workflow_dispatch:
3230

3331
permissions:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ npm-debug.log
5555
# couple of the files. Once it is, we can switch this over to just ignoring
5656
# `types/stable` entirely.
5757
types/stable
58+
59+
# Generated Peggy parser (regenerate with: pnpm build:hbs-parser)
60+
packages/@glimmer/syntax/lib/hbs-parser/parser.js

.prettierignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ docs/
77
**/smoke-tests/
88
**/types/
99
**/type-tests/
10-
packages/@handlebars/**/*.l
11-
packages/@handlebars/**/*.yy
1210
CHANGELOG.md
1311
package.json
1412
pnpm-lock.yaml
1513
internal-docs/**/*.md
14+
packages/@glimmer/syntax/lib/hbs-parser/parser.js
15+
packages/@glimmer/syntax/lib/parser/html5-named-char-refs.js
16+
*.peggy
1617
tracerbench-testing/

eslint.config.mjs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export default [
2828
'**/type-tests/',
2929
'internal-docs/guides/**',
3030
'packages/@glimmer-workspace/**',
31-
'packages/@handlebars/parser/lib/parser.js',
32-
'packages/@handlebars/parser/src/**',
31+
'packages/@glimmer/syntax/lib/hbs-parser/parser.js',
3332
'tracerbench-testing/',
3433
],
3534
},
@@ -189,15 +188,6 @@ export default [
189188
'import/namespace': 'off',
190189
},
191190
},
192-
{
193-
files: ['packages/@handlebars/parser/spec/**/*.js'],
194-
195-
languageOptions: {
196-
globals: {
197-
...globals.mocha,
198-
},
199-
},
200-
},
201191
{
202192
files: [
203193
'packages/*/tests/**/*.[jt]s',

internal-docs/guides/development/build-constraints.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ The build system has specific rules for what gets inlined vs treated as external
137137
- TypeScript helper library (`tslib`)
138138

139139
**Always External:**
140-
- `@handlebars/parser`
141140
- `simple-html-tokenizer`
142141
- `babel-plugin-debug-macros`
143142
- Other `@glimmer/*` packages (to avoid duplication)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"actions-up": "pnpm dlx actions-up",
3939
"bench": "node ./bin/benchmark.mjs",
4040
"bench:precompile": "node --expose-gc bin/precompile.bench.mjs",
41+
"build:hbs-parser": "peggy --format es --allowed-start-rules Template,ExpressionWithParamsAndHash packages/@glimmer/syntax/lib/hbs-parser/hbs.peggy -o packages/@glimmer/syntax/lib/hbs-parser/parser.js",
4142
"build:js": "rollup --config",
43+
"prepare": "pnpm build:hbs-parser",
4244
"build:types": "node types/publish.mjs",
4345
"build": "npm-run-all build:*",
4446
"docs": "ember ember-cli-yuidoc",
@@ -56,7 +58,6 @@
5658
"test:browserstack": "node bin/run-browserstack-tests.js",
5759
"test:wip": "vite build --mode development --minify false && testem ci",
5860
"type-check:internals": "tsc --noEmit",
59-
"type-check:handlebars": "tsc --noEmit --project packages/@handlebars/parser/tsconfig.json",
6061
"type-check:types": "tsc --noEmit --project type-tests",
6162
"type-check": "npm-run-all type-check:*"
6263
},
@@ -126,6 +127,7 @@
126127
"mitata": "^1.0.34",
127128
"mocha": "^11.0.0",
128129
"npm-run-all2": "^8.0.0",
130+
"peggy": "^5.1.0",
129131
"prettier": "^3.5.3",
130132
"qunit": "^2.19.4",
131133
"recast": "^0.22.0",

packages/@ember/template-compiler/lib/compile-options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ function buildCompileOptions(_options: EmberPrecompileOptions): EmberPrecompileO
118118
}
119119

120120
if (options.strictMode) {
121-
options.keywords = STRICT_MODE_KEYWORDS;
121+
// Include fn/on as keywords for runtime compilation so the strict mode
122+
// validation pass allows them. The auto-import-builtins plugin will
123+
// rewrite them to __ember_keywords__.fn / __ember_keywords__.on.
124+
options.keywords = [...STRICT_MODE_KEYWORDS, 'fn', 'on'];
122125
}
123126

124127
return options;

0 commit comments

Comments
 (0)