@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.
- package/build/ExpoMetroConfig.js +239 -366
- package/build/ExpoMetroConfig.js.map +1 -1
- package/build/babel-core.js +6 -23
- package/build/babel-core.js.map +1 -1
- package/build/babel-transformer.js +117 -162
- package/build/babel-transformer.js.map +1 -1
- package/build/customizeFrame.js +84 -78
- package/build/customizeFrame.js.map +1 -1
- package/build/env.js +23 -37
- package/build/env.js.map +1 -1
- package/build/file-store.js +13 -21
- package/build/file-store.js.map +1 -1
- package/build/getModulesPaths.js +31 -48
- package/build/getModulesPaths.js.map +1 -1
- package/build/getWatchFolders.js +70 -98
- package/build/getWatchFolders.js.map +1 -1
- package/build/loadBabelConfig.js +30 -49
- package/build/loadBabelConfig.js.map +1 -1
- package/build/rewriteRequestUrl.js +82 -142
- package/build/rewriteRequestUrl.js.map +1 -1
- package/build/serializer/debugId.js +23 -22
- package/build/serializer/debugId.js.map +1 -1
- package/build/serializer/environmentVariableSerializerPlugin.js +90 -101
- package/build/serializer/environmentVariableSerializerPlugin.js.map +1 -1
- package/build/serializer/exportHermes.js +96 -133
- package/build/serializer/exportHermes.js.map +1 -1
- package/build/serializer/exportPath.js +18 -35
- package/build/serializer/exportPath.js.map +1 -1
- package/build/serializer/fork/baseJSBundle.js +124 -147
- package/build/serializer/fork/baseJSBundle.js.map +1 -1
- package/build/serializer/fork/js.js +81 -116
- package/build/serializer/fork/js.js.map +1 -1
- package/build/serializer/fork/processModules.js +22 -36
- package/build/serializer/fork/processModules.js.map +1 -1
- package/build/serializer/getCssDeps.js +64 -95
- package/build/serializer/getCssDeps.js.map +1 -1
- package/build/serializer/jsOutput.js +6 -16
- package/build/serializer/jsOutput.js.map +1 -1
- package/build/serializer/serializeChunks.js +406 -483
- package/build/serializer/serializeChunks.js.map +1 -1
- package/build/serializer/serializerAssets.js +1 -0
- package/build/serializer/serializerAssets.js.map +1 -1
- package/build/serializer/withExpoSerializers.js +165 -236
- package/build/serializer/withExpoSerializers.js.map +1 -1
- package/build/transform-worker/asset-transformer.js +21 -44
- package/build/transform-worker/asset-transformer.js.map +1 -1
- package/build/transform-worker/css-modules.js +57 -84
- package/build/transform-worker/css-modules.js.map +1 -1
- package/build/transform-worker/css.js +21 -20
- package/build/transform-worker/css.js.map +1 -1
- package/build/transform-worker/getAssets.js +38 -75
- package/build/transform-worker/getAssets.js.map +1 -1
- package/build/transform-worker/metro-transform-worker.js +384 -489
- package/build/transform-worker/metro-transform-worker.js.map +1 -1
- package/build/transform-worker/postcss.js +176 -233
- package/build/transform-worker/postcss.js.map +1 -1
- package/build/transform-worker/sass.js +30 -38
- package/build/transform-worker/sass.js.map +1 -1
- package/build/transform-worker/transform-worker.js +156 -188
- package/build/transform-worker/transform-worker.js.map +1 -1
- package/build/transform-worker/utils/require.js +30 -28
- package/build/transform-worker/utils/require.js.map +1 -1
- package/build/transformSync.js +40 -28
- package/build/transformSync.js.map +1 -1
- package/build/transformer/createExoticTransformer.js +96 -129
- package/build/transformer/createExoticTransformer.js.map +1 -1
- package/build/transformer/createMatcher.js +37 -46
- package/build/transformer/createMatcher.js.map +1 -1
- package/build/transformer/createMultiRuleTransformer.js +170 -240
- package/build/transformer/createMultiRuleTransformer.js.map +1 -1
- package/build/transformer/generateFunctionMap.js +20 -23
- package/build/transformer/generateFunctionMap.js.map +1 -1
- package/build/transformer/getBabelConfig.js +94 -127
- package/build/transformer/getBabelConfig.js.map +1 -1
- package/build/transformer/getCacheKey.js +17 -31
- package/build/transformer/getCacheKey.js.map +1 -1
- package/build/transformer/index.js +11 -62
- package/build/transformer/index.js.map +1 -1
- package/build/transformer/metro-expo-exotic-babel-transformer.js +3 -12
- package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
- package/build/traveling/metro-config.js +12 -19
- package/build/traveling/metro-config.js.map +1 -1
- package/build/utils/hash.js +8 -14
- package/build/utils/hash.js.map +1 -1
- package/package.json +6 -6
package/build/getWatchFolders.js
CHANGED
|
@@ -1,126 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.getWatchFolders =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
96
|
+
return [...new Set(items)];
|
|
125
97
|
}
|
|
126
98
|
//# sourceMappingURL=getWatchFolders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWatchFolders.js","
|
|
1
|
+
{"version":3,"file":"getWatchFolders.js","sourceRoot":"","sources":["../src/getWatchFolders.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,4CAAoB;AACpB,+BAAwC;AACxC,gDAAwB;AAExB,uDAAqD;AAErD,SAAS,YAAY,CAAC,QAAgB;IACpC,eAAe;IACf,MAAM,IAAI,GAA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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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","
|
|
1
|
+
{"version":3,"file":"loadBabelConfig.js","sourceRoot":"","sources":["../src/loadBabelConfig.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;GAMG;AACH,sDAAyB;AACzB,0DAA6B;AAI7B;;;;GAIG;AACU,QAAA,eAAe,GAAG,CAAC;IAC9B,IAAI,OAAO,GAAyD,IAAI,CAAC;IAEzE,OAAO,SAAS,WAAW,CAAC,EAAE,WAAW,EAA2B;QAClE,IAAI,OAAO,KAAK,IAAI,EAAE;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,GAAG,EAAE,CAAC;QAEb,IAAI,WAAW,EAAE;YACf,2DAA2D;YAC3D,iHAAiH;YACjH,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;YAE5E,MAAM,gBAAgB,GAAG,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
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
|
155
|
-
}
|
|
156
|
-
return rewriteExpoRequestUrl;
|
|
95
|
+
return rewriteExpoRequestUrl;
|
|
157
96
|
}
|
|
97
|
+
exports.getRewriteRequestUrl = getRewriteRequestUrl;
|
|
158
98
|
//# sourceMappingURL=rewriteRequestUrl.js.map
|