Commit c9a4db9
TC39 decorators: run Symbol.metadata polyfill before decorated classes in all entry styles
The es6 `pure` entry (and any deep import of a decorated class) crashed at
class-definition time with "Cannot convert undefined or null to object" because
`context.metadata` was `void 0`: TypeScript's TC39 emit computes
`_metadata = Symbol.metadata ? ... : void 0` at the top of the class `static {}`
block, so the metadata bag only exists if `Symbol.metadata` was installed BEFORE
the class module evaluated. The polyfill was only imported by `index.ts` (the
barrel), so the `pure` barrel — which eagerly evaluates every decorated FrameGraph
/ node block without importing the polyfill — always threw.
Fix: anchor the polyfill in the decorator infrastructure that every decorated class
already imports. `decorators.functions.ts` now resolves `Symbol.metadata` into an
exported module-load `const MetadataSymbol` (the idempotent `GetMetadataSymbol()`
already performed the polyfill); ES module evaluation order guarantees this runs
before any importing class body. It is a `const` referenced by the retained
decorator helpers so bundlers treating the module as side-effect-free cannot drop
it, and the tree-shaking side-effect detector skips `const X = ...` initializers so
the module stays pure and remains importable from `.pure` modules — no tooling
policy or `sideEffects` allowlist change required. `nodeDecorator.ts` and the smart
filters `editableInPropertyPage` import that symbol, route their metadata reads
through it, and throw an actionable error instead of a cryptic TypeError if the
polyfill somehow did not run.
Fixes the ES6 visualization "pure" scenes and the resulting Playground snapshot
cascade.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent 30e155d commit c9a4db9
3 files changed
Lines changed: 54 additions & 9 deletions
File tree
- packages/dev
- core/src
- Decorators
- Misc
- smartFilters/src/editorUtils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
112 | 122 | | |
113 | 123 | | |
114 | 124 | | |
| |||
139 | 149 | | |
140 | 150 | | |
141 | 151 | | |
142 | | - | |
| 152 | + | |
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
38 | 56 | | |
39 | 57 | | |
40 | 58 | | |
| |||
47 | 65 | | |
48 | 66 | | |
49 | 67 | | |
50 | | - | |
| 68 | + | |
51 | 69 | | |
52 | | - | |
53 | | - | |
| 70 | + | |
| 71 | + | |
54 | 72 | | |
55 | 73 | | |
56 | 74 | | |
57 | 75 | | |
58 | 76 | | |
59 | 77 | | |
60 | | - | |
| 78 | + | |
61 | 79 | | |
62 | 80 | | |
63 | 81 | | |
| |||
66 | 84 | | |
67 | 85 | | |
68 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
69 | 94 | | |
70 | 95 | | |
71 | 96 | | |
| |||
90 | 115 | | |
91 | 116 | | |
92 | 117 | | |
93 | | - | |
| 118 | + | |
94 | 119 | | |
95 | 120 | | |
96 | 121 | | |
| |||
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
| |||
136 | 146 | | |
137 | 147 | | |
138 | 148 | | |
139 | | - | |
| 149 | + | |
140 | 150 | | |
141 | 151 | | |
142 | 152 | | |
| |||
0 commit comments