babel-preset-expo 54.1.0-canary-20260119-70f7c28 → 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.
- package/build/expo-router-plugin.js +20 -16
- package/package.json +3 -3
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
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.
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
}
|