@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteRequestUrl.js","
|
|
1
|
+
{"version":3,"file":"rewriteRequestUrl.js","sourceRoot":"","sources":["../src/rewriteRequestUrl.ts"],"names":[],"mappings":";;;;;;AAAA,qEAAqE;AACrE,yCAAqD;AACrD,8CAAuD;AACvD,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAExB,uDAAkD;AAElD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qCAAqC,CAAC,CAAC;AAEtE,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI;QACF,OAAO,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC;KAClD;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED,SAAS,qBAAqB,CAC5B,UAAqE,EACrE,QAAgB;IAEhB,QAAQ,QAAQ,EAAE;QAChB,KAAK,SAAS,CAAC,CAAC;YACd,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC;SACxE;QACD,KAAK,KAAK,CAAC,CAAC;YACV,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC;SACpE;QACD;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AAED,SAAS,sCAAsC,CAAC,WAAmB,EAAE,GAAe;IAClF,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC;AAED,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,kCAAkC;IAClC,IAAI,mBAAmB,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE;QAC1D,KAAK,CAAC,sDAAsD,CAA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data = _interopRequireDefault(require("node:crypto"));
|
|
9
|
-
_nodeCrypto = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
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.stringToUUID = void 0;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
15
8
|
/**
|
|
16
9
|
* Copyright © 2023 650 Industries.
|
|
17
10
|
* Copyright (c) 2022, Sentry.
|
|
@@ -19,19 +12,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
12
|
* This source code is licensed under the MIT license found in the
|
|
20
13
|
* LICENSE file in the root directory of this source tree.
|
|
21
14
|
*/
|
|
22
|
-
|
|
23
15
|
/**
|
|
24
16
|
* Deterministically hashes a string and turns the hash into a uuid.
|
|
25
17
|
* https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/58271f1af2ade6b3e64d393d70376ae53bc5bd2f/packages/bundler-plugin-core/src/utils.ts#L174
|
|
26
18
|
*/
|
|
27
19
|
function stringToUUID(str) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
const md5sum = node_crypto_1.default.createHash('md5');
|
|
21
|
+
md5sum.update(str);
|
|
22
|
+
const md5Hash = md5sum.digest('hex');
|
|
23
|
+
// Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)
|
|
24
|
+
// RFC 4122 section 4.4
|
|
25
|
+
const v4variant = ['8', '9', 'a', 'b'][md5Hash.substring(16, 17).charCodeAt(0) % 4];
|
|
26
|
+
return (md5Hash.substring(0, 8) +
|
|
27
|
+
'-' +
|
|
28
|
+
md5Hash.substring(8, 12) +
|
|
29
|
+
'-4' +
|
|
30
|
+
md5Hash.substring(13, 16) +
|
|
31
|
+
'-' +
|
|
32
|
+
v4variant +
|
|
33
|
+
md5Hash.substring(17, 20) +
|
|
34
|
+
'-' +
|
|
35
|
+
md5Hash.substring(20)).toLowerCase();
|
|
36
36
|
}
|
|
37
|
+
exports.stringToUUID = stringToUUID;
|
|
37
38
|
//# sourceMappingURL=debugId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugId.js","
|
|
1
|
+
{"version":3,"file":"debugId.js","sourceRoot":"","sources":["../../src/serializer/debugId.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAiC;AAEjC;;;;;;GAMG;AAEH;;;GAGG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,MAAM,MAAM,GAAG,qBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAErC,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW,CAAC;IAE9F,OAAO,CACL,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB,GAAG;QACH,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;QACxB,IAAI;QACJ,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;QACzB,GAAG;QACH,SAAS;QACT,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;QACzB,GAAG;QACH,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CACtB,CAAC,WAAW,EAAE,CAAC;AAClB,CAAC;AArBD,oCAqBC"}
|
|
@@ -1,120 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.environmentVariableSerializerPlugin =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _CountingSet() {
|
|
10
|
-
const data = _interopRequireDefault(require("metro/src/lib/CountingSet"));
|
|
11
|
-
_CountingSet = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
function _countLines() {
|
|
17
|
-
const data = _interopRequireDefault(require("metro/src/lib/countLines"));
|
|
18
|
-
_countLines = function () {
|
|
19
|
-
return data;
|
|
20
|
-
};
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
/**
|
|
25
|
-
* Copyright © 2022 650 Industries.
|
|
26
|
-
*
|
|
27
|
-
* This source code is licensed under the MIT license found in the
|
|
28
|
-
* LICENSE file in the root directory of this source tree.
|
|
29
|
-
*/
|
|
30
|
-
|
|
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.environmentVariableSerializerPlugin = exports.serverPreludeSerializerPlugin = exports.getTransformEnvironment = void 0;
|
|
7
|
+
const CountingSet_1 = __importDefault(require("metro/src/lib/CountingSet"));
|
|
8
|
+
const countLines_1 = __importDefault(require("metro/src/lib/countLines"));
|
|
31
9
|
const debug = require('debug')('expo:metro-config:serializer:env-var');
|
|
32
10
|
function getTransformEnvironment(url) {
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
const match = url.match(/[&?]transform\.environment=([^&]+)/);
|
|
12
|
+
return match ? match[1] : null;
|
|
35
13
|
}
|
|
14
|
+
exports.getTransformEnvironment = getTransformEnvironment;
|
|
36
15
|
function getAllExpoPublicEnvVars() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
// Create an object containing all environment variables that start with EXPO_PUBLIC_
|
|
17
|
+
const env = {};
|
|
18
|
+
for (const key in process.env) {
|
|
19
|
+
if (key.startsWith('EXPO_PUBLIC_')) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
env[key] = process.env[key];
|
|
22
|
+
}
|
|
43
23
|
}
|
|
44
|
-
|
|
45
|
-
return env;
|
|
24
|
+
return env;
|
|
46
25
|
}
|
|
47
26
|
function isServerEnvironment(graph, options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
// Requests from a dev server will use sourceUrl.
|
|
28
|
+
if (!graph.transformOptions.customTransformOptions) {
|
|
29
|
+
if (options.sourceUrl) {
|
|
30
|
+
const env = getTransformEnvironment(options.sourceUrl);
|
|
31
|
+
return env === 'node';
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
53
34
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Other requests will use customTransformOptions.environment.
|
|
58
|
-
return graph.transformOptions.customTransformOptions.environment === 'node';
|
|
35
|
+
// Other requests will use customTransformOptions.environment.
|
|
36
|
+
return graph.transformOptions.customTransformOptions.environment === 'node';
|
|
59
37
|
}
|
|
60
|
-
|
|
61
38
|
/** Strips the process.env polyfill in server environments to allow for accessing environment variables off the global. */
|
|
62
39
|
function serverPreludeSerializerPlugin(entryPoint, preModules, graph, options) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
if (isServerEnvironment(graph, options)) {
|
|
41
|
+
const prelude = preModules.find((module) => module.path === '__prelude__');
|
|
42
|
+
if (prelude) {
|
|
43
|
+
debug('Stripping environment variable polyfill in server environment.');
|
|
44
|
+
prelude.output[0].data.code = prelude.output[0].data.code
|
|
45
|
+
.replace(/process=this\.process\|\|{},/, '')
|
|
46
|
+
.replace(/process\.env=process\.env\|\|{};process\.env\.NODE_ENV=process\.env\.NODE_ENV\|\|"\w+";/, '');
|
|
47
|
+
}
|
|
68
48
|
}
|
|
69
|
-
|
|
70
|
-
return [entryPoint, preModules, graph, options];
|
|
49
|
+
return [entryPoint, preModules, graph, options];
|
|
71
50
|
}
|
|
51
|
+
exports.serverPreludeSerializerPlugin = serverPreludeSerializerPlugin;
|
|
72
52
|
function environmentVariableSerializerPlugin(entryPoint, preModules, graph, options) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
53
|
+
// Skip replacement in Node.js environments.
|
|
54
|
+
if (isServerEnvironment(graph, options)) {
|
|
55
|
+
debug('Skipping environment variable inlining in Node.js environment.');
|
|
56
|
+
return [entryPoint, preModules, graph, options];
|
|
57
|
+
}
|
|
58
|
+
// In development, we need to add the process.env object to ensure it
|
|
59
|
+
// persists between Fast Refresh updates.
|
|
60
|
+
if (!options.dev) {
|
|
61
|
+
debug('Skipping environment variable inlining in production environment in favor of babel-preset-expo inlining with source maps.');
|
|
62
|
+
return [entryPoint, preModules, graph, options];
|
|
63
|
+
}
|
|
64
|
+
// Set the process.env object to the current environment variables object
|
|
65
|
+
// ensuring they aren't iterable, settable, or enumerable.
|
|
66
|
+
const str = `process.env=Object.defineProperties(process.env, {${Object.keys(getAllExpoPublicEnvVars())
|
|
67
|
+
.map((key) => `${JSON.stringify(key)}: { value: ${JSON.stringify(process.env[key])} }`)
|
|
68
|
+
.join(',')}});`;
|
|
69
|
+
const [firstModule, ...restModules] = preModules;
|
|
70
|
+
// const envCode = `var process=this.process||{};${str}`;
|
|
71
|
+
// process.env
|
|
72
|
+
return [
|
|
73
|
+
entryPoint,
|
|
74
|
+
[
|
|
75
|
+
// First module defines the process.env object.
|
|
76
|
+
firstModule,
|
|
77
|
+
// Second module modifies the process.env object.
|
|
78
|
+
getEnvPrelude(str),
|
|
79
|
+
// Now we add the rest
|
|
80
|
+
...restModules,
|
|
81
|
+
],
|
|
82
|
+
graph,
|
|
83
|
+
options,
|
|
84
|
+
];
|
|
99
85
|
}
|
|
86
|
+
exports.environmentVariableSerializerPlugin = environmentVariableSerializerPlugin;
|
|
100
87
|
function getEnvPrelude(contents) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
88
|
+
const code = '// HMR env vars from Expo CLI (dev-only)\n' + contents;
|
|
89
|
+
const name = '__env__';
|
|
90
|
+
const lineCount = (0, countLines_1.default)(code);
|
|
91
|
+
return {
|
|
92
|
+
dependencies: new Map(),
|
|
93
|
+
getSource: () => Buffer.from(code),
|
|
94
|
+
inverseDependencies: new CountingSet_1.default(),
|
|
95
|
+
path: name,
|
|
96
|
+
output: [
|
|
97
|
+
{
|
|
98
|
+
type: 'js/script/virtual',
|
|
99
|
+
data: {
|
|
100
|
+
code,
|
|
101
|
+
// @ts-expect-error: typed incorrectly upstream
|
|
102
|
+
lineCount,
|
|
103
|
+
map: [],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
119
108
|
}
|
|
120
109
|
//# sourceMappingURL=environmentVariableSerializerPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentVariableSerializerPlugin.js","
|
|
1
|
+
{"version":3,"file":"environmentVariableSerializerPlugin.js","sourceRoot":"","sources":["../../src/serializer/environmentVariableSerializerPlugin.ts"],"names":[],"mappings":";;;;;;AAOA,4EAAoD;AACpD,0EAAkD;AAIlD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAuB,CAAC;AAE7F,SAAgB,uBAAuB,CAAC,GAAW;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAHD,0DAGC;AAED,SAAS,uBAAuB;IAC9B,qFAAqF;IACrF,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;QAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;YAClC,aAAa;YACb,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC7B;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAoB,EAAE,OAA0B;IAC3E,iDAAiD;IACjD,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,sBAAsB,EAAE;QAClD,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,MAAM,GAAG,GAAG,uBAAuB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACvD,OAAO,GAAG,KAAK,MAAM,CAAC;SACvB;QACD,OAAO,KAAK,CAAC;KACd;IAED,8DAA8D;IAC9D,OAAO,KAAK,CAAC,gBAAgB,CAAC,sBAA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
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function _chalk() {
|
|
15
|
-
const data = _interopRequireDefault(require("chalk"));
|
|
16
|
-
_chalk = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _fsExtra() {
|
|
22
|
-
const data = _interopRequireDefault(require("fs-extra"));
|
|
23
|
-
_fsExtra = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _metroSourceMap() {
|
|
29
|
-
const data = require("metro-source-map");
|
|
30
|
-
_metroSourceMap = function () {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _os() {
|
|
36
|
-
const data = _interopRequireDefault(require("os"));
|
|
37
|
-
_os = function () {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
function _path() {
|
|
43
|
-
const data = _interopRequireDefault(require("path"));
|
|
44
|
-
_path = function () {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
function _process() {
|
|
50
|
-
const data = _interopRequireDefault(require("process"));
|
|
51
|
-
_process = function () {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
|
-
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.buildHermesBundleAsync = void 0;
|
|
7
|
+
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const metro_source_map_1 = require("metro-source-map");
|
|
11
|
+
const os_1 = __importDefault(require("os"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const process_1 = __importDefault(require("process"));
|
|
57
14
|
const debug = require('debug')('expo:metro:hermes');
|
|
58
15
|
function importHermesCommandFromProject() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
16
|
+
const platformExecutable = getHermesCommandPlatform();
|
|
17
|
+
const hermescLocations = [
|
|
18
|
+
// Override hermesc dir by environment variables
|
|
19
|
+
process_1.default.env['REACT_NATIVE_OVERRIDE_HERMES_DIR']
|
|
20
|
+
? `${process_1.default.env['REACT_NATIVE_OVERRIDE_HERMES_DIR']}/build/bin/hermesc`
|
|
21
|
+
: '',
|
|
22
|
+
// Building hermes from source
|
|
23
|
+
'react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc',
|
|
24
|
+
// Prebuilt hermesc in official react-native 0.69+
|
|
25
|
+
`react-native/sdks/hermesc/${platformExecutable}`,
|
|
26
|
+
// Legacy hermes-engine package
|
|
27
|
+
`hermes-engine/${platformExecutable}`,
|
|
28
|
+
];
|
|
29
|
+
for (const location of hermescLocations) {
|
|
30
|
+
try {
|
|
31
|
+
return require.resolve(location);
|
|
32
|
+
}
|
|
33
|
+
catch { }
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Cannot find the hermesc executable.');
|
|
75
36
|
}
|
|
76
37
|
function getHermesCommandPlatform() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
38
|
+
switch (os_1.default.platform()) {
|
|
39
|
+
case 'darwin':
|
|
40
|
+
return 'osx-bin/hermesc';
|
|
41
|
+
case 'linux':
|
|
42
|
+
return 'linux64-bin/hermesc';
|
|
43
|
+
case 'win32':
|
|
44
|
+
return 'win64-bin/hermesc.exe';
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported host platform for Hermes compiler: ${os_1.default.platform()}`);
|
|
47
|
+
}
|
|
87
48
|
}
|
|
88
49
|
// Only one hermes build at a time is supported.
|
|
89
50
|
let currentHermesBuild = null;
|
|
90
51
|
async function buildHermesBundleAsync(options) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
currentHermesBuild = directlyBuildHermesBundleAsync(options);
|
|
96
|
-
return await currentHermesBuild;
|
|
97
|
-
}
|
|
98
|
-
async function directlyBuildHermesBundleAsync({
|
|
99
|
-
code,
|
|
100
|
-
map,
|
|
101
|
-
minify = false,
|
|
102
|
-
filename
|
|
103
|
-
}) {
|
|
104
|
-
const tempDir = _path().default.join(_os().default.tmpdir(), `expo-bundler-${Math.random()}-${Date.now()}`);
|
|
105
|
-
await _fsExtra().default.ensureDir(tempDir);
|
|
106
|
-
try {
|
|
107
|
-
const tempBundleFile = _path().default.join(tempDir, 'index.js');
|
|
108
|
-
await _fsExtra().default.writeFile(tempBundleFile, code);
|
|
109
|
-
if (map) {
|
|
110
|
-
const tempSourcemapFile = _path().default.join(tempDir, 'index.js.map');
|
|
111
|
-
await _fsExtra().default.writeFile(tempSourcemapFile, map);
|
|
52
|
+
if (currentHermesBuild) {
|
|
53
|
+
debug(`Waiting for existing Hermes builds to finish`);
|
|
54
|
+
await currentHermesBuild;
|
|
112
55
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
56
|
+
currentHermesBuild = directlyBuildHermesBundleAsync(options);
|
|
57
|
+
return await currentHermesBuild;
|
|
58
|
+
}
|
|
59
|
+
exports.buildHermesBundleAsync = buildHermesBundleAsync;
|
|
60
|
+
async function directlyBuildHermesBundleAsync({ code, map, minify = false, filename, }) {
|
|
61
|
+
const tempDir = path_1.default.join(os_1.default.tmpdir(), `expo-bundler-${Math.random()}-${Date.now()}`);
|
|
62
|
+
await fs_extra_1.default.ensureDir(tempDir);
|
|
63
|
+
try {
|
|
64
|
+
const tempBundleFile = path_1.default.join(tempDir, 'index.js');
|
|
65
|
+
await fs_extra_1.default.writeFile(tempBundleFile, code);
|
|
66
|
+
if (map) {
|
|
67
|
+
const tempSourcemapFile = path_1.default.join(tempDir, 'index.js.map');
|
|
68
|
+
await fs_extra_1.default.writeFile(tempSourcemapFile, map);
|
|
69
|
+
}
|
|
70
|
+
const tempHbcFile = path_1.default.join(tempDir, 'index.hbc');
|
|
71
|
+
const hermesCommand = importHermesCommandFromProject();
|
|
72
|
+
const args = ['-emit-binary', '-out', tempHbcFile, tempBundleFile];
|
|
73
|
+
if (minify) {
|
|
74
|
+
args.push('-O');
|
|
75
|
+
}
|
|
76
|
+
if (map) {
|
|
77
|
+
args.push('-output-source-map');
|
|
78
|
+
}
|
|
79
|
+
debug(`Running hermesc: ${hermesCommand} ${args.join(' ')}`);
|
|
80
|
+
await (0, spawn_async_1.default)(hermesCommand, args);
|
|
81
|
+
let hbc;
|
|
82
|
+
let sourcemap = null;
|
|
83
|
+
if (!map) {
|
|
84
|
+
hbc = await fs_extra_1.default.readFile(tempHbcFile);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
[hbc, sourcemap] = await Promise.all([
|
|
88
|
+
fs_extra_1.default.readFile(tempHbcFile),
|
|
89
|
+
createHermesSourcemapAsync(map, `${tempHbcFile}.map`),
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
hbc,
|
|
94
|
+
sourcemap,
|
|
95
|
+
};
|
|
121
96
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
} else {
|
|
129
|
-
[hbc, sourcemap] = await Promise.all([_fsExtra().default.readFile(tempHbcFile), createHermesSourcemapAsync(map, `${tempHbcFile}.map`)]);
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error(chalk_1.default.red(`\nFailed to generate Hermes bytecode for: ${filename}`));
|
|
99
|
+
if ('status' in error) {
|
|
100
|
+
console.error(error.output.join('\n'));
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
sourcemap
|
|
134
|
-
};
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error(_chalk().default.red(`\nFailed to generate Hermes bytecode for: ${filename}`));
|
|
137
|
-
if ('status' in error) {
|
|
138
|
-
console.error(error.output.join('\n'));
|
|
104
|
+
finally {
|
|
105
|
+
await fs_extra_1.default.remove(tempDir);
|
|
139
106
|
}
|
|
140
|
-
throw error;
|
|
141
|
-
} finally {
|
|
142
|
-
await _fsExtra().default.remove(tempDir);
|
|
143
|
-
}
|
|
144
107
|
}
|
|
145
108
|
async function createHermesSourcemapAsync(sourcemap, hermesMapFile) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
109
|
+
const bundlerSourcemap = JSON.parse(sourcemap);
|
|
110
|
+
const hermesSourcemap = await fs_extra_1.default.readJSON(hermesMapFile);
|
|
111
|
+
return JSON.stringify((0, metro_source_map_1.composeSourceMaps)([bundlerSourcemap, hermesSourcemap]));
|
|
149
112
|
}
|
|
150
113
|
//# sourceMappingURL=exportHermes.js.map
|