While upgrading to Expo SDK 53, our mobile app failed to load on web with this error:
Cannot destructure property '__extends' of '_tslib.default' as it is undefined
đ§Š Root Cause
â
Fix
Exclude .mjs from Metro:
jsCopyEditconfig.resolver.sourceExts = config.resolver.sourceExts.filter(
(ext) => ext !== 'mjs'
);
Alias tslib to the proper ES6 version:
config.resolver.extraNodeModules = {
tslib: require.resolve('tslib/tslib.es6.js'),
};
Optional:
If you locate any path like import ... from "../tslib.js" in node_modules/framer-motion, change it to. import ... from "../tslib.es6.js";
đ Conclusion
This issue is a perfect example of how minor mismatches between module types (.mjs vs .js) and bundlers like Metro can silently break your app â especially when using cross-platform libraries like framer-motion. If you're building for both mobile and web using Expo SDK 53 or higher, it's important to proactively patch tslib usage and keep an eye on how Metro resolves modules.
By tweaking your Metro config and properly aliasing tslib, you can get your app running on all platforms smoothly again.