babel-preset-expo 54.1.0-canary-20260114-d8e19f5 → 54.1.0-canary-20260120-bb71700

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,22 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.expoRouterBabelPlugin = expoRouterBabelPlugin;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
- const resolve_from_1 = __importDefault(require("resolve-from"));
9
8
  const common_1 = require("./common");
10
9
  const debug = require('debug')('expo:babel:router');
11
- // Cache for getExpoRouterAppRoot results (projectRoot -> appRoot)
12
- const appRootCache = new Map();
13
- function getExpoRouterAppRoot(projectRoot, appFolder) {
14
- const cacheKey = `${projectRoot}:${appFolder}`;
15
- const cached = appRootCache.get(cacheKey);
16
- if (cached !== undefined) {
17
- return cached;
18
- }
19
- // TODO: We should have cache invalidation if the expo-router/entry file location changes.
20
- const routerEntry = (0, resolve_from_1.default)(projectRoot, 'expo-router/entry');
21
- const appRoot = node_path_1.default.relative(node_path_1.default.dirname(routerEntry), appFolder);
22
- debug('routerEntry', routerEntry, appFolder, appRoot);
23
- appRootCache.set(cacheKey, appRoot);
10
+ /**
11
+ * Compute the relative path from the current file to the app folder.
12
+ *
13
+ * Previously this was computed relative to `expo-router/entry`, but that breaks
14
+ * when packages are hoisted to unexpected locations (e.g., with Bun in monorepos).
15
+ * By using the actual file being transformed, the relative path is always correct
16
+ * regardless of where the package is installed.
17
+ */
18
+ function getExpoRouterAppRoot(currentFile, appFolder) {
19
+ const appRoot = node_path_1.default.relative(node_path_1.default.dirname(currentFile), appFolder);
20
+ debug('getExpoRouterAppRoot', currentFile, appFolder, appRoot);
24
21
  return appRoot;
25
22
  }
26
23
  /**
@@ -83,8 +80,15 @@ function expoRouterBabelPlugin(api) {
83
80
  case 'EXPO_ROUTER_ABS_APP_ROOT':
84
81
  path.replaceWith(t.stringLiteral(routerAbsoluteRoot));
85
82
  return;
86
- case 'EXPO_ROUTER_APP_ROOT':
87
- path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(state.projectRoot, routerAbsoluteRoot)));
83
+ case 'EXPO_ROUTER_APP_ROOT': {
84
+ // Use the actual file being transformed to compute the relative path.
85
+ // This ensures the path is correct regardless of package hoisting.
86
+ const filename = state.filename || state.file.opts.filename;
87
+ if (!filename) {
88
+ throw new Error('babel-preset-expo: Unable to determine filename for EXPO_ROUTER_APP_ROOT transformation');
89
+ }
90
+ path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(filename, routerAbsoluteRoot)));
91
+ }
88
92
  }
89
93
  },
90
94
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-expo",
3
- "version": "54.1.0-canary-20260114-d8e19f5",
3
+ "version": "54.1.0-canary-20260120-bb71700",
4
4
  "description": "The Babel preset for Expo projects",
5
5
  "main": "build/index.js",
6
6
  "files": [
@@ -43,7 +43,7 @@
43
43
  "peerDependencies": {
44
44
  "@babel/runtime": "^7.20.0",
45
45
  "react-refresh": ">=0.14.0 <1.0.0",
46
- "expo": "55.0.0-canary-20260114-d8e19f5"
46
+ "expo": "55.0.0-canary-20260120-bb71700"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@babel/runtime": {
@@ -81,7 +81,7 @@
81
81
  "@babel/core": "^7.26.0",
82
82
  "@types/babel__core": "^7.20.5",
83
83
  "@expo/metro": "~54.2.0",
84
- "expo-module-scripts": "5.1.0-canary-20260114-d8e19f5",
84
+ "expo-module-scripts": "5.1.0-canary-20260120-bb71700",
85
85
  "jest": "^29.2.1",
86
86
  "react-refresh": "^0.14.2"
87
87
  }