Lagg till custom Metro-resolver for .js->ts samt react-native-web for SDK 54

This commit is contained in:
Sven (AAMOS AI)
2026-08-06 20:51:30 +07:00
parent a837283a2e
commit 8e6b780480
3 changed files with 232 additions and 63 deletions
+20
View File
@@ -15,4 +15,24 @@ config.resolver.nodeModulesPaths = [
path.resolve(workspaceRoot, "node_modules"),
];
// SDK 54 Metro does not automatically strip `.js` extensions from relative
// ESM imports (our workspace packages use `./foo.js` to point at `.ts` source).
// Try the specifier without `.js` first, then fall back to the default resolver.
const defaultResolveRequest = config.resolver.resolveRequest;
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (
(moduleName.startsWith("./") || moduleName.startsWith("../")) &&
moduleName.endsWith(".js")
) {
try {
return context.resolveRequest(context, moduleName.slice(0, -3), platform);
} catch {}
}
return (defaultResolveRequest ?? context.resolveRequest)(
context,
moduleName,
platform,
);
};
module.exports = config;
+2 -1
View File
@@ -40,11 +40,12 @@
"react-native-reanimated": "4.1.7",
"react-native-safe-area-context": "~5.6.2",
"react-native-screens": "~4.16.0",
"react-native-web": "~0.21.2",
"react-native-worklets": "~0.5.1",
"zustand": "^5.0.0"
},
"devDependencies": {
"@expo/ngrok": "^4.1.3",
"@expo/ngrok": "^4.1.0",
"@types/react": "~19.1.17",
"typescript": "~5.9.3"
},