@expo/cli 0.0.0-bisect-20240612-1 → 0.0.0-bisect-20240612-2
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/bin/cli +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +41 -108
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +1 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +102 -126
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +48 -3
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +241 -26
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/run/startBundler.js +8 -1
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +2 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -13
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +103 -2
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +75 -364
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +9 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +1 -5
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +20 -28
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +1 -1
- package/package.json +2 -2
- package/build/src/start/server/metro/metroPrivateServer.js +0 -26
- package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
package/build/bin/cli
CHANGED
|
@@ -120,7 +120,7 @@ const args = (0, _arg().default)({
|
|
|
120
120
|
});
|
|
121
121
|
if (args["--version"]) {
|
|
122
122
|
// Version is added in the build script.
|
|
123
|
-
console.log("0.0.0-bisect-20240612-
|
|
123
|
+
console.log("0.0.0-bisect-20240612-2");
|
|
124
124
|
process.exit(0);
|
|
125
125
|
}
|
|
126
126
|
if (args["--non-interactive"]) {
|
|
@@ -15,8 +15,9 @@ function _export(target, all) {
|
|
|
15
15
|
}
|
|
16
16
|
_export(exports, {
|
|
17
17
|
exportEmbedAsync: ()=>exportEmbedAsync,
|
|
18
|
-
exportEmbedBundleAndAssetsAsync: ()=>exportEmbedBundleAndAssetsAsync,
|
|
19
18
|
createMetroServerAndBundleRequestAsync: ()=>createMetroServerAndBundleRequestAsync,
|
|
19
|
+
exportEmbedBundleAndAssetsAsync: ()=>exportEmbedBundleAndAssetsAsync,
|
|
20
|
+
exportEmbedBundleAsync: ()=>exportEmbedBundleAsync,
|
|
20
21
|
exportEmbedAssetsAsync: ()=>exportEmbedAssetsAsync
|
|
21
22
|
});
|
|
22
23
|
function _config() {
|
|
@@ -26,20 +27,6 @@ function _config() {
|
|
|
26
27
|
};
|
|
27
28
|
return data;
|
|
28
29
|
}
|
|
29
|
-
function _getAssets() {
|
|
30
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("@expo/metro-config/build/transform-worker/getAssets"));
|
|
31
|
-
_getAssets = function() {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
function _assert() {
|
|
37
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("assert"));
|
|
38
|
-
_assert = function() {
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
30
|
function _fs() {
|
|
44
31
|
const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
45
32
|
_fs = function() {
|
|
@@ -61,13 +48,6 @@ function _server() {
|
|
|
61
48
|
};
|
|
62
49
|
return data;
|
|
63
50
|
}
|
|
64
|
-
function _splitBundleOptions() {
|
|
65
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("metro/src/lib/splitBundleOptions"));
|
|
66
|
-
_splitBundleOptions = function() {
|
|
67
|
-
return data;
|
|
68
|
-
};
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
51
|
function _bundle() {
|
|
72
52
|
const data = /*#__PURE__*/ _interopRequireDefault(require("metro/src/shared/output/bundle"));
|
|
73
53
|
_bundle = function() {
|
|
@@ -84,15 +64,14 @@ function _path() {
|
|
|
84
64
|
}
|
|
85
65
|
const _xcodeCompilerLogger = require("./xcodeCompilerLogger");
|
|
86
66
|
const _log = require("../../log");
|
|
87
|
-
const _devServerManager = require("../../start/server/DevServerManager");
|
|
88
|
-
const _metroBundlerDevServer = require("../../start/server/metro/MetroBundlerDevServer");
|
|
89
67
|
const _instantiateMetro = require("../../start/server/metro/instantiateMetro");
|
|
90
|
-
const _metroPrivateServer = require("../../start/server/metro/metroPrivateServer");
|
|
91
68
|
const _metroOptions = require("../../start/server/middleware/metroOptions");
|
|
92
69
|
const _ansi = require("../../utils/ansi");
|
|
93
70
|
const _dir = require("../../utils/dir");
|
|
94
71
|
const _nodeEnv = require("../../utils/nodeEnv");
|
|
72
|
+
const _profile = require("../../utils/profile");
|
|
95
73
|
const _exportHermes = require("../exportHermes");
|
|
74
|
+
const _forkBundleAsync = require("../fork-bundleAsync");
|
|
96
75
|
const _persistMetroAssets = require("../persistMetroAssets");
|
|
97
76
|
function _interopRequireDefault(obj) {
|
|
98
77
|
return obj && obj.__esModule ? obj : {
|
|
@@ -146,67 +125,6 @@ async function exportEmbedAsync(projectRoot, options) {
|
|
|
146
125
|
}) : null,
|
|
147
126
|
]);
|
|
148
127
|
}
|
|
149
|
-
async function exportEmbedBundleAndAssetsAsync(projectRoot, options) {
|
|
150
|
-
const devServerManager = await _devServerManager.DevServerManager.startMetroAsync(projectRoot, {
|
|
151
|
-
minify: options.minify,
|
|
152
|
-
mode: options.dev ? "development" : "production",
|
|
153
|
-
port: 8081,
|
|
154
|
-
isExporting: true,
|
|
155
|
-
location: {},
|
|
156
|
-
resetDevServer: options.resetCache,
|
|
157
|
-
maxWorkers: options.maxWorkers
|
|
158
|
-
});
|
|
159
|
-
const devServer = devServerManager.getDefaultDevServer();
|
|
160
|
-
(0, _assert().default)(devServer instanceof _metroBundlerDevServer.MetroBundlerDevServer);
|
|
161
|
-
const exp = (0, _config().getConfig)(projectRoot, {
|
|
162
|
-
skipSDKVersionRequirement: true
|
|
163
|
-
}).exp;
|
|
164
|
-
const isHermes = (0, _exportHermes.isEnableHermesManaged)(exp, options.platform);
|
|
165
|
-
let sourceMapUrl = options.sourcemapOutput;
|
|
166
|
-
if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {
|
|
167
|
-
sourceMapUrl = _path().default.basename(sourceMapUrl);
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
var ref;
|
|
171
|
-
const bundles = await devServer.legacySinglePageExportBundleAsync({
|
|
172
|
-
splitChunks: false,
|
|
173
|
-
mainModuleName: options.entryFile,
|
|
174
|
-
platform: options.platform,
|
|
175
|
-
minify: options.minify,
|
|
176
|
-
mode: options.dev ? "development" : "production",
|
|
177
|
-
engine: isHermes ? "hermes" : undefined,
|
|
178
|
-
serializerIncludeMaps: !!sourceMapUrl,
|
|
179
|
-
// Never output bytecode in the exported bundle since that is hardcoded in the native run script.
|
|
180
|
-
bytecode: false
|
|
181
|
-
}, {
|
|
182
|
-
sourceMapUrl,
|
|
183
|
-
unstable_transformProfile: options.unstableTransformProfile || (isHermes ? "hermes-stable" : "default")
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
bundle: {
|
|
187
|
-
code: bundles.artifacts.filter((a)=>a.type === "js")[0].source.toString(),
|
|
188
|
-
// Can be optional when source maps aren't enabled.
|
|
189
|
-
map: (ref = bundles.artifacts.filter((a)=>a.type === "map")[0]) == null ? void 0 : ref.source.toString()
|
|
190
|
-
},
|
|
191
|
-
assets: bundles.assets
|
|
192
|
-
};
|
|
193
|
-
} catch (error) {
|
|
194
|
-
if (isError(error)) {
|
|
195
|
-
// Log using Xcode error format so the errors are picked up by xcodebuild.
|
|
196
|
-
// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script
|
|
197
|
-
if (options.platform === "ios") {
|
|
198
|
-
// If the error is about to be presented in Xcode, strip the ansi characters from the message.
|
|
199
|
-
if ("message" in error && (0, _xcodeCompilerLogger.isExecutingFromXcodebuild)()) {
|
|
200
|
-
error.message = (0, _ansi.stripAnsi)(error.message);
|
|
201
|
-
}
|
|
202
|
-
(0, _xcodeCompilerLogger.logMetroErrorInXcode)(projectRoot, error);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
throw error;
|
|
206
|
-
} finally{
|
|
207
|
-
devServerManager.stopAsync();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
128
|
async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
|
|
211
129
|
const exp = (0, _config().getConfig)(projectRoot, {
|
|
212
130
|
skipSDKVersionRequirement: true
|
|
@@ -238,9 +156,8 @@ async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
|
|
|
238
156
|
minify: options.minify,
|
|
239
157
|
mode: options.dev ? "development" : "production",
|
|
240
158
|
engine: isHermes ? "hermes" : undefined,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
bytecode: false
|
|
159
|
+
bytecode: isHermes,
|
|
160
|
+
isExporting: true
|
|
244
161
|
}),
|
|
245
162
|
sourceMapUrl,
|
|
246
163
|
unstable_transformProfile: options.unstableTransformProfile || (isHermes ? "hermes-stable" : "default")
|
|
@@ -253,30 +170,46 @@ async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
|
|
|
253
170
|
bundleRequest
|
|
254
171
|
};
|
|
255
172
|
}
|
|
173
|
+
async function exportEmbedBundleAndAssetsAsync(projectRoot, options) {
|
|
174
|
+
const { server , bundleRequest } = await createMetroServerAndBundleRequestAsync(projectRoot, options);
|
|
175
|
+
try {
|
|
176
|
+
const bundle = await exportEmbedBundleAsync(server, bundleRequest, projectRoot, options);
|
|
177
|
+
const assets = await exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options);
|
|
178
|
+
return {
|
|
179
|
+
bundle,
|
|
180
|
+
assets
|
|
181
|
+
};
|
|
182
|
+
} finally{
|
|
183
|
+
server.end();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function exportEmbedBundleAsync(server, bundleRequest, projectRoot, options) {
|
|
187
|
+
try {
|
|
188
|
+
return await (0, _profile.profile)(server.build.bind(server), "metro-bundle")({
|
|
189
|
+
...bundleRequest,
|
|
190
|
+
bundleType: "bundle"
|
|
191
|
+
});
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (isError(error)) {
|
|
194
|
+
// Log using Xcode error format so the errors are picked up by xcodebuild.
|
|
195
|
+
// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script
|
|
196
|
+
if (options.platform === "ios") {
|
|
197
|
+
// If the error is about to be presented in Xcode, strip the ansi characters from the message.
|
|
198
|
+
if ("message" in error && (0, _xcodeCompilerLogger.isExecutingFromXcodebuild)()) {
|
|
199
|
+
error.message = (0, _ansi.stripAnsi)(error.message);
|
|
200
|
+
}
|
|
201
|
+
(0, _xcodeCompilerLogger.logMetroErrorInXcode)(projectRoot, error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
256
207
|
async function exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options) {
|
|
257
208
|
try {
|
|
258
|
-
|
|
209
|
+
return await (0, _forkBundleAsync.getAssets)(server, {
|
|
259
210
|
...bundleRequest,
|
|
260
211
|
bundleType: "todo"
|
|
261
212
|
});
|
|
262
|
-
(0, _metroPrivateServer.assertMetroPrivateServer)(server);
|
|
263
|
-
const dependencies = await server._bundler.getDependencies([
|
|
264
|
-
entryFile
|
|
265
|
-
], transformOptions, resolverOptions, {
|
|
266
|
-
onProgress,
|
|
267
|
-
shallow: false,
|
|
268
|
-
lazy: false
|
|
269
|
-
});
|
|
270
|
-
const config = server._config;
|
|
271
|
-
return (0, _getAssets().default)(dependencies, {
|
|
272
|
-
processModuleFilter: config.serializer.processModuleFilter,
|
|
273
|
-
assetPlugins: config.transformer.assetPlugins,
|
|
274
|
-
platform: transformOptions.platform,
|
|
275
|
-
// Forked out of Metro because the `this._getServerRootDir()` doesn't match the development
|
|
276
|
-
// behavior.
|
|
277
|
-
projectRoot: config.projectRoot,
|
|
278
|
-
publicPath: config.transformer.publicPath
|
|
279
|
-
});
|
|
280
213
|
} catch (error) {
|
|
281
214
|
if (isError(error)) {
|
|
282
215
|
// Log using Xcode error format so the errors are picked up by xcodebuild.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\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 { getConfig } from '@expo/config';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { assertMetroPrivateServer } from '../../start/server/metro/metroPrivateServer';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { BundleAssetWithFileHashes } from '../fork-bundleAsync';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n try {\n const bundles = await devServer.legacySinglePageExportBundleAsync(\n {\n splitChunks: false,\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n // source map inline\n },\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n return {\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0].source.toString(),\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString(),\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n\n maxWorkers: options.maxWorkers,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n assertMetroPrivateServer(server);\n\n const dependencies = await server._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n\n/**\n * This is a workaround for Metro not resolving entry file paths to their real location.\n * When running exports through `eas build --local` on macOS, the `/var/folders` path is used instead of `/private/var/folders`.\n *\n * See: https://github.com/expo/expo/issues/28890\n */\nfunction resolveRealEntryFilePath(projectRoot: string, entryFile: string): string {\n if (projectRoot.startsWith('/private/var') && entryFile.startsWith('/var')) {\n return fs.realpathSync(entryFile);\n }\n\n return entryFile;\n}\n"],"names":["exportEmbedAsync","exportEmbedBundleAndAssetsAsync","createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","resetCache","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundles","legacySinglePageExportBundleAsync","splitChunks","mainModuleName","entryFile","engine","undefined","serializerIncludeMaps","bytecode","unstable_transformProfile","unstableTransformProfile","code","artifacts","filter","a","type","source","toString","map","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","server","getBundler","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","resolveRealEntryFilePath","watch","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","assertMetroPrivateServer","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","Error","startsWith","realpathSync"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA4CsBA,gBAAgB,MAAhBA,gBAAgB;IAoChBC,+BAA+B,MAA/BA,+BAA+B;IA4E/BC,sCAAsC,MAAtCA,sCAAsC;IAqEtCC,sBAAsB,MAAtBA,sBAAsB;;;yBAjOlB,cAAc;;;;;;;8DACb,qDAAqD;;;;;;;8DAC7D,QAAQ;;;;;;;8DACZ,IAAI;;;;;;;yBACc,MAAM;;;;;;;8DACpB,kBAAkB;;;;;;;8DACN,kCAAkC;;;;;;;8DAC9C,gCAAgC;;;;;;;8DAElC,MAAM;;;;;;qCAGyC,uBAAuB;qBACnE,WAAW;kCACE,qCAAqC;uCAChC,gDAAgD;kCACjD,2CAA2C;oCACvC,6CAA6C;8BAC7B,4CAA4C;sBAC3E,kBAAkB;qBAChB,iBAAiB;yBAClB,qB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,YAAY;YAC7C9F,QAAQ,EAAEiF,gBAAgB,CAACjF,QAAQ;YACnC,2FAA2F;YAC3F,YAAY;YACZN,WAAW,EAAE0E,MAAM,CAAC1E,WAAW;YAC/BsG,UAAU,EAAE5B,MAAM,CAAC2B,WAAW,CAACC,UAAU;SAC1C,CAAC,CAAC;IACL,EAAE,OAAOnC,KAAK,EAAO;QACnB,IAAIC,OAAO,CAACD,KAAK,CAAC,EAAE;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAIlE,OAAO,CAACK,QAAQ,KAAK,KAAK,EAAE;gBAC9B,8FAA8F;gBAC9F,IAAI,SAAS,IAAI6D,KAAK,IAAIE,IAAAA,oBAAyB,0BAAA,GAAE,EAAE;oBACrDF,KAAK,CAACG,OAAO,GAAGC,IAAAA,KAAS,UAAA,EAACJ,KAAK,CAACG,OAAO,CAAC,AAAU,CAAC;gBACrD,CAAC;gBACDE,IAAAA,oBAAoB,qBAAA,EAACxE,WAAW,EAAEmE,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,MAAMA,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAASC,OAAO,CAACD,KAAU,EAAkB;IAC3C,OAAOA,KAAK,YAAYoC,KAAK,CAAC;AAChC,CAAC;AAED;;;;;CAKC,GACD,SAASpB,wBAAwB,CAACnF,WAAmB,EAAEoD,SAAiB,EAAU;IAChF,IAAIpD,WAAW,CAACwG,UAAU,CAAC,cAAc,CAAC,IAAIpD,SAAS,CAACoD,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1E,OAAOhG,GAAE,EAAA,QAAA,CAACiG,YAAY,CAACrD,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAOA,SAAS,CAAC;AACnB,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\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 { getConfig } from '@expo/config';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { profile } from '../../utils/profile';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { getAssets } from '../fork-bundleAsync';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n\n maxWorkers: options.maxWorkers,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n bytecode: isHermes,\n isExporting: true,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: Awaited<ReturnType<typeof getAssets>>;\n}> {\n const { server, bundleRequest } = await createMetroServerAndBundleRequestAsync(\n projectRoot,\n options\n );\n\n try {\n const bundle = await exportEmbedBundleAsync(server, bundleRequest, projectRoot, options);\n const assets = await exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options);\n return { bundle, assets };\n } finally {\n server.end();\n }\n}\n\nexport async function exportEmbedBundleAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n return await profile(\n server.build.bind(server),\n 'metro-bundle'\n )({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n return await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n\n/**\n * This is a workaround for Metro not resolving entry file paths to their real location.\n * When running exports through `eas build --local` on macOS, the `/var/folders` path is used instead of `/private/var/folders`.\n *\n * See: https://github.com/expo/expo/issues/28890\n */\nfunction resolveRealEntryFilePath(projectRoot: string, entryFile: string): string {\n if (projectRoot.startsWith('/private/var') && entryFile.startsWith('/var')) {\n return fs.realpathSync(entryFile);\n }\n\n return entryFile;\n}\n"],"names":["exportEmbedAsync","createMetroServerAndBundleRequestAsync","exportEmbedBundleAndAssetsAsync","exportEmbedBundleAsync","exportEmbedAssetsAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","exp","getConfig","skipSDKVersionRequirement","config","loadMetroConfigAsync","resetCache","maxWorkers","isExporting","getMetroBundler","server","getBundler","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","splitChunks","mainModuleName","resolveRealEntryFilePath","entryFile","minify","engine","undefined","bytecode","unstable_transformProfile","unstableTransformProfile","watch","end","profile","build","bind","bundleType","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","getAssets","Error","startsWith","realpathSync"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAuCsBA,gBAAgB,MAAhBA,gBAAgB;IAoChBC,sCAAsC,MAAtCA,sCAA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,EAACJ,KAAK,CAACG,OAAO,CAAC,AAAU,CAAC;gBACrD,CAAC;gBACDE,IAAAA,oBAAoB,qBAAA,EAACnE,WAAW,EAAE8D,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,MAAMA,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAASC,OAAO,CAACD,KAAU,EAAkB;IAC3C,OAAOA,KAAK,YAAYO,KAAK,CAAC;AAChC,CAAC;AAED;;;;;CAKC,GACD,SAASrB,wBAAwB,CAAChD,WAAmB,EAAEiD,SAAiB,EAAU;IAChF,IAAIjD,WAAW,CAACsE,UAAU,CAAC,cAAc,CAAC,IAAIrB,SAAS,CAACqB,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1E,OAAO9D,GAAE,EAAA,QAAA,CAAC+D,YAAY,CAACtB,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAOA,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -57,6 +57,7 @@ function resolveOptions(args, parsed) {
|
|
|
57
57
|
assetsDest: args["--assets-dest"],
|
|
58
58
|
unstableTransformProfile: args["--unstable-transform-profile"],
|
|
59
59
|
resetCache: !!parsed.args["--reset-cache"],
|
|
60
|
+
resetGlobalCache: false,
|
|
60
61
|
verbose: (ref4 = args["--verbose"]) != null ? ref4 : _env.env.EXPO_DEBUG,
|
|
61
62
|
config: args["--config"] ? _path().default.resolve(args["--config"]) : undefined,
|
|
62
63
|
dev,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/resolveOptions.ts"],"sourcesContent":["import arg from 'arg';\nimport path from 'path';\n\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { resolveCustomBooleanArgsAsync } from '../../utils/resolveArgs';\n\nexport interface Options {\n assetsDest?: string;\n assetCatalogDest?: string;\n entryFile: string;\n resetCache: boolean;\n transformer?: string;\n minify?: boolean;\n config?: string;\n platform: string;\n dev: boolean;\n bundleOutput: string;\n bundleEncoding?: string;\n maxWorkers?: number;\n sourcemapOutput?: string;\n sourcemapSourcesRoot?: string;\n sourcemapUseAbsolutePath: boolean;\n verbose: boolean;\n unstableTransformProfile?: string;\n}\n\nfunction assertIsBoolean(val: any): asserts val is boolean {\n if (typeof val !== 'boolean') {\n throw new CommandError(`Expected boolean, got ${typeof val}`);\n }\n}\n\nexport function resolveOptions(\n args: arg.Result<arg.Spec>,\n parsed: Awaited<ReturnType<typeof resolveCustomBooleanArgsAsync>>\n): Options {\n const dev = parsed.args['--dev'] ?? true;\n assertIsBoolean(dev);\n\n const minify = parsed.args['--minify'] ?? !dev;\n assertIsBoolean(minify);\n\n const entryFile = args['--entry-file'];\n if (!entryFile) {\n throw new CommandError(`Missing required argument: --entry-file`);\n }\n const bundleOutput = args['--bundle-output'];\n if (!bundleOutput) {\n throw new CommandError(`Missing required argument: --bundle-output`);\n }\n return {\n entryFile,\n assetCatalogDest: args['--asset-catalog-dest'],\n platform: args['--platform'] ?? 'ios',\n transformer: args['--transformer'],\n // TODO: Support `--dev false`\n // dev: false,\n bundleOutput,\n bundleEncoding: args['--bundle-encoding'] ?? 'utf8',\n maxWorkers: args['--max-workers'],\n sourcemapOutput: args['--sourcemap-output'],\n sourcemapSourcesRoot: args['--sourcemap-sources-root'],\n sourcemapUseAbsolutePath: !!parsed.args['--sourcemap-use-absolute-path'],\n assetsDest: args['--assets-dest'],\n unstableTransformProfile: args['--unstable-transform-profile'],\n resetCache: !!parsed.args['--reset-cache'],\n verbose: args['--verbose'] ?? env.EXPO_DEBUG,\n config: args['--config'] ? path.resolve(args['--config']) : undefined,\n dev,\n minify,\n };\n}\n"],"names":["resolveOptions","assertIsBoolean","val","CommandError","args","parsed","dev","minify","entryFile","bundleOutput","assetCatalogDest","platform","transformer","bundleEncoding","maxWorkers","sourcemapOutput","sourcemapSourcesRoot","sourcemapUseAbsolutePath","assetsDest","unstableTransformProfile","resetCache","verbose","env","EXPO_DEBUG","config","path","resolve","undefined"],"mappings":"AAAA;;;;+
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/resolveOptions.ts"],"sourcesContent":["import arg from 'arg';\nimport path from 'path';\n\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { resolveCustomBooleanArgsAsync } from '../../utils/resolveArgs';\n\nexport interface Options {\n assetsDest?: string;\n assetCatalogDest?: string;\n entryFile: string;\n resetCache: boolean;\n resetGlobalCache: boolean;\n transformer?: string;\n minify?: boolean;\n config?: string;\n platform: string;\n dev: boolean;\n bundleOutput: string;\n bundleEncoding?: string;\n maxWorkers?: number;\n sourcemapOutput?: string;\n sourcemapSourcesRoot?: string;\n sourcemapUseAbsolutePath: boolean;\n verbose: boolean;\n unstableTransformProfile?: string;\n}\n\nfunction assertIsBoolean(val: any): asserts val is boolean {\n if (typeof val !== 'boolean') {\n throw new CommandError(`Expected boolean, got ${typeof val}`);\n }\n}\n\nexport function resolveOptions(\n args: arg.Result<arg.Spec>,\n parsed: Awaited<ReturnType<typeof resolveCustomBooleanArgsAsync>>\n): Options {\n const dev = parsed.args['--dev'] ?? true;\n assertIsBoolean(dev);\n\n const minify = parsed.args['--minify'] ?? !dev;\n assertIsBoolean(minify);\n\n const entryFile = args['--entry-file'];\n if (!entryFile) {\n throw new CommandError(`Missing required argument: --entry-file`);\n }\n const bundleOutput = args['--bundle-output'];\n if (!bundleOutput) {\n throw new CommandError(`Missing required argument: --bundle-output`);\n }\n return {\n entryFile,\n assetCatalogDest: args['--asset-catalog-dest'],\n platform: args['--platform'] ?? 'ios',\n transformer: args['--transformer'],\n // TODO: Support `--dev false`\n // dev: false,\n bundleOutput,\n bundleEncoding: args['--bundle-encoding'] ?? 'utf8',\n maxWorkers: args['--max-workers'],\n sourcemapOutput: args['--sourcemap-output'],\n sourcemapSourcesRoot: args['--sourcemap-sources-root'],\n sourcemapUseAbsolutePath: !!parsed.args['--sourcemap-use-absolute-path'],\n assetsDest: args['--assets-dest'],\n unstableTransformProfile: args['--unstable-transform-profile'],\n resetCache: !!parsed.args['--reset-cache'],\n resetGlobalCache: false,\n verbose: args['--verbose'] ?? env.EXPO_DEBUG,\n config: args['--config'] ? path.resolve(args['--config']) : undefined,\n dev,\n minify,\n };\n}\n"],"names":["resolveOptions","assertIsBoolean","val","CommandError","args","parsed","dev","minify","entryFile","bundleOutput","assetCatalogDest","platform","transformer","bundleEncoding","maxWorkers","sourcemapOutput","sourcemapSourcesRoot","sourcemapUseAbsolutePath","assetsDest","unstableTransformProfile","resetCache","resetGlobalCache","verbose","env","EXPO_DEBUG","config","path","resolve","undefined"],"mappings":"AAAA;;;;+BAkCgBA,gBAAc;;aAAdA,cAAc;;;8DAjCb,MAAM;;;;;;qBAEH,iBAAiB;wBACR,oBAAoB;;;;;;AAwBjD,SAASC,eAAe,CAACC,GAAQ,EAA0B;IACzD,IAAI,OAAOA,GAAG,KAAK,SAAS,EAAE;QAC5B,MAAM,IAAIC,OAAY,aAAA,CAAC,CAAC,sBAAsB,EAAE,OAAOD,GAAG,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAEM,SAASF,cAAc,CAC5BI,IAA0B,EAC1BC,MAAiE,EACxD;QACGA,GAAoB;IAAhC,MAAMC,GAAG,GAAGD,CAAAA,GAAoB,GAApBA,MAAM,CAACD,IAAI,CAAC,OAAO,CAAC,YAApBC,GAAoB,GAAI,IAAI,AAAC;IACzCJ,eAAe,CAACK,GAAG,CAAC,CAAC;QAEND,IAAuB;IAAtC,MAAME,MAAM,GAAGF,CAAAA,IAAuB,GAAvBA,MAAM,CAACD,IAAI,CAAC,UAAU,CAAC,YAAvBC,IAAuB,GAAI,CAACC,GAAG,AAAC;IAC/CL,eAAe,CAACM,MAAM,CAAC,CAAC;IAExB,MAAMC,SAAS,GAAGJ,IAAI,CAAC,cAAc,CAAC,AAAC;IACvC,IAAI,CAACI,SAAS,EAAE;QACd,MAAM,IAAIL,OAAY,aAAA,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC;IACpE,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AS;QACrEtB,GAAG;QACHC,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -13,13 +13,6 @@ function _config() {
|
|
|
13
13
|
};
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
-
function _assert() {
|
|
17
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("assert"));
|
|
18
|
-
_assert = function() {
|
|
19
|
-
return data;
|
|
20
|
-
};
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
16
|
function _chalk() {
|
|
24
17
|
const data = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
|
|
25
18
|
_chalk = function() {
|
|
@@ -45,8 +38,6 @@ const _saveAssets = require("./saveAssets");
|
|
|
45
38
|
const _writeContents = require("./writeContents");
|
|
46
39
|
const _log = /*#__PURE__*/ _interopRequireWildcard(require("../log"));
|
|
47
40
|
const _webSupportProjectPrerequisite = require("../start/doctor/web/WebSupportProjectPrerequisite");
|
|
48
|
-
const _devServerManager = require("../start/server/DevServerManager");
|
|
49
|
-
const _metroBundlerDevServer = require("../start/server/metro/MetroBundlerDevServer");
|
|
50
41
|
const _router = require("../start/server/metro/router");
|
|
51
42
|
const _serializeHtml = require("../start/server/metro/serializeHtml");
|
|
52
43
|
const _metroOptions = require("../start/server/middleware/metroOptions");
|
|
@@ -130,136 +121,121 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
130
121
|
const mode = dev ? "development" : "production";
|
|
131
122
|
const publicPath = _path().default.resolve(projectRoot, _env.env.EXPO_PUBLIC_FOLDER);
|
|
132
123
|
const outputPath = _path().default.resolve(projectRoot, outputDir);
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
// NOTE(kitten): The public folder is currently always copied, regardless of targetDomain
|
|
125
|
+
// split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`
|
|
126
|
+
await (0, _publicFolder.copyPublicFolderAsync)(publicPath, outputPath);
|
|
127
|
+
// Run metro bundler and create the JS bundles/source maps.
|
|
128
|
+
const bundles = await (0, _forkBundleAsync.createBundlesAsync)(projectRoot, projectConfig, {
|
|
129
|
+
clear: !!clear,
|
|
136
130
|
minify,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
resetDevServer: clear,
|
|
131
|
+
bytecode,
|
|
132
|
+
sourcemaps: sourceMaps,
|
|
133
|
+
platforms: useServerRendering ? platforms.filter((platform)=>platform !== "web") : platforms,
|
|
134
|
+
dev,
|
|
142
135
|
maxWorkers
|
|
143
136
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
// Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
|
|
138
|
+
const files = new Map();
|
|
139
|
+
Object.values(bundles).forEach((bundle)=>{
|
|
140
|
+
(0, _saveAssets.getFilesFromSerialAssets)(bundle.artifacts, {
|
|
141
|
+
includeSourceMaps: sourceMaps,
|
|
142
|
+
files
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
const bundleEntries = Object.entries(bundles);
|
|
146
|
+
// Can be empty during web-only SSG.
|
|
147
|
+
if (bundleEntries.length) {
|
|
148
|
+
// TODO: Use same asset system across platforms again.
|
|
149
|
+
const { assets , embeddedHashSet } = await (0, _exportAssets.exportAssetsAsync)(projectRoot, {
|
|
150
|
+
files,
|
|
151
|
+
exp,
|
|
152
|
+
outputDir: outputPath,
|
|
153
|
+
bundles,
|
|
154
|
+
baseUrl
|
|
159
155
|
});
|
|
160
|
-
|
|
161
|
-
(
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
if (dumpAssetmap) {
|
|
157
|
+
_log.log("Creating asset map");
|
|
158
|
+
files.set("assetmap.json", {
|
|
159
|
+
contents: JSON.stringify((0, _writeContents.createAssetMap)({
|
|
160
|
+
assets
|
|
161
|
+
}))
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const fileNames = Object.fromEntries(Object.entries(bundles).map(([platform, bundle])=>[
|
|
165
|
+
platform,
|
|
166
|
+
bundle.artifacts.filter((asset)=>asset.type === "js").map((asset)=>asset.filename),
|
|
167
|
+
]));
|
|
168
|
+
// build source maps
|
|
169
|
+
if (sourceMaps) {
|
|
170
|
+
_log.log("Preparing additional debugging files");
|
|
171
|
+
// If we output source maps, then add a debug HTML file which the user can open in
|
|
172
|
+
// the web browser to inspect the output like web.
|
|
173
|
+
files.set("debug.html", {
|
|
174
|
+
contents: (0, _writeContents.createSourceMapDebugHtml)({
|
|
175
|
+
fileNames: Object.values(fileNames).flat()
|
|
176
|
+
})
|
|
164
177
|
});
|
|
178
|
+
}
|
|
179
|
+
// Generate a `metadata.json` for EAS Update.
|
|
180
|
+
const contents = (0, _createMetadataJson.createMetadataJson)({
|
|
181
|
+
bundles,
|
|
182
|
+
fileNames,
|
|
183
|
+
embeddedHashSet
|
|
184
|
+
});
|
|
185
|
+
files.set("metadata.json", {
|
|
186
|
+
contents: JSON.stringify(contents)
|
|
165
187
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
188
|
+
}
|
|
189
|
+
// Additional web-only steps...
|
|
190
|
+
if (platforms.includes("web")) {
|
|
191
|
+
if (useServerRendering) {
|
|
192
|
+
var ref2;
|
|
193
|
+
const exportServer = ((ref2 = exp.web) == null ? void 0 : ref2.output) === "server";
|
|
194
|
+
if (exportServer) {
|
|
195
|
+
// TODO: Remove when this is abstracted into the files map
|
|
196
|
+
await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _path().default.resolve(outputPath, "client"));
|
|
197
|
+
}
|
|
198
|
+
await (0, _exportStaticAsync.unstable_exportStaticAsync)(projectRoot, {
|
|
199
|
+
mode,
|
|
171
200
|
files,
|
|
172
|
-
|
|
201
|
+
clear: !!clear,
|
|
173
202
|
outputDir: outputPath,
|
|
174
|
-
|
|
175
|
-
baseUrl
|
|
203
|
+
minify,
|
|
204
|
+
baseUrl,
|
|
205
|
+
includeSourceMaps: sourceMaps,
|
|
206
|
+
routerRoot: (0, _router.getRouterDirectoryModuleIdWithManifest)(projectRoot, exp),
|
|
207
|
+
exportServer,
|
|
208
|
+
maxWorkers,
|
|
209
|
+
isExporting: true
|
|
176
210
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
]));
|
|
189
|
-
// build source maps
|
|
190
|
-
if (sourceMaps) {
|
|
191
|
-
_log.log("Preparing additional debugging files");
|
|
192
|
-
// If we output source maps, then add a debug HTML file which the user can open in
|
|
193
|
-
// the web browser to inspect the output like web.
|
|
194
|
-
files.set("debug.html", {
|
|
195
|
-
contents: (0, _writeContents.createSourceMapDebugHtml)({
|
|
196
|
-
fileNames: Object.values(fileNames).flat()
|
|
197
|
-
})
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
// Generate a `metadata.json` for EAS Update.
|
|
201
|
-
const contents = (0, _createMetadataJson.createMetadataJson)({
|
|
202
|
-
bundles,
|
|
203
|
-
fileNames,
|
|
204
|
-
embeddedHashSet
|
|
211
|
+
} else {
|
|
212
|
+
// TODO: Unify with exportStaticAsync
|
|
213
|
+
// TODO: Maybe move to the serializer.
|
|
214
|
+
let html = await (0, _serializeHtml.serializeHtmlWithAssets)({
|
|
215
|
+
isExporting: true,
|
|
216
|
+
resources: bundles.web.artifacts,
|
|
217
|
+
template: await (0, _webTemplate.createTemplateHtmlFromExpoConfigAsync)(projectRoot, {
|
|
218
|
+
scripts: [],
|
|
219
|
+
cssLinks: []
|
|
220
|
+
}),
|
|
221
|
+
baseUrl
|
|
205
222
|
});
|
|
206
|
-
|
|
207
|
-
|
|
223
|
+
// Add the favicon assets to the HTML.
|
|
224
|
+
const modifyHtml = await (0, _favicon.getVirtualFaviconAssetsAsync)(projectRoot, {
|
|
225
|
+
outputDir,
|
|
226
|
+
baseUrl,
|
|
227
|
+
files
|
|
208
228
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (platforms.includes("web")) {
|
|
212
|
-
if (useServerRendering) {
|
|
213
|
-
var ref2;
|
|
214
|
-
const exportServer = ((ref2 = exp.web) == null ? void 0 : ref2.output) === "server";
|
|
215
|
-
if (exportServer) {
|
|
216
|
-
// TODO: Remove when this is abstracted into the files map
|
|
217
|
-
await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _path().default.resolve(outputPath, "client"));
|
|
218
|
-
}
|
|
219
|
-
await (0, _exportStaticAsync.exportFromServerAsync)(projectRoot, devServer, {
|
|
220
|
-
mode,
|
|
221
|
-
files,
|
|
222
|
-
clear: !!clear,
|
|
223
|
-
outputDir: outputPath,
|
|
224
|
-
minify,
|
|
225
|
-
baseUrl,
|
|
226
|
-
includeSourceMaps: sourceMaps,
|
|
227
|
-
routerRoot: (0, _router.getRouterDirectoryModuleIdWithManifest)(projectRoot, exp),
|
|
228
|
-
exportServer,
|
|
229
|
-
maxWorkers,
|
|
230
|
-
isExporting: true
|
|
231
|
-
});
|
|
232
|
-
} else {
|
|
233
|
-
// TODO: Unify with exportStaticAsync
|
|
234
|
-
// TODO: Maybe move to the serializer.
|
|
235
|
-
let html = await (0, _serializeHtml.serializeHtmlWithAssets)({
|
|
236
|
-
isExporting: true,
|
|
237
|
-
resources: bundles.web.artifacts,
|
|
238
|
-
template: await (0, _webTemplate.createTemplateHtmlFromExpoConfigAsync)(projectRoot, {
|
|
239
|
-
scripts: [],
|
|
240
|
-
cssLinks: []
|
|
241
|
-
}),
|
|
242
|
-
baseUrl
|
|
243
|
-
});
|
|
244
|
-
// Add the favicon assets to the HTML.
|
|
245
|
-
const modifyHtml = await (0, _favicon.getVirtualFaviconAssetsAsync)(projectRoot, {
|
|
246
|
-
outputDir,
|
|
247
|
-
baseUrl,
|
|
248
|
-
files
|
|
249
|
-
});
|
|
250
|
-
if (modifyHtml) {
|
|
251
|
-
html = modifyHtml(html);
|
|
252
|
-
}
|
|
253
|
-
// Generate SPA-styled HTML file.
|
|
254
|
-
// If web exists, then write the template HTML file.
|
|
255
|
-
files.set("index.html", {
|
|
256
|
-
contents: html,
|
|
257
|
-
targetDomain: "client"
|
|
258
|
-
});
|
|
229
|
+
if (modifyHtml) {
|
|
230
|
+
html = modifyHtml(html);
|
|
259
231
|
}
|
|
232
|
+
// Generate SPA-styled HTML file.
|
|
233
|
+
// If web exists, then write the template HTML file.
|
|
234
|
+
files.set("index.html", {
|
|
235
|
+
contents: html,
|
|
236
|
+
targetDomain: "client"
|
|
237
|
+
});
|
|
260
238
|
}
|
|
261
|
-
} finally{
|
|
262
|
-
await devServerManager.stopAsync();
|
|
263
239
|
}
|
|
264
240
|
// Write all files at the end for unified logging.
|
|
265
241
|
await (0, _saveAssets.persistMetroFilesAsync)(files, outputPath);
|