New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove @babel/plugin-transform-destructuring
plugin
#43662
chore: remove @babel/plugin-transform-destructuring
plugin
#43662
Conversation
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Sharing with permission from @tmikov:
|
I noticed today 7 packages that need attention: @babel/plugin-proposal-nullish-coalescing-operator@7.18.6 -> @babel/plugin-transform-nullish-coalescing-operator |
The Expo E2E tests discovered a missing feature in Hermes destructuring implementation: expo/expo#27885 (comment)
Which comes from: try {
} catch ({ message }) {
} We'll just disable the transform when targeting web/server environments, which can be done in expo/expo. |
# Why In RSC, components can be shared between server and client, the client components may contain react hooks which will run on the client but shouldn't run on the server. This PR reduces the errors to only throw when APIs are used and not when they're simply imported. The import errors still run when importing `Component` or `PureComponent`. To fully support shared components, we'll need a follow up PR to "optimize" server components. This should collapse unused hooks so that they don't run, and therefore don't trigger the static error pass. This optimization pass is a bit tricky since we have old babel passes that obfuscate the expected syntax, ref facebook/react-native#43662 # Test Plan - Updated the tests with the expected syntax. --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Summary:
react-native@0.73.6
appears to support destructuring natively. The babel preset only removes the plugin if running Hermes canary, which doesn't seem to be needed anymore.@babel/preset-env
with reasonably modern defaults doesn't apply this transform anymore repl. (This is for web / Node.js support since we reuse the babel preset in Expo CLI).Changelog:
[GENERAL] [BREAKING] - Remove
@babel/plugin-transform-destructuring
transform ([a, b, ...c]
) from all platforms and engines.Test Plan:
code node_modules/@react-native/babel-preset/src/configs/main.js
-> delete plugin).const [index, setIndex, ...foo] = React.useState(0);
to the code to ensure at least one instance of destructuring (there are many throughout the default modules though).npx expo start -c
) on iOS, Android, web, Node.js (Expo Router).jsEngine
in theapp.json
).http://localhost:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.bacon.mar26&transform.routerRoot=app&transform.engine=hermes&transform.bytecode=true
var [index, setIndex, ...foo] = (0, _react.useState)(0);
(modifications primarily coming from@babel/plugin-transform-modules-commonjs
and@babel/plugin-transform-block-scoping
)../ios/Pods/hermes-engine/destroot/bin/hermes ./foo.js
wherefoo.js
contained: