@expo/metro-config 0.17.2 → 0.17.4

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.
Files changed (85) hide show
  1. package/build/ExpoMetroConfig.js +239 -366
  2. package/build/ExpoMetroConfig.js.map +1 -1
  3. package/build/babel-core.js +6 -23
  4. package/build/babel-core.js.map +1 -1
  5. package/build/babel-transformer.js +117 -162
  6. package/build/babel-transformer.js.map +1 -1
  7. package/build/customizeFrame.js +84 -78
  8. package/build/customizeFrame.js.map +1 -1
  9. package/build/env.js +23 -37
  10. package/build/env.js.map +1 -1
  11. package/build/file-store.js +13 -21
  12. package/build/file-store.js.map +1 -1
  13. package/build/getModulesPaths.js +31 -48
  14. package/build/getModulesPaths.js.map +1 -1
  15. package/build/getWatchFolders.js +70 -98
  16. package/build/getWatchFolders.js.map +1 -1
  17. package/build/loadBabelConfig.js +30 -49
  18. package/build/loadBabelConfig.js.map +1 -1
  19. package/build/rewriteRequestUrl.js +82 -142
  20. package/build/rewriteRequestUrl.js.map +1 -1
  21. package/build/serializer/debugId.js +23 -22
  22. package/build/serializer/debugId.js.map +1 -1
  23. package/build/serializer/environmentVariableSerializerPlugin.js +90 -101
  24. package/build/serializer/environmentVariableSerializerPlugin.js.map +1 -1
  25. package/build/serializer/exportHermes.js +96 -133
  26. package/build/serializer/exportHermes.js.map +1 -1
  27. package/build/serializer/exportPath.js +18 -35
  28. package/build/serializer/exportPath.js.map +1 -1
  29. package/build/serializer/fork/baseJSBundle.js +124 -147
  30. package/build/serializer/fork/baseJSBundle.js.map +1 -1
  31. package/build/serializer/fork/js.js +81 -116
  32. package/build/serializer/fork/js.js.map +1 -1
  33. package/build/serializer/fork/processModules.js +22 -36
  34. package/build/serializer/fork/processModules.js.map +1 -1
  35. package/build/serializer/getCssDeps.js +64 -95
  36. package/build/serializer/getCssDeps.js.map +1 -1
  37. package/build/serializer/jsOutput.js +6 -16
  38. package/build/serializer/jsOutput.js.map +1 -1
  39. package/build/serializer/serializeChunks.js +406 -483
  40. package/build/serializer/serializeChunks.js.map +1 -1
  41. package/build/serializer/serializerAssets.js +1 -0
  42. package/build/serializer/serializerAssets.js.map +1 -1
  43. package/build/serializer/withExpoSerializers.js +165 -236
  44. package/build/serializer/withExpoSerializers.js.map +1 -1
  45. package/build/transform-worker/asset-transformer.js +21 -44
  46. package/build/transform-worker/asset-transformer.js.map +1 -1
  47. package/build/transform-worker/css-modules.js +57 -84
  48. package/build/transform-worker/css-modules.js.map +1 -1
  49. package/build/transform-worker/css.js +21 -20
  50. package/build/transform-worker/css.js.map +1 -1
  51. package/build/transform-worker/getAssets.js +38 -75
  52. package/build/transform-worker/getAssets.js.map +1 -1
  53. package/build/transform-worker/metro-transform-worker.js +384 -489
  54. package/build/transform-worker/metro-transform-worker.js.map +1 -1
  55. package/build/transform-worker/postcss.js +176 -233
  56. package/build/transform-worker/postcss.js.map +1 -1
  57. package/build/transform-worker/sass.js +30 -38
  58. package/build/transform-worker/sass.js.map +1 -1
  59. package/build/transform-worker/transform-worker.js +156 -188
  60. package/build/transform-worker/transform-worker.js.map +1 -1
  61. package/build/transform-worker/utils/require.js +30 -28
  62. package/build/transform-worker/utils/require.js.map +1 -1
  63. package/build/transformSync.js +40 -28
  64. package/build/transformSync.js.map +1 -1
  65. package/build/transformer/createExoticTransformer.js +96 -129
  66. package/build/transformer/createExoticTransformer.js.map +1 -1
  67. package/build/transformer/createMatcher.js +37 -46
  68. package/build/transformer/createMatcher.js.map +1 -1
  69. package/build/transformer/createMultiRuleTransformer.js +170 -240
  70. package/build/transformer/createMultiRuleTransformer.js.map +1 -1
  71. package/build/transformer/generateFunctionMap.js +20 -23
  72. package/build/transformer/generateFunctionMap.js.map +1 -1
  73. package/build/transformer/getBabelConfig.js +94 -127
  74. package/build/transformer/getBabelConfig.js.map +1 -1
  75. package/build/transformer/getCacheKey.js +17 -31
  76. package/build/transformer/getCacheKey.js.map +1 -1
  77. package/build/transformer/index.js +11 -62
  78. package/build/transformer/index.js.map +1 -1
  79. package/build/transformer/metro-expo-exotic-babel-transformer.js +3 -12
  80. package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
  81. package/build/traveling/metro-config.js +12 -19
  82. package/build/traveling/metro-config.js.map +1 -1
  83. package/build/utils/hash.js +8 -14
  84. package/build/utils/hash.js.map +1 -1
  85. package/package.json +6 -6
@@ -1,126 +1,98 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWatchFolders = getWatchFolders;
7
- exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
8
- exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
9
- function _assert() {
10
- const data = _interopRequireDefault(require("assert"));
11
- _assert = function () {
12
- return data;
13
- };
14
- return data;
15
- }
16
- function _fs() {
17
- const data = _interopRequireDefault(require("fs"));
18
- _fs = function () {
19
- return data;
20
- };
21
- return data;
22
- }
23
- function _glob() {
24
- const data = require("glob");
25
- _glob = function () {
26
- return data;
27
- };
28
- return data;
29
- }
30
- function _path() {
31
- const data = _interopRequireDefault(require("path"));
32
- _path = function () {
33
- return data;
34
- };
35
- return data;
36
- }
37
- function _getModulesPaths() {
38
- const data = require("./getModulesPaths");
39
- _getModulesPaths = function () {
40
- return data;
41
- };
42
- return data;
43
- }
44
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWatchFolders = exports.resolveAllWorkspacePackageJsonPaths = exports.globAllPackageJsonPaths = void 0;
7
+ const assert_1 = __importDefault(require("assert"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const glob_1 = require("glob");
10
+ const path_1 = __importDefault(require("path"));
11
+ const getModulesPaths_1 = require("./getModulesPaths");
45
12
  function readJsonFile(filePath) {
46
- // Read with fs
47
- const file = _fs().default.readFileSync(filePath, 'utf8');
48
- // Parse with JSON.parse
49
- return JSON.parse(file);
13
+ // Read with fs
14
+ const file = fs_1.default.readFileSync(filePath, 'utf8');
15
+ // Parse with JSON.parse
16
+ return JSON.parse(file);
50
17
  }
51
18
  function isValidJsonFile(filePath) {
52
- try {
53
- // Throws if invalid or unable to read.
54
- readJsonFile(filePath);
55
- return true;
56
- } catch {
57
- return false;
58
- }
19
+ try {
20
+ // Throws if invalid or unable to read.
21
+ readJsonFile(filePath);
22
+ return true;
23
+ }
24
+ catch {
25
+ return false;
26
+ }
59
27
  }
60
-
61
28
  /**
62
29
  * @param workspaceProjectRoot Root file path for the yarn workspace
63
30
  * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`
64
31
  * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`
65
32
  */
66
33
  function globAllPackageJsonPaths(workspaceProjectRoot, linkedPackages) {
67
- return linkedPackages.map(glob => {
68
- return (0, _glob().sync)(_path().default.join(glob, 'package.json').replace(/\\/g, '/'), {
69
- cwd: workspaceProjectRoot,
70
- absolute: true,
71
- ignore: ['**/@(Carthage|Pods|node_modules)/**']
72
- }).map(pkgPath => {
73
- return isValidJsonFile(pkgPath) ? pkgPath : null;
74
- });
75
- }).flat().filter(Boolean).map(p => _path().default.join(p));
34
+ return linkedPackages
35
+ .map((glob) => {
36
+ return (0, glob_1.sync)(path_1.default.join(glob, 'package.json').replace(/\\/g, '/'), {
37
+ cwd: workspaceProjectRoot,
38
+ absolute: true,
39
+ ignore: ['**/@(Carthage|Pods|node_modules)/**'],
40
+ }).map((pkgPath) => {
41
+ return isValidJsonFile(pkgPath) ? pkgPath : null;
42
+ });
43
+ })
44
+ .flat()
45
+ .filter(Boolean)
46
+ .map((p) => path_1.default.join(p));
76
47
  }
77
- function getWorkspacePackagesArray({
78
- workspaces
79
- }) {
80
- if (Array.isArray(workspaces)) {
81
- return workspaces;
82
- }
83
- (0, _assert().default)(workspaces === null || workspaces === void 0 ? void 0 : workspaces.packages, 'Could not find a `workspaces` object in the root package.json');
84
- return workspaces.packages;
48
+ exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
49
+ function getWorkspacePackagesArray({ workspaces }) {
50
+ if (Array.isArray(workspaces)) {
51
+ return workspaces;
52
+ }
53
+ (0, assert_1.default)(workspaces?.packages, 'Could not find a `workspaces` object in the root package.json');
54
+ return workspaces.packages;
85
55
  }
86
-
87
56
  /**
88
57
  * @param workspaceProjectRoot root file path for a yarn workspace.
89
58
  * @returns list of package.json file paths that are linked to the yarn workspace.
90
59
  */
91
60
  function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot) {
92
- try {
93
- const rootPackageJsonFilePath = _path().default.join(workspaceProjectRoot, 'package.json');
94
- // Could throw if package.json is invalid.
95
- const rootPackageJson = readJsonFile(rootPackageJsonFilePath);
96
-
97
- // Extract the "packages" array or use "workspaces" as packages array (yarn workspaces spec).
98
- const packages = getWorkspacePackagesArray(rootPackageJson);
99
-
100
- // Glob all package.json files and return valid paths.
101
- return globAllPackageJsonPaths(workspaceProjectRoot, packages);
102
- } catch {
103
- return [];
104
- }
61
+ try {
62
+ const rootPackageJsonFilePath = path_1.default.join(workspaceProjectRoot, 'package.json');
63
+ // Could throw if package.json is invalid.
64
+ const rootPackageJson = readJsonFile(rootPackageJsonFilePath);
65
+ // Extract the "packages" array or use "workspaces" as packages array (yarn workspaces spec).
66
+ const packages = getWorkspacePackagesArray(rootPackageJson);
67
+ // Glob all package.json files and return valid paths.
68
+ return globAllPackageJsonPaths(workspaceProjectRoot, packages);
69
+ }
70
+ catch {
71
+ return [];
72
+ }
105
73
  }
106
-
74
+ exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
107
75
  /**
108
76
  * @param projectRoot file path to app's project root
109
77
  * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`
110
78
  */
111
79
  function getWatchFolders(projectRoot) {
112
- const workspaceRoot = (0, _getModulesPaths().getWorkspaceRoot)(_path().default.resolve(projectRoot));
113
- // Rely on default behavior in standard projects.
114
- if (!workspaceRoot) {
115
- return [];
116
- }
117
- const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);
118
- if (!packages.length) {
119
- return [];
120
- }
121
- return uniqueItems([_path().default.join(workspaceRoot, 'node_modules'), ...packages.map(pkg => _path().default.dirname(pkg))]);
80
+ const workspaceRoot = (0, getModulesPaths_1.getWorkspaceRoot)(path_1.default.resolve(projectRoot));
81
+ // Rely on default behavior in standard projects.
82
+ if (!workspaceRoot) {
83
+ return [];
84
+ }
85
+ const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);
86
+ if (!packages.length) {
87
+ return [];
88
+ }
89
+ return uniqueItems([
90
+ path_1.default.join(workspaceRoot, 'node_modules'),
91
+ ...packages.map((pkg) => path_1.default.dirname(pkg)),
92
+ ]);
122
93
  }
94
+ exports.getWatchFolders = getWatchFolders;
123
95
  function uniqueItems(items) {
124
- return [...new Set(items)];
96
+ return [...new Set(items)];
125
97
  }
126
98
  //# sourceMappingURL=getWatchFolders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWatchFolders.js","names":["_assert","data","_interopRequireDefault","require","_fs","_glob","_path","_getModulesPaths","obj","__esModule","default","readJsonFile","filePath","file","fs","readFileSync","JSON","parse","isValidJsonFile","globAllPackageJsonPaths","workspaceProjectRoot","linkedPackages","map","glob","globSync","path","join","replace","cwd","absolute","ignore","pkgPath","flat","filter","Boolean","p","getWorkspacePackagesArray","workspaces","Array","isArray","assert","packages","resolveAllWorkspacePackageJsonPaths","rootPackageJsonFilePath","rootPackageJson","getWatchFolders","projectRoot","workspaceRoot","getWorkspaceRoot","resolve","length","uniqueItems","pkg","dirname","items","Set"],"sources":["../src/getWatchFolders.ts"],"sourcesContent":["import assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport { getWorkspaceRoot } from './getModulesPaths';\n\nfunction readJsonFile(filePath: string) {\n // Read with fs\n const file = fs.readFileSync(filePath, 'utf8');\n // Parse with JSON.parse\n return JSON.parse(file);\n}\n\nfunction isValidJsonFile(filePath: string): boolean {\n try {\n // Throws if invalid or unable to read.\n readJsonFile(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * @param workspaceProjectRoot Root file path for the yarn workspace\n * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`\n * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`\n */\nexport function globAllPackageJsonPaths(\n workspaceProjectRoot: string,\n linkedPackages: string[]\n): string[] {\n return linkedPackages\n .map((glob) => {\n return globSync(path.join(glob, 'package.json').replace(/\\\\/g, '/'), {\n cwd: workspaceProjectRoot,\n absolute: true,\n ignore: ['**/@(Carthage|Pods|node_modules)/**'],\n }).map((pkgPath) => {\n return isValidJsonFile(pkgPath) ? pkgPath : null;\n });\n })\n .flat()\n .filter(Boolean)\n .map((p) => path.join(p as string));\n}\n\nfunction getWorkspacePackagesArray({ workspaces }: any): string[] {\n if (Array.isArray(workspaces)) {\n return workspaces;\n }\n\n assert(workspaces?.packages, 'Could not find a `workspaces` object in the root package.json');\n\n return workspaces.packages;\n}\n\n/**\n * @param workspaceProjectRoot root file path for a yarn workspace.\n * @returns list of package.json file paths that are linked to the yarn workspace.\n */\nexport function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot: string) {\n try {\n const rootPackageJsonFilePath = path.join(workspaceProjectRoot, 'package.json');\n // Could throw if package.json is invalid.\n const rootPackageJson = readJsonFile(rootPackageJsonFilePath);\n\n // Extract the \"packages\" array or use \"workspaces\" as packages array (yarn workspaces spec).\n const packages = getWorkspacePackagesArray(rootPackageJson);\n\n // Glob all package.json files and return valid paths.\n return globAllPackageJsonPaths(workspaceProjectRoot, packages);\n } catch {\n return [];\n }\n}\n\n/**\n * @param projectRoot file path to app's project root\n * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`\n */\nexport function getWatchFolders(projectRoot: string): string[] {\n const workspaceRoot = getWorkspaceRoot(path.resolve(projectRoot));\n // Rely on default behavior in standard projects.\n if (!workspaceRoot) {\n return [];\n }\n\n const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);\n if (!packages.length) {\n return [];\n }\n\n return uniqueItems([\n path.join(workspaceRoot, 'node_modules'),\n ...packages.map((pkg) => path.dirname(pkg)),\n ]);\n}\n\nfunction uniqueItems(items: string[]): string[] {\n return [...new Set(items)];\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,iBAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,gBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAqD,SAAAC,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UA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D,CAAC;EAE7F,OAAOJ,UAAU,CAACI,QAAQ;AAC5B;;AAEA;AACA;AACA;AACA;AACO,SAASC,mCAAmCA,CAACtB,oBAA4B,EAAE;EAChF,IAAI;IACF,MAAMuB,uBAAuB,GAAGlB,eAAI,CAACC,IAAI,CAACN,oBAAoB,EAAE,cAAc,CAAC;IAC/E;IACA,MAAMwB,eAAe,GAAGjC,YAAY,CAACgC,uBAAuB,CAAC;;IAE7D;IACA,MAAMF,QAAQ,GAAGL,yBAAyB,CAACQ,eAAe,CAAC;;IAE3D;IACA,OAAOzB,uBAAuB,CAACC,oBAAoB,EAAEqB,QAAQ,CAAC;EAChE,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA;AACA;AACO,SAASI,eAAeA,CAACC,WAAmB,EAAY;EAC7D,MAAMC,aAAa,GAAG,IAAAC,mCAAgB,EAACvB,eAAI,CAACwB,OAAO,CAACH,WAAW,CAAC,CAAC;EACjE;EACA,IAAI,CAACC,aAAa,EAAE;IAClB,OAAO,EAAE;EACX;EAEA,MAAMN,QAAQ,GAAGC,mCAAmC,CAACK,aAAa,CAAC;EACnE,IAAI,CAACN,QAAQ,CAACS,MAAM,EAAE;IACpB,OAAO,EAAE;EACX;EAEA,OAAOC,WAAW,CAAC,CACjB1B,eAAI,CAACC,IAAI,CAACqB,aAAa,EAAE,cAAc,CAAC,EACxC,GAAGN,QAAQ,CAACnB,GAAG,CAAE8B,GAAG,IAAK3B,eAAI,CAAC4B,OAAO,CAACD,GAAG,CAAC,CAAC,CAC5C,CAAC;AACJ;AAEA,SAASD,WAAWA,CAACG,KAAe,EAAY;EAC9C,OAAO,CAAC,GAAG,IAAIC,GAAG,CAACD,KAAK,CAAC,CAAC;AAC5B"}
1
+ {"version":3,"file":"getWatchFolders.js","sourceRoot":"","sources":["../src/getWatchFolders.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,4CAAoB;AACpB,+BAAwC;AACxC,gDAAwB;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1,9 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadBabelConfig = void 0;
7
- function _nodeFs() {
8
- const data = _interopRequireDefault(require("node:fs"));
9
- _nodeFs = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _nodePath() {
15
- const data = _interopRequireDefault(require("node:path"));
16
- _nodePath = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
7
  /**
23
8
  * Copyright (c) 650 Industries (Expo). All rights reserved.
24
9
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -26,39 +11,35 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
11
  * This source code is licensed under the MIT license found in the
27
12
  * LICENSE file in the root directory of this source tree.
28
13
  */
29
-
14
+ const node_fs_1 = __importDefault(require("node:fs"));
15
+ const node_path_1 = __importDefault(require("node:path"));
30
16
  /**
31
17
  * Returns a memoized function that checks for the existence of a
32
18
  * project-level .babelrc file. If it doesn't exist, it reads the
33
19
  * default React Native babelrc file and uses that.
34
20
  */
35
- const loadBabelConfig = function () {
36
- let babelRC = null;
37
- return function _getBabelRC({
38
- projectRoot
39
- }) {
40
- if (babelRC !== null) {
41
- return babelRC;
42
- }
43
- babelRC = {};
44
- if (projectRoot) {
45
- // Check for various babel config files in the project root
46
- // TODO(EvanBacon): We might want to disable babelrc lookup when the user specifies `enableBabelRCLookup: false`.
47
- const possibleBabelRCPaths = ['.babelrc', '.babelrc.js', 'babel.config.js'];
48
- const foundBabelRCPath = possibleBabelRCPaths.find(configFileName => _nodeFs().default.existsSync(_nodePath().default.resolve(projectRoot, configFileName)));
49
-
50
- // Extend the config if a babel config file is found
51
- if (foundBabelRCPath) {
52
- babelRC.extends = _nodePath().default.resolve(projectRoot, foundBabelRCPath);
53
- }
54
- }
55
-
56
- // Use the default preset for react-native if no babel config file is found
57
- if (!babelRC.extends) {
58
- babelRC.presets = [require('babel-preset-expo')];
59
- }
60
- return babelRC;
61
- };
62
- }();
63
- exports.loadBabelConfig = loadBabelConfig;
21
+ exports.loadBabelConfig = (function () {
22
+ let babelRC = null;
23
+ return function _getBabelRC({ projectRoot }) {
24
+ if (babelRC !== null) {
25
+ return babelRC;
26
+ }
27
+ babelRC = {};
28
+ if (projectRoot) {
29
+ // Check for various babel config files in the project root
30
+ // TODO(EvanBacon): We might want to disable babelrc lookup when the user specifies `enableBabelRCLookup: false`.
31
+ const possibleBabelRCPaths = ['.babelrc', '.babelrc.js', 'babel.config.js'];
32
+ const foundBabelRCPath = possibleBabelRCPaths.find((configFileName) => node_fs_1.default.existsSync(node_path_1.default.resolve(projectRoot, configFileName)));
33
+ // Extend the config if a babel config file is found
34
+ if (foundBabelRCPath) {
35
+ babelRC.extends = node_path_1.default.resolve(projectRoot, foundBabelRCPath);
36
+ }
37
+ }
38
+ // Use the default preset for react-native if no babel config file is found
39
+ if (!babelRC.extends) {
40
+ babelRC.presets = [require('babel-preset-expo')];
41
+ }
42
+ return babelRC;
43
+ };
44
+ })();
64
45
  //# sourceMappingURL=loadBabelConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadBabelConfig.js","names":["_nodeFs","data","_interopRequireDefault","require","_nodePath","obj","__esModule","default","loadBabelConfig","babelRC","_getBabelRC","projectRoot","possibleBabelRCPaths","foundBabelRCPath","find","configFileName","fs","existsSync","path","resolve","extends","presets","exports"],"sources":["../src/loadBabelConfig.ts"],"sourcesContent":["/**\n * Copyright (c) 650 Industries (Expo). All rights reserved.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { TransformOptions } from './babel-core';\n\n/**\n * Returns a memoized function that checks for the existence of a\n * project-level .babelrc file. If it doesn't exist, it reads the\n * default React Native babelrc file and uses that.\n */\nexport const loadBabelConfig = (function () {\n let babelRC: Pick<TransformOptions, 'extends' | 'presets'> | null = null;\n\n return function _getBabelRC({ projectRoot }: { projectRoot: string }) {\n if (babelRC !== null) {\n return babelRC;\n }\n\n babelRC = {};\n\n if (projectRoot) {\n // Check for various babel config files in the project root\n // TODO(EvanBacon): We might want to disable babelrc lookup when the user specifies `enableBabelRCLookup: false`.\n const possibleBabelRCPaths = ['.babelrc', '.babelrc.js', 'babel.config.js'];\n\n const foundBabelRCPath = possibleBabelRCPaths.find((configFileName) =>\n fs.existsSync(path.resolve(projectRoot, configFileName))\n );\n\n // Extend the config if a babel config file is found\n if (foundBabelRCPath) {\n babelRC.extends = path.resolve(projectRoot, foundBabelRCPath);\n }\n }\n\n // Use the default preset for react-native if no babel config file is found\n if (!babelRC.extends) {\n babelRC.presets = [require('babel-preset-expo')];\n }\n\n return babelRC;\n };\n})();\n"],"mappings":";;;;;;AAOA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6B,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAR7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACO,MAAMG,eAAe,GAAI,YAAY;EAC1C,IAAIC,OAA6D,GAAG,IAAI;EAExE,OAAO,SAASC,WAAWA,CAAC;IAAEC;EAAqC,CAAC,EA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,oBAAoB,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE,CACpE,iBAAE,CAAC,UAAU,CAAC,mBAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CACzD,CAAC;YAEF,oDAAoD;YACpD,IAAI,gBAAgB,EAAE;gBACpB,OAAO,CAAC,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;aAC/D;SACF;QAED,2EAA2E;QAC3E,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;SAClD;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
@@ -1,158 +1,98 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRewriteRequestUrl = getRewriteRequestUrl;
7
- exports.getRouterDirectory = getRouterDirectory;
8
- function _config() {
9
- const data = require("@expo/config");
10
- _config = function () {
11
- return data;
12
- };
13
- return data;
14
- }
15
- function _paths() {
16
- const data = require("@expo/config/paths");
17
- _paths = function () {
18
- return data;
19
- };
20
- return data;
21
- }
22
- function _chalk() {
23
- const data = _interopRequireDefault(require("chalk"));
24
- _chalk = function () {
25
- return data;
26
- };
27
- return data;
28
- }
29
- function _fs() {
30
- const data = _interopRequireDefault(require("fs"));
31
- _fs = function () {
32
- return data;
33
- };
34
- return data;
35
- }
36
- function _path() {
37
- const data = _interopRequireDefault(require("path"));
38
- _path = function () {
39
- return data;
40
- };
41
- return data;
42
- }
43
- function _getModulesPaths() {
44
- const data = require("./getModulesPaths");
45
- _getModulesPaths = function () {
46
- return data;
47
- };
48
- return data;
49
- }
50
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRewriteRequestUrl = exports.getRouterDirectory = void 0;
51
7
  // Copyright 2023-present 650 Industries (Expo). All rights reserved.
52
-
8
+ const config_1 = require("@expo/config");
9
+ const paths_1 = require("@expo/config/paths");
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const getModulesPaths_1 = require("./getModulesPaths");
53
14
  const debug = require('debug')('expo:metro:config:rewriteRequestUrl');
54
15
  function directoryExistsSync(file) {
55
- try {
56
- var _fs$statSync$isDirect, _fs$statSync;
57
- return (_fs$statSync$isDirect = (_fs$statSync = _fs().default.statSync(file)) === null || _fs$statSync === void 0 ? void 0 : _fs$statSync.isDirectory()) !== null && _fs$statSync$isDirect !== void 0 ? _fs$statSync$isDirect : false;
58
- } catch {
59
- return false;
60
- }
16
+ try {
17
+ return fs_1.default.statSync(file)?.isDirectory() ?? false;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
61
22
  }
62
23
  function isEnableHermesManaged(expoConfig, platform) {
63
- switch (platform) {
64
- case 'android':
65
- {
66
- var _expoConfig$android$j, _expoConfig$android;
67
- return ((_expoConfig$android$j = (_expoConfig$android = expoConfig.android) === null || _expoConfig$android === void 0 ? void 0 : _expoConfig$android.jsEngine) !== null && _expoConfig$android$j !== void 0 ? _expoConfig$android$j : expoConfig.jsEngine) !== 'jsc';
68
- }
69
- case 'ios':
70
- {
71
- var _expoConfig$ios$jsEng, _expoConfig$ios;
72
- return ((_expoConfig$ios$jsEng = (_expoConfig$ios = expoConfig.ios) === null || _expoConfig$ios === void 0 ? void 0 : _expoConfig$ios.jsEngine) !== null && _expoConfig$ios$jsEng !== void 0 ? _expoConfig$ios$jsEng : expoConfig.jsEngine) !== 'jsc';
73
- }
74
- default:
75
- return false;
76
- }
24
+ switch (platform) {
25
+ case 'android': {
26
+ return (expoConfig.android?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';
27
+ }
28
+ case 'ios': {
29
+ return (expoConfig.ios?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';
30
+ }
31
+ default:
32
+ return false;
33
+ }
77
34
  }
78
35
  function getRouterDirectoryModuleIdWithManifest(projectRoot, exp) {
79
- var _exp$extra$router$roo, _exp$extra, _exp$extra$router;
80
- return (_exp$extra$router$roo = (_exp$extra = exp.extra) === null || _exp$extra === void 0 ? void 0 : (_exp$extra$router = _exp$extra.router) === null || _exp$extra$router === void 0 ? void 0 : _exp$extra$router.root) !== null && _exp$extra$router$roo !== void 0 ? _exp$extra$router$roo : getRouterDirectory(projectRoot);
36
+ return exp.extra?.router?.root ?? getRouterDirectory(projectRoot);
81
37
  }
82
38
  function getRouterDirectory(projectRoot) {
83
- // more specific directories first
84
- if (directoryExistsSync(_path().default.join(projectRoot, 'src/app'))) {
85
- debug('Using src/app as the root directory for Expo Router.');
86
- return 'src/app';
87
- }
88
- debug('Using app as the root directory for Expo Router.');
89
- return 'app';
39
+ // more specific directories first
40
+ if (directoryExistsSync(path_1.default.join(projectRoot, 'src/app'))) {
41
+ debug('Using src/app as the root directory for Expo Router.');
42
+ return 'src/app';
43
+ }
44
+ debug('Using app as the root directory for Expo Router.');
45
+ return 'app';
90
46
  }
47
+ exports.getRouterDirectory = getRouterDirectory;
91
48
  function getRewriteRequestUrl(projectRoot) {
92
- function rewriteExpoRequestUrl(url) {
93
- // Like: `/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
94
- // Sometimes a fully qualified URL is passed in, e.g. `http://localhost:19001/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
95
- if (url.includes('/.expo/.virtual-metro-entry.bundle?')) {
96
- var _searchParams$get;
97
- const {
98
- pkg,
99
- exp
100
- } = (0, _config().getConfig)(projectRoot, {
101
- skipSDKVersionRequirement: true
102
- });
103
- const ensured = url.startsWith('/') ? new URL(url, 'https://acme.dev') : new URL(url);
104
- // TODO: Maybe this function could be memoized in some capacity?
105
- const {
106
- searchParams
107
- } = ensured;
108
- const platform = (_searchParams$get = searchParams.get('platform')) !== null && _searchParams$get !== void 0 ? _searchParams$get : 'web';
109
- debug('Rewriting magic request url to entry point', {
110
- url,
111
- platform
112
- });
113
- const entry = (0, _paths().resolveEntryPoint)(projectRoot, {
114
- platform,
115
- pkg
116
- });
117
- if (!entry) {
118
- throw new Error((0, _chalk().default)`The project entry file could not be resolved (platform: ${platform}, root: ${projectRoot}). Define it in the {bold package.json} "main" field.`);
119
- }
120
-
121
- // Infer the missing transform properties to attempt to match the manifest request.
122
- // NOTE: Keep in sync with metroOptions.ts
123
- if (!ensured.searchParams.has('transform.routerRoot')) {
124
- ensured.searchParams.set('transform.routerRoot', getRouterDirectoryModuleIdWithManifest(projectRoot, exp));
125
- }
126
- if (!ensured.searchParams.has('transform.engine')) {
127
- const isHermesEnabled = isEnableHermesManaged(exp, platform);
128
- if (isHermesEnabled) {
129
- debug('Enabling Hermes for managed project');
130
- ensured.searchParams.set('transform.engine', 'hermes');
49
+ function rewriteExpoRequestUrl(url) {
50
+ // Like: `/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
51
+ // Sometimes a fully qualified URL is passed in, e.g. `http://localhost:19001/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
52
+ if (url.includes('/.expo/.virtual-metro-entry.bundle?')) {
53
+ const { pkg, exp } = (0, config_1.getConfig)(projectRoot, { skipSDKVersionRequirement: true });
54
+ const ensured = url.startsWith('/') ? new URL(url, 'https://acme.dev') : new URL(url);
55
+ // TODO: Maybe this function could be memoized in some capacity?
56
+ const { searchParams } = ensured;
57
+ const platform = searchParams.get('platform') ?? 'web';
58
+ debug('Rewriting magic request url to entry point', { url, platform });
59
+ const entry = (0, paths_1.resolveEntryPoint)(projectRoot, {
60
+ platform,
61
+ pkg,
62
+ });
63
+ if (!entry) {
64
+ throw new Error((0, chalk_1.default) `The project entry file could not be resolved (platform: ${platform}, root: ${projectRoot}). Define it in the {bold package.json} "main" field.`);
65
+ }
66
+ // Infer the missing transform properties to attempt to match the manifest request.
67
+ // NOTE: Keep in sync with metroOptions.ts
68
+ if (!ensured.searchParams.has('transform.routerRoot')) {
69
+ ensured.searchParams.set('transform.routerRoot', getRouterDirectoryModuleIdWithManifest(projectRoot, exp));
70
+ }
71
+ if (!ensured.searchParams.has('transform.engine')) {
72
+ const isHermesEnabled = isEnableHermesManaged(exp, platform);
73
+ if (isHermesEnabled) {
74
+ debug('Enabling Hermes for managed project');
75
+ ensured.searchParams.set('transform.engine', 'hermes');
76
+ }
77
+ }
78
+ const serverRoot = (0, getModulesPaths_1.getServerRoot)(projectRoot);
79
+ const relativeEntry = path_1.default.relative(serverRoot, entry).replace(/\.[tj]sx?$/, '');
80
+ debug('Resolved entry point', { entry, relativeEntry, serverRoot });
81
+ // Only return the pathname when url is relative
82
+ if (url.startsWith('/')) {
83
+ // Like: `/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
84
+ return '/' + relativeEntry + '.bundle?' + searchParams.toString();
85
+ }
86
+ // Modify the pathname within the URL and return the full URL
87
+ ensured.pathname = '/' + relativeEntry + '.bundle';
88
+ const outputUrl = ensured.toString();
89
+ debug('Redirected:', outputUrl);
90
+ // Like: `http://localhost:19001/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
91
+ return outputUrl;
131
92
  }
132
- }
133
- const serverRoot = (0, _getModulesPaths().getServerRoot)(projectRoot);
134
- const relativeEntry = _path().default.relative(serverRoot, entry).replace(/\.[tj]sx?$/, '');
135
- debug('Resolved entry point', {
136
- entry,
137
- relativeEntry,
138
- serverRoot
139
- });
140
-
141
- // Only return the pathname when url is relative
142
- if (url.startsWith('/')) {
143
- // Like: `/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
144
- return '/' + relativeEntry + '.bundle?' + searchParams.toString();
145
- }
146
-
147
- // Modify the pathname within the URL and return the full URL
148
- ensured.pathname = '/' + relativeEntry + '.bundle';
149
- const outputUrl = ensured.toString();
150
- debug('Redirected:', outputUrl);
151
- // Like: `http://localhost:19001/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bacon.test-custom-entry`
152
- return outputUrl;
93
+ return url;
153
94
  }
154
- return url;
155
- }
156
- return rewriteExpoRequestUrl;
95
+ return rewriteExpoRequestUrl;
157
96
  }
97
+ exports.getRewriteRequestUrl = getRewriteRequestUrl;
158
98
  //# sourceMappingURL=rewriteRequestUrl.js.map