Commit fb0e583
[BUGFIX] Trigger glimmer opcode bootstrap from the VM, not the barrel
The smoke tests on #21350 fail with "Cannot read properties of null
(reading 'syscall')" in `AppendOpcodes.evaluate`. Cause: the lint
autofix replaced barrel imports of `@glimmer/runtime` with deep paths
(`@glimmer/runtime/lib/...`), so nothing pulled in the package index.
The index's `import './lib/bootstrap';` was the only thing loading the
opcode handler files (each `lib/compiled/opcodes/*.ts` registers via
top-level `APPEND_OPCODES.add(...)`), so 28 of 90 handlers stayed
unregistered.
Fix: own the bootstrap from the file that actually consumes registered
handlers — `lib/vm/low-level.ts`, where `evaluateSyscall` calls
`APPEND_OPCODES.evaluate(...)`. Any deep-import path that uses the VM
(directly or transitively) now triggers bootstrap; consumers that
don't need the VM don't pay for opcode handlers in their bundle.
Verified by counting top-level `APPEND_OPCODES.add(...)` calls in
`dist/dev`:
origin/main: 90 in a chunk loaded by everyone
nvp/remove-barrel-imports: 62 loaded + 28 trapped in the unused
`@glimmer/runtime/index.js`
this commit: 90 reachable from
`@ember/-internals/glimmer/index.js`
Note for reviewers: the validator duplicate-package guard in
`@glimmer/validator/index.ts` and the `class EmberObject extends
CoreObject.extend(Observable)` extension in `@ember/object/index.ts`
are also barrel-only side effects. EmberObject's case is handled
naturally — `import EmberObject from '@ember/object'` is a default
import, which the lint rule's `kept` mechanism preserves on the
barrel. The validator guard becomes dormant under deep imports; if
that's a concern, move the registration check into a shared leaf
module (e.g. `lib/meta.ts`) in a follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 753eba9 commit fb0e583
2 files changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 1 | | |
7 | 2 | | |
8 | 3 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
0 commit comments