React Native Babel preset uses a loose plugin to convert imports to commonjs, we're investigating switching to a more standard approach in Expo CLI here https://github.com/expo/expo/pull/30005 which aligns with how Metro is used at Meta.
When running on the kitchen sink, I found that there was an invalid expression in reanimated where it exports null and then destructures null. This error didn't occur previously because the commonjs plugin deferred access to the null object until later.
Before
var _Math = _$$_REQUIRE(_dependencyMap[0]);
// Later ...
_Math.add
This coincidentally didn't throw because the deferred code is never accessed.
After
var add = _$$_REQUIRE(_dependencyMap[0]).add;
This throws because the null is accessed when the module is loaded.
Test plan
Bundle a Metro web project with experimentalImportSupport enabled:
Summary
React Native Babel preset uses a loose plugin to convert imports to commonjs, we're investigating switching to a more standard approach in Expo CLI here https://github.com/expo/expo/pull/30005 which aligns with how Metro is used at Meta.
When running on the kitchen sink, I found that there was an invalid expression in reanimated where it exports null and then destructures null. This error didn't occur previously because the commonjs plugin deferred access to the null object until later.
Before
This coincidentally didn't throw because the deferred code is never accessed.
After
This throws because the
null
is accessed when the module is loaded.Test plan
Bundle a Metro web project with experimentalImportSupport enabled:
Then run
npx serve dist
-> Error was there but not anymore.