fix(matrix-mobile): add EAS Build pre-install hook for pnpm hoisted mode

pnpm's strict isolated dependency resolution prevents @babel/core from
finding babel-preset-expo and @babel/plugin-transform-react-jsx during
Metro bundling. The pre-install hook creates .npmrc with node-linker=hoisted
at the monorepo root so pnpm uses a flat node_modules on EAS Build.

Also simplified metro.config.js by removing manual monorepo watchFolders
config (handled automatically by expo/metro-config since SDK 52).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-12 19:08:52 +01:00
parent 713f4f7c33
commit 402e135179
2 changed files with 13 additions and 9 deletions

View file

@ -0,0 +1,13 @@
#!/bin/bash
# EAS Build pre-install hook
# Creates .npmrc with node-linker=hoisted at the monorepo root
# so pnpm uses a flat node_modules structure compatible with
# React Native / Metro bundler module resolution.
MONOREPO_ROOT="$EAS_BUILD_WORKINGDIR"
if [ -z "$MONOREPO_ROOT" ]; then
MONOREPO_ROOT=$(cd "$(dirname "$0")/../../../.." && pwd)
fi
echo "node-linker=hoisted" > "$MONOREPO_ROOT/.npmrc"
echo "Created .npmrc with node-linker=hoisted at $MONOREPO_ROOT"

View file

@ -1,6 +1,5 @@
const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');
const path = require('path');
const config = getDefaultConfig(__dirname);
@ -20,12 +19,4 @@ config.resolver.resolveRequest = (context, moduleName, platform) => {
return context.resolveRequest(context, moduleName, platform);
};
// Monorepo workspace support
const monorepoRoot = path.resolve(__dirname, '../../../..');
config.watchFolders = [monorepoRoot];
config.resolver.nodeModulesPaths = [
path.resolve(__dirname, 'node_modules'),
path.resolve(monorepoRoot, 'node_modules'),
];
module.exports = withNativeWind(config, { input: './global.css' });