enable expo experimental tree shaking

This commit is contained in:
Oleksii Bulenok
2026-08-11 13:57:38 +02:00
parent 64bc9672a8
commit d3de1795f7
3 changed files with 27 additions and 1 deletions
+22
View File
@@ -1,3 +1,24 @@
/**
* React Compiler tags generated nodes with loc = Symbol(GeneratedSource),
* which breaks the structuredClone Metro performs on the AST when
* EXPO_UNSTABLE_TREE_SHAKING is enabled. Strip them after all other
* transforms have run.
*/
const stripSymbolLocs = () => ({
post(file) {
file.path.traverse({
enter(path) {
if (typeof path.node.loc === 'symbol') {
path.node.loc = undefined
}
},
})
if (typeof file.ast.program.loc === 'symbol') {
file.ast.program.loc = undefined
}
},
})
/**
* @param {import("@babel/core").ConfigAPI} api
* @returns {import("@babel/core").InputOptions}
@@ -45,6 +66,7 @@ module.exports = function (api) {
: []),
...(api.env('production') ? ['transform-remove-console'] : []),
stripSymbolLocs,
'react-native-worklets/plugin', // NOTE: this plugin MUST be last
],
}