babel-preset-expo 13.2.4 → 13.2.5

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.
@@ -9,14 +9,15 @@ exports.expoRouterBabelPlugin = expoRouterBabelPlugin;
9
9
  */
10
10
  const core_1 = require("@babel/core");
11
11
  const node_path_1 = __importDefault(require("node:path"));
12
- const resolve_from_1 = __importDefault(require("resolve-from"));
13
12
  const common_1 = require("./common");
14
13
  const debug = require('debug')('expo:babel:router');
15
- function getExpoRouterAppRoot(projectRoot, appFolder) {
16
- // TODO: We should have cache invalidation if the expo-router/entry file location changes.
17
- const routerEntry = (0, resolve_from_1.default)(projectRoot, 'expo-router/entry');
18
- const appRoot = node_path_1.default.relative(node_path_1.default.dirname(routerEntry), appFolder);
19
- debug('routerEntry', routerEntry, appFolder, appRoot);
14
+ function getExpoRouterAppRoot(currentFile, projectRoot, appFolder) {
15
+ // FIXME(@kitten): This is only defaulting to `projectRoot` for the backport. `projectRoot` is wrong here,
16
+ // but was previously used instead of the filename to compute the relative path. We're still keeping it here
17
+ // to avoid a new breaking error/invariant in case the `filename` is missing
18
+ const fromPath = (currentFile && node_path_1.default.dirname(currentFile)) || projectRoot;
19
+ const appRoot = node_path_1.default.relative(fromPath, appFolder);
20
+ debug('getExpoRouterAppRoot', currentFile, appFolder, appRoot);
20
21
  return appRoot;
21
22
  }
22
23
  /**
@@ -58,7 +59,8 @@ function expoRouterBabelPlugin(api) {
58
59
  path.replaceWith(t.stringLiteral(routerAbsoluteRoot));
59
60
  }
60
61
  else if (key.value.startsWith('EXPO_ROUTER_APP_ROOT')) {
61
- path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(projectRoot, routerAbsoluteRoot)));
62
+ const filename = state.filename || state.file.opts.filename;
63
+ path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(filename, projectRoot, routerAbsoluteRoot)));
62
64
  }
63
65
  }
64
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-expo",
3
- "version": "13.2.4",
3
+ "version": "13.2.5",
4
4
  "description": "The Babel preset for Expo projects",
5
5
  "main": "build/index.js",
6
6
  "files": [
@@ -79,5 +79,5 @@
79
79
  "expo-module-scripts": "^4.1.10",
80
80
  "jest": "^29.2.1"
81
81
  },
82
- "gitHead": "4110196100039dfd537a5eba6be164c1a7c79a44"
82
+ "gitHead": "0ce4dfe84cd156ceab8cd00749bf3f86f0c8d12d"
83
83
  }