Skip to content

Fix swapped jsx runtime __source and __self arguments#3459

Merged
marvinhagemeister merged 1 commit into
masterfrom
fix-jsxDev-source
Feb 19, 2022
Merged

Fix swapped jsx runtime __source and __self arguments#3459
marvinhagemeister merged 1 commit into
masterfrom
fix-jsxDev-source

Conversation

@marvinhagemeister

@marvinhagemeister marvinhagemeister commented Feb 19, 2022

Copy link
Copy Markdown
Member

While working on preactjs/preset-vite#40 I noticed that our argument order to jsxDEV differs from the argument order babel transpiles to. There the __source argument comes last and the __source is before that. Basically the other way round than what we have.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 99.626% when pulling 28ce61c on fix-jsxDev-source into 77c6243 on master.

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 42.2 kB

ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.46 kB 0 B
compat/dist/compat.module.js 3.45 kB 0 B
compat/dist/compat.umd.js 3.51 kB 0 B
debug/dist/debug.js 2.99 kB 0 B
debug/dist/debug.module.js 2.98 kB 0 B
debug/dist/debug.umd.js 3.07 kB 0 B
devtools/dist/devtools.js 231 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 307 B 0 B
dist/preact.js 3.97 kB 0 B
dist/preact.min.js 4 kB 0 B
dist/preact.module.js 3.99 kB 0 B
dist/preact.umd.js 4.04 kB 0 B
hooks/dist/hooks.js 1.15 kB 0 B
hooks/dist/hooks.module.js 1.17 kB 0 B
hooks/dist/hooks.umd.js 1.23 kB 0 B
jsx-runtime/dist/jsxRuntime.js 317 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 327 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 395 B 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

@marvinhagemeister marvinhagemeister merged commit df2dbd8 into master Feb 19, 2022
@marvinhagemeister marvinhagemeister deleted the fix-jsxDev-source branch February 19, 2022 21:30
JoviDeCroock pushed a commit that referenced this pull request Feb 3, 2023
* There was a parameter missing (`isStaticChildren: boolean`), which is not useful\*,
  but is still being passed
* Fix order of `source` and `self` again (incorrectly introduced in GH-3459)
* Fix some (internal JSDoc) types for these parameters

My guess is that the previous PR “fixed” the earlier problem because `self` isn’t used, so by
calling `isStaticChildren` “`self`”, a bug went away.

The source for where this `jsxDEV` call is generated in Babel is here:
<https://github.com/babel/babel/blob/3952486/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts#L506-L508>.
The React RFC for the transform that mentions the dev runtime is here:
<https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#dev-only-transforms>

\* `isStaticChildren` is the same as whether `jsxs` would be used, instead of `jsx`.
Which is also whether there are 2 or more children passed:

*   `<a />` -> `jsx('a', {})`
*   `<a>b</a>` -> `jsx('a', {children: 'b'})`
*   `<a>{1}{2}</a>` -> `jsxs('a', {children: [1, 2]})`

Related-to: GH-3459.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants