Repository navigation
Commit 93962f9
Export nested make values flat, derived from the signature
Every `make` in a nested module of a file's final signature is also exported
as `A$B$make`, and other modules read it through that name. React Server
Components only pass a client module's top-level exports to the client, so
`<Sidebar.Provider />` no longer reads `.make` from a client reference. Both
sides decide from the signature alone, which replaces `@res.hoistedFunction`
and its `.cmj` table (#8402); see #8901.
Example (rescript):
// Sidebar.res
module Provider = {
@react.component
let make = (~children) => children
}
// Page.res
let page = <Sidebar.Provider> {React.null} </Sidebar.Provider>
Before (js):
// Page.res.js
JsxRuntime.jsx(Sidebar.Provider.make, {children: null})
After (js):
// Sidebar.res.js
let Provider$make = Sidebar$Provider;
export { Provider, Provider$make }
// Page.res.js
JsxRuntime.jsx(Sidebar.Provider$make, {children: null})
Source: After from tests/build_tests/react_ppx/src/nested_component_*.res.js
in this diff. Before is master's fallback for a nested read without a
`.cmj` hoisting entry.
Breaking: `@res.hoistedFunction` is gone; it now reports the unused-attribute
warning 101. Nested functions other than `make` are no longer exported flat.
Consumers read `Lib.A$make` instead of `Lib.A.make`, so test spies or mocks
that replace `make` on the module object no longer intercept those reads.
Review: Why can't a `.resi` edit leave consumers stale, as in #8886? The
flat export set is a function of the signature, so it changes exactly when
the `.cmi` does, and both build systems already rebuild dependents then.
Changing only `Sidebar.res` behind an unchanged `.resi` (a module alias, an
external, a functor application, `include`) kept the `.cmi` byte-identical
and every flat export in a scratch build.
Review: Do the aliases defeat tree-shaking? When the module field holds a
top-level binding, the alias is `let A$B$make = make`. Only fields without
one (a wrapped value such as `Some(make)`, a functor result, an awaited
module) fall back to a property read.
Review: What about name clashes? A flat name already used by a top-level
binding is a compile error, as it was for `@res.hoistedFunction`.
Area: lambda codegen frontend typechecker playground tests
Output: changed programs with nested `make` values gain flat exports and
read them from other modules; 26 committed outputs change, all additive
apart from the rewritten reads, and 3 go with the removed tests
Formatting: unchanged
Formats: cmi
PPX: unchanged
Editor: unchanged
Errors: none, because the new clash error is an inline raise_errorf, outside
the catalog's scope
Tests: +tests/build_tests/react_ppx/src/nested_component_producer.res
+tests/build_tests/react_ppx/src/nested_component_consumer.res
+tests/build_tests/super_errors/fixtures/flat_make_export_collision.res
~tests/tests/src/flat_make_export*.res (from hoisted_function_attr*.res)
~tests/tests/src/import2.res
~tests/build_tests/super_errors/fixtures/warning_101_bs_unused_attribute.res
-tests/build_tests/super_errors/fixtures/hoisted_function_*.res
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GUg1NbeoJMi6t6V89yBWh
Signed-off-by: Christoph Knittel <ck@cca.io>1 parent 5e3cc82 commit 93962f9
83 files changed
Lines changed: 802 additions & 758 deletions
File tree
- changes
- compiler
- core
- ext
- frontend
- jsoo
- ml
- tests
- build_tests
- react_ppx/src
- super_errors
- expected
- fixtures
- gentype_tests/typescript-react-example/src
- ounit_tests
- tests/src
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 | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 48 | | |
59 | 49 | | |
60 | | - | |
61 | 50 | | |
62 | 51 | | |
63 | 52 | | |
64 | 53 | | |
65 | 54 | | |
66 | | - | |
67 | | - | |
| 55 | + | |
68 | 56 | | |
69 | 57 | | |
70 | 58 | | |
| |||
75 | 63 | | |
76 | 64 | | |
77 | 65 | | |
78 | | - | |
79 | 66 | | |
80 | 67 | | |
81 | 68 | | |
| |||
173 | 160 | | |
174 | 161 | | |
175 | 162 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 163 | | |
184 | 164 | | |
185 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 64 | | |
75 | 65 | | |
76 | | - | |
77 | 66 | | |
78 | 67 | | |
79 | 68 | | |
80 | 69 | | |
81 | 70 | | |
82 | 71 | | |
83 | 72 | | |
84 | | - | |
85 | 73 | | |
86 | 74 | | |
87 | 75 | | |
88 | 76 | | |
89 | 77 | | |
90 | 78 | | |
91 | 79 | | |
92 | | - | |
93 | | - | |
94 | 80 | | |
95 | 81 | | |
96 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
268 | 262 | | |
269 | 263 | | |
270 | 264 | | |
| |||
274 | 268 | | |
275 | 269 | | |
276 | 270 | | |
277 | | - | |
| 271 | + | |
278 | 272 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
283 | 277 | | |
284 | 278 | | |
285 | 279 | | |
| |||
1633 | 1627 | | |
1634 | 1628 | | |
1635 | 1629 | | |
1636 | | - | |
1637 | | - | |
| 1630 | + | |
| 1631 | + | |
1638 | 1632 | | |
1639 | 1633 | | |
1640 | | - | |
| 1634 | + | |
1641 | 1635 | | |
1642 | 1636 | | |
1643 | 1637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 109 | | |
115 | 110 | | |
116 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
| |||
0 commit comments