Commit e36a604
[BUGFIX] Preserve barrel side effects when rewriting deep imports
The no-barrel-imports rule rewrites `import { x } from 'BARREL'` to
deep paths like `import { x } from 'BARREL/lib/foo'` for tree-shaking.
But when the barrel itself has top-level side effects (e.g.
`import './lib/bootstrap';` in @glimmer/runtime/index.ts, or the
`globalThis` registration check in @glimmer/validator/index.ts), those
side effects are skipped — the barrel is never loaded.
Concrete failure: @glimmer/runtime/index.ts pulls in bootstrap.ts as
a side-effect import. bootstrap.ts then imports
./compiled/opcodes/{component,content,dom,debugger,expressions,vm,lists},
each of which calls APPEND_OPCODES.add(...) at module-load to register
opcode handlers. Without bootstrap, AppendOpcodes.evaluateOpcode[type]
is null at render time → "Cannot read properties of null (reading
'syscall')" in the smoke tests.
The rule now:
1. Detects whether a barrel has top-level side effects (any
non-export, non-pure-type, non-`declare` statement, or any
side-effect-only import).
2. When rewriting away from such a barrel, prepends a side-effect-only
`import 'BARREL';` to the rewritten output. Modules are cached, so
this is idempotent; bundlers will tree-shake the named exports and
leave only the side effects, which is exactly what we want.
3. Skips this for `import type` / `export type` (no runtime).
Side-effect detection caught and preserved three barrels we'd
otherwise have silently broken: @glimmer/runtime (opcode bootstrap),
@glimmer/validator (duplicate-package guard), and @ember/object
(EmberObject extends CoreObject.extend(Observable) at top level).
The Fix commit's manual one-off patches in @glimmer/debug and
@glimmer/opcode-compiler aren't needed anymore — the rule now handles
the IS_COMPILABLE_TEMPLATE type/value distinction correctly via its
existing isType tracking.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 753eba9 commit e36a604
70 files changed
Lines changed: 154 additions & 6 deletions
File tree
- eslint-rules
- packages
- @ember
- -internals
- glimmer/lib
- component-managers
- components
- helpers
- syntax
- utils
- views
- metal/lib
- runtime/lib/mixins
- views/lib/mixins
- application
- array
- component
- controller
- debug
- engine
- helper
- modifier
- object
- lib/computed
- reactive
- routing
- utils/lib
- @glimmer
- manager/lib
- public
- util
- node/lib
- reference/lib
- runtime/lib
- compiled/opcodes
- helpers
- modifiers
- vm
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
106 | 130 | | |
107 | 131 | | |
108 | 132 | | |
109 | 133 | | |
| 134 | + | |
110 | 135 | | |
111 | 136 | | |
112 | 137 | | |
113 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
114 | 144 | | |
115 | 145 | | |
116 | 146 | | |
| |||
402 | 432 | | |
403 | 433 | | |
404 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
405 | 452 | | |
406 | 453 | | |
407 | 454 | | |
| |||
492 | 539 | | |
493 | 540 | | |
494 | 541 | | |
495 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
496 | 552 | | |
497 | | - | |
498 | | - | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
499 | 557 | | |
500 | 558 | | |
501 | 559 | | |
| |||
564 | 622 | | |
565 | 623 | | |
566 | 624 | | |
567 | | - | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
568 | 631 | | |
569 | | - | |
570 | | - | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
571 | 636 | | |
572 | 637 | | |
573 | 638 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
0 commit comments