@expo/cli 0.13.2 → 0.15.0
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 +30 -27
- package/build/bin/cli.map +1 -1
- package/build/src/api/getVersions.js.map +1 -1
- package/build/src/api/rest/cache/response.js.map +1 -1
- package/build/src/api/rest/client.js +2 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/config/index.js +2 -2
- package/build/src/config/index.js.map +1 -1
- package/build/src/customize/generate.js +1 -1
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/typescript.js +6 -4
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/createMetadataJson.js +3 -2
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +44 -17
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +4 -4
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +3 -3
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +74 -83
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +81 -21
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +24 -14
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +109 -58
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +2 -2
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +56 -23
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +11 -9
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js +101 -0
- package/build/src/export/metroAssetLocalPath.js.map +1 -0
- package/build/src/export/persistMetroAssets.js +94 -21
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -1
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +9 -48
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/web/index.js +2 -2
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/export/writeContents.js +6 -3
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/applyPlugins.js +52 -0
- package/build/src/install/applyPlugins.js.map +1 -0
- package/build/src/install/checkPackages.js +2 -2
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/fixPackages.js +84 -0
- package/build/src/install/fixPackages.js.map +1 -0
- package/build/src/install/installAsync.js +32 -61
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/installExpoPackage.js +79 -0
- package/build/src/install/installExpoPackage.js.map +1 -0
- package/build/src/login/index.js +1 -1
- package/build/src/login/index.js.map +1 -1
- package/build/src/logout/index.js +1 -1
- package/build/src/logout/index.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +1 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +3 -3
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +21 -30
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +3 -3
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +39 -17
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +2 -2
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -6
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +49 -36
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
- package/build/src/register/index.js +1 -1
- package/build/src/register/index.js.map +1 -1
- package/build/src/run/android/index.js +2 -2
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/index.js +2 -2
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/index.js +3 -3
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +30 -11
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +14 -10
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +6 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +63 -0
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/getStaticRenderFunctions.js +21 -20
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +67 -64
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +4 -19
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +187 -0
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
- package/build/src/start/server/metro/createJResolver.js +149 -0
- package/build/src/start/server/metro/createJResolver.js.map +1 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/externals.js +25 -3
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js +72 -0
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +37 -16
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +3 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +6 -3
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +19 -10
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +43 -0
- package/build/src/start/server/metro/serializeHtml.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +268 -191
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +114 -40
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +45 -68
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +123 -0
- package/build/src/start/server/middleware/metroOptions.js.map +1 -0
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +1 -1
- package/build/src/start/server/type-generation/expo-env.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +1 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
- package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -2
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/args.js +4 -2
- package/build/src/utils/args.js.map +1 -1
- package/build/src/utils/cocoapods.js +2 -1
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +18 -8
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +6 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/getOrPromptApplicationId.js +2 -4
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
- package/build/src/utils/prompts.js +1 -28
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/whoami/index.js +1 -1
- package/build/src/whoami/index.js.map +1 -1
- package/package.json +16 -16
- package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
- package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
- package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
- package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
- package/build/src/export/createBundles.js +0 -37
- package/build/src/export/createBundles.js.map +0 -1
- package/build/src/start/server/metro/resolveFromProject.js +0 -90
- package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
|
@@ -3,15 +3,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.exportEmbedAsync = exportEmbedAsync;
|
|
6
|
+
exports.exportEmbedBundleAsync = exportEmbedBundleAsync;
|
|
7
|
+
var _config = require("@expo/config");
|
|
6
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
7
9
|
var _server = _interopRequireDefault(require("metro/src/Server"));
|
|
8
10
|
var _bundle = _interopRequireDefault(require("metro/src/shared/output/bundle"));
|
|
9
11
|
var _path = _interopRequireDefault(require("path"));
|
|
10
12
|
var _log = require("../../log");
|
|
11
13
|
var _instantiateMetro = require("../../start/server/metro/instantiateMetro");
|
|
12
|
-
var
|
|
14
|
+
var _metroOptions = require("../../start/server/middleware/metroOptions");
|
|
13
15
|
var _nodeEnv = require("../../utils/nodeEnv");
|
|
16
|
+
var _profile = require("../../utils/profile");
|
|
17
|
+
var _exportHermes = require("../exportHermes");
|
|
14
18
|
var _forkBundleAsync = require("../fork-bundleAsync");
|
|
19
|
+
var _persistMetroAssets = require("../persistMetroAssets");
|
|
15
20
|
function _interopRequireDefault(obj) {
|
|
16
21
|
return obj && obj.__esModule ? obj : {
|
|
17
22
|
default: obj
|
|
@@ -20,49 +25,71 @@ function _interopRequireDefault(obj) {
|
|
|
20
25
|
async function exportEmbedAsync(projectRoot, options) {
|
|
21
26
|
(0, _nodeEnv).setNodeEnv(options.dev ? "development" : "production");
|
|
22
27
|
require("@expo/env").load(projectRoot);
|
|
28
|
+
const { bundle , assets } = await exportEmbedBundleAsync(projectRoot, options);
|
|
29
|
+
_fs.default.mkdirSync(_path.default.dirname(options.bundleOutput), {
|
|
30
|
+
recursive: true,
|
|
31
|
+
mode: 493
|
|
32
|
+
});
|
|
33
|
+
// Persist bundle and source maps.
|
|
34
|
+
await Promise.all([
|
|
35
|
+
_bundle.default.save(bundle, options, _log.Log.log),
|
|
36
|
+
// NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native
|
|
37
|
+
// platforms when doing production embeds (unlikely).
|
|
38
|
+
options.assetsDest ? (0, _persistMetroAssets).persistMetroAssetsAsync(assets, {
|
|
39
|
+
platform: options.platform,
|
|
40
|
+
outputDirectory: options.assetsDest,
|
|
41
|
+
iosAssetCatalogDirectory: options.assetCatalogDest
|
|
42
|
+
}) : null,
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
async function exportEmbedBundleAsync(projectRoot, options) {
|
|
46
|
+
const exp = (0, _config).getConfig(projectRoot, {
|
|
47
|
+
skipSDKVersionRequirement: true
|
|
48
|
+
}).exp;
|
|
49
|
+
// TODO: This is slow ~40ms
|
|
23
50
|
const { config } = await (0, _instantiateMetro).loadMetroConfigAsync(projectRoot, {
|
|
24
51
|
maxWorkers: options.maxWorkers,
|
|
25
52
|
resetCache: options.resetCache,
|
|
26
53
|
config: options.config
|
|
27
54
|
}, {
|
|
55
|
+
exp,
|
|
28
56
|
isExporting: true
|
|
29
57
|
});
|
|
30
|
-
|
|
31
|
-
// platforms when doing production embeds (unlikely).
|
|
32
|
-
const saveAssets = (0, _resolveFromProject).importCliSaveAssetsFromProject(projectRoot);
|
|
58
|
+
const isHermes = (0, _exportHermes).isEnableHermesManaged(exp, options.platform);
|
|
33
59
|
let sourceMapUrl = options.sourcemapOutput;
|
|
34
60
|
if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {
|
|
35
61
|
sourceMapUrl = _path.default.basename(sourceMapUrl);
|
|
36
62
|
}
|
|
37
63
|
const bundleRequest = {
|
|
38
64
|
..._server.default.DEFAULT_BUNDLE_OPTIONS,
|
|
39
|
-
|
|
65
|
+
...(0, _metroOptions).getMetroDirectBundleOptions({
|
|
66
|
+
mainModuleName: options.entryFile,
|
|
67
|
+
platform: options.platform,
|
|
68
|
+
minify: options.minify,
|
|
69
|
+
mode: options.dev ? "development" : "production",
|
|
70
|
+
engine: isHermes ? "hermes" : undefined,
|
|
71
|
+
baseUrl: (0, _metroOptions).getBaseUrlFromExpoConfig(exp)
|
|
72
|
+
}),
|
|
40
73
|
sourceMapUrl,
|
|
41
|
-
|
|
42
|
-
minify: !!options.minify,
|
|
43
|
-
platform: options.platform,
|
|
44
|
-
unstable_transformProfile: options.unstableTransformProfile
|
|
74
|
+
unstable_transformProfile: options.unstableTransformProfile || (isHermes ? "hermes-stable" : "default")
|
|
45
75
|
};
|
|
46
76
|
const server = new _server.default(config, {
|
|
47
77
|
watch: false
|
|
48
78
|
});
|
|
49
79
|
try {
|
|
50
|
-
const bundle = await server.build({
|
|
80
|
+
const bundle = await (0, _profile).profile(server.build.bind(server), "metro-bundle")({
|
|
51
81
|
...bundleRequest,
|
|
52
82
|
bundleType: "bundle"
|
|
53
83
|
});
|
|
54
|
-
_fs.default.mkdirSync(_path.default.dirname(options.bundleOutput), {
|
|
55
|
-
recursive: true,
|
|
56
|
-
mode: 493
|
|
57
|
-
});
|
|
58
|
-
// Persist bundle and source maps.
|
|
59
|
-
await _bundle.default.save(bundle, options, _log.Log.log);
|
|
60
84
|
// Save the assets of the bundle
|
|
61
85
|
const outputAssets = await (0, _forkBundleAsync).getAssets(server, {
|
|
62
86
|
...bundleRequest,
|
|
63
87
|
bundleType: "todo"
|
|
64
88
|
});
|
|
65
|
-
|
|
89
|
+
return {
|
|
90
|
+
bundle,
|
|
91
|
+
assets: outputAssets
|
|
92
|
+
};
|
|
66
93
|
} finally{
|
|
67
94
|
server.end();
|
|
68
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["import fs from 'fs';\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 { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport fs from 'fs';\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 { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport {\n getBaseUrlFromExpoConfig,\n getMetroDirectBundleOptions,\n} from '../../start/server/middleware/metroOptions';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { profile } from '../../utils/profile';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { getAssets } from '../fork-bundleAsync';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const { bundle, assets } = await exportEmbedBundleAsync(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 exportEmbedBundleAsync(projectRoot: string, options: Options) {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n maxWorkers: options.maxWorkers,\n resetCache: options.resetCache,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\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 ...getMetroDirectBundleOptions({\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(exp),\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 try {\n const bundle = await profile(\n server.build.bind(server),\n 'metro-bundle'\n )({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n\n // Save the assets of the bundle\n const outputAssets = await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n return {\n bundle,\n assets: outputAssets,\n };\n } finally {\n server.end();\n }\n}\n"],"names":["exportEmbedAsync","exportEmbedBundleAsync","projectRoot","options","setNodeEnv","dev","require","load","bundle","assets","fs","mkdirSync","path","dirname","bundleOutput","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","platform","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","exp","getConfig","skipSDKVersionRequirement","config","loadMetroConfigAsync","maxWorkers","resetCache","isExporting","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","basename","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptions","mainModuleName","entryFile","minify","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","unstable_transformProfile","unstableTransformProfile","server","watch","profile","build","bind","bundleType","outputAssets","getAssets","end"],"mappings":"AAAA;;;;QAoBsBA,gBAAgB,GAAhBA,gBAAgB;QAuBhBC,sBAAsB,GAAtBA,sBAAsB;AA3ClB,IAAA,OAAc,WAAd,cAAc,CAAA;AACzB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACA,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AAClB,IAAA,OAAgC,kCAAhC,gCAAgC,EAAA;AAElC,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGH,IAAA,IAAW,WAAX,WAAW,CAAA;AACM,IAAA,iBAA2C,WAA3C,2CAA2C,CAAA;AAIzE,IAAA,aAA4C,WAA5C,4CAA4C,CAAA;AACxB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,gBAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,mBAAuB,W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IZ,OAAM,QAAA,CAACZ,MAAM,EAAE;QAChCyB,KAAK,EAAE,KAAK;KACb,CAAC,AAAC;IAEH,IAAI;QACF,MAAMjD,MAAM,GAAG,MAAMkD,CAAAA,GAAAA,QAAO,AAG3B,CAAA,QAH2B,CAC1BF,MAAM,CAACG,KAAK,CAACC,IAAI,CAACJ,MAAM,CAAC,EACzB,cAAc,CACf,CAAC;YACA,GAAGb,aAAa;YAChBkB,UAAU,EAAE,QAAQ;SACrB,CAAC,AAAC;QAEH,gCAAgC;QAChC,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,gBAAS,AAGlC,CAAA,UAHkC,CAACP,MAAM,EAAE;YAC3C,GAAGb,aAAa;YAChBkB,UAAU,EAAE,MAAM;SACnB,CAAC,AAAC;QAEH,OAAO;YACLrD,MAAM;YACNC,MAAM,EAAEqD,YAAY;SACrB,CAAC;KACH,QAAS;QACRN,MAAM,CAACQ,GAAG,EAAE,CAAC;KACd;CACF"}
|
|
@@ -87,16 +87,16 @@ const expoExportEmbed = async (argv)=>{
|
|
|
87
87
|
}
|
|
88
88
|
const [{ exportEmbedAsync }, { resolveOptions }, { logCmdError }, { resolveCustomBooleanArgsAsync }, ] = await Promise.all([
|
|
89
89
|
Promise.resolve().then(function() {
|
|
90
|
-
return _interopRequireWildcard(require("./exportEmbedAsync"));
|
|
90
|
+
return _interopRequireWildcard(require("./exportEmbedAsync.js"));
|
|
91
91
|
}),
|
|
92
92
|
Promise.resolve().then(function() {
|
|
93
|
-
return _interopRequireWildcard(require("./resolveOptions"));
|
|
93
|
+
return _interopRequireWildcard(require("./resolveOptions.js"));
|
|
94
94
|
}),
|
|
95
95
|
Promise.resolve().then(function() {
|
|
96
|
-
return _interopRequireWildcard(require("../../utils/errors"));
|
|
96
|
+
return _interopRequireWildcard(require("../../utils/errors.js"));
|
|
97
97
|
}),
|
|
98
98
|
Promise.resolve().then(function() {
|
|
99
|
-
return _interopRequireWildcard(require("../../utils/resolveArgs"));
|
|
99
|
+
return _interopRequireWildcard(require("../../utils/resolveArgs.js"));
|
|
100
100
|
}),
|
|
101
101
|
]);
|
|
102
102
|
return (async ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport arg from 'arg';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { Command } from '../../../bin/cli';\nimport { assertWithOptionsArgs, printHelp } from '../../utils/args';\n\nexport const expoExportEmbed: Command = async (argv) => {\n const rawArgsMap: arg.Spec = {\n // Types\n '--entry-file': String,\n '--platform': String,\n '--transformer': String,\n '--bundle-output': String,\n '--bundle-encoding': String,\n '--max-workers': Number,\n '--sourcemap-output': String,\n '--sourcemap-sources-root': String,\n '--assets-dest': String,\n '--asset-catalog-dest': String,\n '--unstable-transform-profile': String,\n '--config': String,\n\n // This is here for compatibility with the `npx react-native bundle` command.\n // devs should use `DEBUG=expo:*` instead.\n '--verbose': Boolean,\n '--help': Boolean,\n // Aliases\n '-h': '--help',\n '-v': '--verbose',\n };\n const args = assertWithOptionsArgs(rawArgsMap, {\n argv,\n permissive: true,\n });\n\n if (args['--help']) {\n printHelp(\n `(Internal) Export the JavaScript bundle during a native build script for embedding in a native binary`,\n chalk`npx expo export:embed {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n `--entry-file <path> Path to the root JS file, either absolute or relative to JS root`,\n `--platform <string> Either \"ios\" or \"android\" (default: \"ios\")`,\n `--transformer <string> Specify a custom transformer to be used`,\n `--dev [boolean] If false, warnings are disabled and the bundle is minified (default: true)`,\n `--minify [boolean] Allows overriding whether bundle is minified. This defaults to false if dev is true, and true if dev is false. Disabling minification can be useful for speeding up production builds for testing purposes.`,\n `--bundle-output <string> File name where to store the resulting bundle, ex. /tmp/groups.bundle`,\n `--bundle-encoding <string> Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer). (default: \"utf8\")`,\n `--max-workers <number> Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine.`,\n `--sourcemap-output <string> File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map`,\n `--sourcemap-sources-root <string> Path to make sourcemap's sources entries relative to, ex. /root/dir`,\n `--sourcemap-use-absolute-path Report SourceMapURL using its full path`,\n `--assets-dest <string> Directory name where to store assets referenced in the bundle`,\n `--asset-catalog-dest <string> Directory to create an iOS Asset Catalog for images`,\n `--unstable-transform-profile <string> Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default`,\n `--reset-cache Removes cached files`,\n `-v, --verbose Enables debug logging`,\n\n `--config <string> Path to the CLI configuration file`,\n // This is seemingly unused.\n `--read-global-cache Try to fetch transformed JS code from the global cache, if configured.`,\n\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const [\n { exportEmbedAsync },\n { resolveOptions },\n { logCmdError },\n { resolveCustomBooleanArgsAsync },\n ] = await Promise.all([\n import('./exportEmbedAsync'),\n import('./resolveOptions'),\n import('../../utils/errors'),\n import('../../utils/resolveArgs'),\n ]);\n\n return (async () => {\n const parsed = await resolveCustomBooleanArgsAsync(argv ?? [], rawArgsMap, {\n '--dev': Boolean,\n '--minify': Boolean,\n '--sourcemap-use-absolute-path': Boolean,\n '--reset-cache': Boolean,\n '--read-global-cache': Boolean,\n });\n return exportEmbedAsync(path.resolve(parsed.projectRoot), resolveOptions(args, parsed));\n })().catch(logCmdError);\n};\n"],"names":["expoExportEmbed","argv","rawArgsMap","String","Number","Boolean","args","assertWithOptionsArgs","permissive","printHelp","chalk","join","exportEmbedAsync","resolveOptions","logCmdError","resolveCustomBooleanArgsAsync","Promise","all","parsed","path","resolve","projectRoot","catch"],"mappings":"AAAA;;;;;;AAEkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAG0B,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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tG,CAAC,0FAA0F,CAAC;YAC5F,CAAC,+IAA+I,CAAC;YACjJ,CAAC,2DAA2D,CAAC;YAC7D,CAAC,4DAA4D,CAAC;YAE9D,CAAC,yEAAyE,CAAC;YAC3E,4BAA4B;YAC5B,CAAC,6GAA6G,CAAC;YAE/G,CAAC,iDAAiD,CAAC;SACpD,CAACC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;KACH;IAED,MAAM,CACJ,EAAEC,gBAAgB,CAAA,EAAE,EACpB,EAAEC,cAAc,CAAA,EAAE,EAClB,EAAEC,WAAW,CAAA,EAAE,EACf,EAAEC,6BAA6B,CAAA,EAAE,GAClC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC;QACpB;mDAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport arg from 'arg';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { Command } from '../../../bin/cli';\nimport { assertWithOptionsArgs, printHelp } from '../../utils/args';\n\nexport const expoExportEmbed: Command = async (argv) => {\n const rawArgsMap: arg.Spec = {\n // Types\n '--entry-file': String,\n '--platform': String,\n '--transformer': String,\n '--bundle-output': String,\n '--bundle-encoding': String,\n '--max-workers': Number,\n '--sourcemap-output': String,\n '--sourcemap-sources-root': String,\n '--assets-dest': String,\n '--asset-catalog-dest': String,\n '--unstable-transform-profile': String,\n '--config': String,\n\n // This is here for compatibility with the `npx react-native bundle` command.\n // devs should use `DEBUG=expo:*` instead.\n '--verbose': Boolean,\n '--help': Boolean,\n // Aliases\n '-h': '--help',\n '-v': '--verbose',\n };\n const args = assertWithOptionsArgs(rawArgsMap, {\n argv,\n permissive: true,\n });\n\n if (args['--help']) {\n printHelp(\n `(Internal) Export the JavaScript bundle during a native build script for embedding in a native binary`,\n chalk`npx expo export:embed {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n `--entry-file <path> Path to the root JS file, either absolute or relative to JS root`,\n `--platform <string> Either \"ios\" or \"android\" (default: \"ios\")`,\n `--transformer <string> Specify a custom transformer to be used`,\n `--dev [boolean] If false, warnings are disabled and the bundle is minified (default: true)`,\n `--minify [boolean] Allows overriding whether bundle is minified. This defaults to false if dev is true, and true if dev is false. Disabling minification can be useful for speeding up production builds for testing purposes.`,\n `--bundle-output <string> File name where to store the resulting bundle, ex. /tmp/groups.bundle`,\n `--bundle-encoding <string> Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer). (default: \"utf8\")`,\n `--max-workers <number> Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine.`,\n `--sourcemap-output <string> File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map`,\n `--sourcemap-sources-root <string> Path to make sourcemap's sources entries relative to, ex. /root/dir`,\n `--sourcemap-use-absolute-path Report SourceMapURL using its full path`,\n `--assets-dest <string> Directory name where to store assets referenced in the bundle`,\n `--asset-catalog-dest <string> Directory to create an iOS Asset Catalog for images`,\n `--unstable-transform-profile <string> Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default`,\n `--reset-cache Removes cached files`,\n `-v, --verbose Enables debug logging`,\n\n `--config <string> Path to the CLI configuration file`,\n // This is seemingly unused.\n `--read-global-cache Try to fetch transformed JS code from the global cache, if configured.`,\n\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const [\n { exportEmbedAsync },\n { resolveOptions },\n { logCmdError },\n { resolveCustomBooleanArgsAsync },\n ] = await Promise.all([\n import('./exportEmbedAsync.js'),\n import('./resolveOptions.js'),\n import('../../utils/errors.js'),\n import('../../utils/resolveArgs.js'),\n ]);\n\n return (async () => {\n const parsed = await resolveCustomBooleanArgsAsync(argv ?? [], rawArgsMap, {\n '--dev': Boolean,\n '--minify': Boolean,\n '--sourcemap-use-absolute-path': Boolean,\n '--reset-cache': Boolean,\n '--read-global-cache': Boolean,\n });\n return exportEmbedAsync(path.resolve(parsed.projectRoot), resolveOptions(args, parsed));\n })().catch(logCmdError);\n};\n"],"names":["expoExportEmbed","argv","rawArgsMap","String","Number","Boolean","args","assertWithOptionsArgs","permissive","printHelp","chalk","join","exportEmbedAsync","resolveOptions","logCmdError","resolveCustomBooleanArgsAsync","Promise","all","parsed","path","resolve","projectRoot","catch"],"mappings":"AAAA;;;;;;AAEkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAG0B,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5D,MAAMA,eAAe,GAAY,OAAOC,IAAI,GAAK;IACtD,MAAMC,UAAU,GAAa;QAC3B,QAAQ;QACR,cAAc,EAAEC,MAAM;QACtB,YAAY,EAAEA,MAAM;QACpB,eAAe,EAAEA,MAAM;QACvB,iBAAiB,EAAEA,MAAM;QACzB,mBAAmB,EAAEA,MAAM;QAC3B,eAAe,EAAEC,MAAM;QACvB,oBAAoB,EAAED,MAAM;QAC5B,0BAA0B,EAAEA,MAAM;QAClC,eAAe,EAAEA,MAAM;QACvB,sBAAsB,EAAEA,MAAM;QAC9B,8BAA8B,EAAEA,MAAM;QACtC,UAAU,EAAEA,MAAM;QAElB,6EAA6E;QAC7E,0CAA0C;QAC1C,WAAW,EAAEE,OAAO;QACpB,QAAQ,EAAEA,OAAO;QACjB,UAAU;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,WAAW;KAClB,AAAC;IACF,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAqB,AAGhC,CAAA,sBAHgC,CAACL,UAAU,EAAE;QAC7CD,IAAI;QACJO,UAAU,EAAE,IAAI;KACjB,CAAC,AAAC;IAEH,IAAIF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBG,CAAAA,GAAAA,KAAS,AA4BR,CAAA,UA5BQ,CACP,CAAC,qGAAqG,CAAC,EACvGC,MAAK,QAAA,CAAC,iCAAiC,CAAC,EACxC;YACEA,MAAK,QAAA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AACC,OAAO,CAACF,MAAM,CAACG,WAAW,CAAC,EAAER,cAAc,CAACP,IAAI,EAAEY,MAAM,CAAC,CAAC,CAAC;KACzF,CAAC,EAAE,CAACI,KAAK,CAACR,WAAW,CAAC,CAAC;CACzB,AAAC;QAnFWd,eAAe,GAAfA,eAAe"}
|
|
@@ -31,7 +31,7 @@ function resolveOptions(args, parsed) {
|
|
|
31
31
|
if (!bundleOutput) {
|
|
32
32
|
throw new _errors.CommandError(`Missing required argument: --bundle-output`);
|
|
33
33
|
}
|
|
34
|
-
var ref2, ref3, ref4
|
|
34
|
+
var ref2, ref3, ref4;
|
|
35
35
|
return {
|
|
36
36
|
entryFile,
|
|
37
37
|
assetCatalogDest: args["--asset-catalog-dest"],
|
|
@@ -46,10 +46,10 @@ function resolveOptions(args, parsed) {
|
|
|
46
46
|
sourcemapSourcesRoot: args["--sourcemap-sources-root"],
|
|
47
47
|
sourcemapUseAbsolutePath: !!parsed.args["--sourcemap-use-absolute-path"],
|
|
48
48
|
assetsDest: args["--assets-dest"],
|
|
49
|
-
unstableTransformProfile:
|
|
49
|
+
unstableTransformProfile: args["--unstable-transform-profile"],
|
|
50
50
|
resetCache: !!parsed.args["--reset-cache"],
|
|
51
51
|
resetGlobalCache: false,
|
|
52
|
-
verbose: (
|
|
52
|
+
verbose: (ref4 = args["--verbose"]) != null ? ref4 : _env.env.EXPO_DEBUG,
|
|
53
53
|
config: args["--config"] ? _path.default.resolve(args["--config"]) : undefined,
|
|
54
54
|
dev,
|
|
55
55
|
minify
|
|
@@ -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 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
|
|
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;;;;QAkCgBA,cAAc,GAAdA,cAAc;AAjCb,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;;;;;;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;KAC/D;CACF;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,CA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,IAAI,CAAC,WAAW,CAAC,YAAjBA,IAAiB,GAAImB,IAAG,IAAA,CAACC,UAAU;QAC5CC,MAAM,EAAErB,IAAI,CAAC,UAAU,CAAC,GAAGsB,KAAI,QAAA,CAACC,OAAO,CAACvB,IAAI,CAAC,UAAU,CAAC,CAAC,GAAGwB,SAAS;QACrEtB,GAAG;QACHC,MAAM;KACP,CAAC;CACH"}
|
|
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.exportAppAsync = exportAppAsync;
|
|
6
|
+
var _config = require("@expo/config");
|
|
6
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
9
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _createBundles = require("./createBundles");
|
|
10
10
|
var _exportAssets = require("./exportAssets");
|
|
11
11
|
var _exportStaticAsync = require("./exportStaticAsync");
|
|
12
12
|
var _favicon = require("./favicon");
|
|
13
|
+
var _forkBundleAsync = require("./fork-bundleAsync");
|
|
13
14
|
var _getPublicExpoManifest = require("./getPublicExpoManifest");
|
|
14
|
-
var _persistMetroAssets = require("./persistMetroAssets");
|
|
15
15
|
var _printBundleSizes = require("./printBundleSizes");
|
|
16
16
|
var _writeContents = require("./writeContents");
|
|
17
17
|
var Log = _interopRequireWildcard(require("../log"));
|
|
18
|
+
var _metroOptions = require("../start/server/middleware/metroOptions");
|
|
18
19
|
var _webTemplate = require("../start/server/webTemplate");
|
|
19
20
|
var _dir = require("../utils/dir");
|
|
20
21
|
var _env = require("../utils/env");
|
|
@@ -45,27 +46,27 @@ function _interopRequireWildcard(obj) {
|
|
|
45
46
|
return newObj;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev , dumpAssetmap ,
|
|
49
|
-
var ref
|
|
49
|
+
async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev , dumpAssetmap , sourceMaps , minify }) {
|
|
50
|
+
var ref;
|
|
50
51
|
(0, _nodeEnv).setNodeEnv(dev ? "development" : "production");
|
|
51
52
|
require("@expo/env").load(projectRoot);
|
|
53
|
+
const projectConfig = (0, _config).getConfig(projectRoot);
|
|
52
54
|
const exp = await (0, _getPublicExpoManifest).getPublicExpoManifestAsync(projectRoot, {
|
|
53
55
|
// Web doesn't require validation.
|
|
54
56
|
skipValidation: platforms.length === 1 && platforms[0] === "web"
|
|
55
57
|
});
|
|
56
|
-
var
|
|
58
|
+
var ref1;
|
|
57
59
|
const useServerRendering = [
|
|
58
60
|
"static",
|
|
59
61
|
"server"
|
|
60
|
-
].includes((
|
|
61
|
-
|
|
62
|
-
const basePath = ((ref4 = (ref1 = exp.experiments) == null ? void 0 : (ref2 = ref1.basePath) == null ? void 0 : ref2.replace(/\/+$/, "")) != null ? ref4 : "").trim();
|
|
62
|
+
].includes((ref1 = (ref = exp.web) == null ? void 0 : ref.output) != null ? ref1 : "");
|
|
63
|
+
const baseUrl = (0, _metroOptions).getBaseUrlFromExpoConfig(exp);
|
|
63
64
|
// Print out logs
|
|
64
|
-
if (
|
|
65
|
+
if (baseUrl) {
|
|
65
66
|
Log.log();
|
|
66
|
-
Log.log(_chalk.default.gray`Using (experimental) base path: ${
|
|
67
|
+
Log.log(_chalk.default.gray`Using (experimental) base path: ${baseUrl}`);
|
|
67
68
|
// Warn if not using an absolute path.
|
|
68
|
-
if (!
|
|
69
|
+
if (!baseUrl.startsWith("/")) {
|
|
69
70
|
Log.log(_chalk.default.yellow` Base path does not start with a slash. Requests will not be absolute.`);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -80,22 +81,25 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
80
81
|
].map(_dir.ensureDirectoryAsync));
|
|
81
82
|
await copyPublicFolderAsync(publicPath, staticFolder);
|
|
82
83
|
// Run metro bundler and create the JS bundles/source maps.
|
|
83
|
-
const bundles = await (0,
|
|
84
|
-
|
|
85
|
-
}, {
|
|
86
|
-
platforms,
|
|
84
|
+
const bundles = await (0, _forkBundleAsync).createBundlesAsync(projectRoot, projectConfig, {
|
|
85
|
+
clear: !!clear,
|
|
87
86
|
minify,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// : platforms,
|
|
87
|
+
sourcemaps: sourceMaps,
|
|
88
|
+
platforms: useServerRendering ? platforms.filter((platform)=>platform !== "web"
|
|
89
|
+
) : platforms,
|
|
92
90
|
dev
|
|
93
91
|
});
|
|
92
|
+
// Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
|
|
93
|
+
const { hashes , fileNames } = await (0, _writeContents).writeBundlesAsync({
|
|
94
|
+
bundles,
|
|
95
|
+
useServerRendering,
|
|
96
|
+
outputDir: bundlesPath
|
|
97
|
+
});
|
|
94
98
|
const bundleEntries = Object.entries(bundles);
|
|
95
99
|
if (bundleEntries.length) {
|
|
96
100
|
// Log bundle size info to the user
|
|
97
101
|
(0, _printBundleSizes).printBundleSizes(Object.fromEntries(bundleEntries.map(([key, value])=>{
|
|
98
|
-
if (!
|
|
102
|
+
if (!sourceMaps) {
|
|
99
103
|
return [
|
|
100
104
|
key,
|
|
101
105
|
{
|
|
@@ -110,68 +114,14 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
110
114
|
value
|
|
111
115
|
];
|
|
112
116
|
})));
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
useServerRendering,
|
|
118
|
-
outputDir: bundlesPath
|
|
119
|
-
});
|
|
120
|
-
Log.log("Finished saving JS Bundles");
|
|
121
|
-
if (platforms.includes("web")) {
|
|
122
|
-
if (useServerRendering) {
|
|
123
|
-
var ref5;
|
|
124
|
-
await (0, _exportStaticAsync).unstable_exportStaticAsync(projectRoot, {
|
|
125
|
-
outputDir: outputPath,
|
|
126
|
-
minify,
|
|
127
|
-
basePath,
|
|
128
|
-
includeMaps: dumpSourcemap,
|
|
129
|
-
// @ts-expect-error: server not on type yet
|
|
130
|
-
exportServer: ((ref5 = exp.web) == null ? void 0 : ref5.output) === "server"
|
|
131
|
-
});
|
|
132
|
-
Log.log("Finished saving static files");
|
|
133
|
-
} else {
|
|
134
|
-
const cssLinks = await (0, _exportAssets).exportCssAssetsAsync({
|
|
135
|
-
outputDir,
|
|
136
|
-
bundles,
|
|
137
|
-
basePath
|
|
138
|
-
});
|
|
139
|
-
let html = await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(projectRoot, {
|
|
140
|
-
scripts: [
|
|
141
|
-
`${basePath}/bundles/${fileNames.web}`
|
|
142
|
-
],
|
|
143
|
-
cssLinks
|
|
144
|
-
});
|
|
145
|
-
// Add the favicon assets to the HTML.
|
|
146
|
-
const modifyHtml = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, {
|
|
147
|
-
outputDir,
|
|
148
|
-
basePath
|
|
149
|
-
});
|
|
150
|
-
if (modifyHtml) {
|
|
151
|
-
html = modifyHtml(html);
|
|
152
|
-
}
|
|
153
|
-
// Generate SPA-styled HTML file.
|
|
154
|
-
// If web exists, then write the template HTML file.
|
|
155
|
-
await _fs.default.promises.writeFile(_path.default.join(staticFolder, "index.html"), html);
|
|
156
|
-
}
|
|
157
|
-
// TODO: Use a different mechanism for static web.
|
|
158
|
-
if (bundles.web) {
|
|
159
|
-
// Save assets like a typical bundler, preserving the file paths on web.
|
|
160
|
-
// TODO: Update React Native Web to support loading files from asset hashes.
|
|
161
|
-
await (0, _persistMetroAssets).persistMetroAssetsAsync(bundles.web.assets, {
|
|
162
|
-
platform: "web",
|
|
163
|
-
outputDirectory: staticFolder,
|
|
164
|
-
basePath
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// Can be empty during web-only SSG.
|
|
169
|
-
// TODO: Use same asset system across platforms again.
|
|
170
|
-
if (Object.keys(fileNames).length) {
|
|
171
|
-
const { assets } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
|
|
117
|
+
Log.log("Finished saving JS Bundles");
|
|
118
|
+
// Can be empty during web-only SSG.
|
|
119
|
+
// TODO: Use same asset system across platforms again.
|
|
120
|
+
const { assets , embeddedHashSet } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
|
|
172
121
|
exp,
|
|
173
122
|
outputDir: staticFolder,
|
|
174
|
-
bundles
|
|
123
|
+
bundles,
|
|
124
|
+
baseUrl
|
|
175
125
|
});
|
|
176
126
|
if (dumpAssetmap) {
|
|
177
127
|
Log.log("Dumping asset map");
|
|
@@ -181,8 +131,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
181
131
|
});
|
|
182
132
|
}
|
|
183
133
|
// build source maps
|
|
184
|
-
if (
|
|
185
|
-
Log.log("
|
|
134
|
+
if (sourceMaps) {
|
|
135
|
+
Log.log("Emitting source maps");
|
|
186
136
|
await (0, _writeContents).writeSourceMapsAsync({
|
|
187
137
|
bundles,
|
|
188
138
|
hashes,
|
|
@@ -201,8 +151,49 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
201
151
|
await (0, _writeContents).writeMetadataJsonAsync({
|
|
202
152
|
outputDir: staticFolder,
|
|
203
153
|
bundles,
|
|
204
|
-
fileNames
|
|
154
|
+
fileNames,
|
|
155
|
+
embeddedHashSet
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// Additional web-only steps...
|
|
159
|
+
if (!platforms.includes("web")) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (useServerRendering) {
|
|
163
|
+
var ref2;
|
|
164
|
+
await (0, _exportStaticAsync).unstable_exportStaticAsync(projectRoot, {
|
|
165
|
+
clear: !!clear,
|
|
166
|
+
outputDir: outputPath,
|
|
167
|
+
minify,
|
|
168
|
+
baseUrl,
|
|
169
|
+
includeMaps: sourceMaps,
|
|
170
|
+
// @ts-expect-error: server not on type yet
|
|
171
|
+
exportServer: ((ref2 = exp.web) == null ? void 0 : ref2.output) === "server"
|
|
172
|
+
});
|
|
173
|
+
Log.log("Finished saving static files");
|
|
174
|
+
} else {
|
|
175
|
+
const cssLinks = await (0, _exportAssets).exportCssAssetsAsync({
|
|
176
|
+
outputDir,
|
|
177
|
+
bundles,
|
|
178
|
+
baseUrl
|
|
179
|
+
});
|
|
180
|
+
let html = await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(projectRoot, {
|
|
181
|
+
scripts: [
|
|
182
|
+
`${baseUrl}/bundles/${fileNames.web}`
|
|
183
|
+
],
|
|
184
|
+
cssLinks
|
|
205
185
|
});
|
|
186
|
+
// Add the favicon assets to the HTML.
|
|
187
|
+
const modifyHtml = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, {
|
|
188
|
+
outputDir,
|
|
189
|
+
baseUrl
|
|
190
|
+
});
|
|
191
|
+
if (modifyHtml) {
|
|
192
|
+
html = modifyHtml(html);
|
|
193
|
+
}
|
|
194
|
+
// Generate SPA-styled HTML file.
|
|
195
|
+
// If web exists, then write the template HTML file.
|
|
196
|
+
await _fs.default.promises.writeFile(_path.default.join(staticFolder, "index.html"), html);
|
|
206
197
|
}
|
|
207
198
|
}
|
|
208
199
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync, exportCssAssetsAsync } from './exportAssets';\nimport { unstable_exportStaticAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\nimport * as Log from '../log';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n minify,\n }: Pick<\n Options,\n 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms' | 'minify'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n const basePath = (exp.experiments?.basePath?.replace(/\\/+$/, '') ?? '').trim();\n\n // Print out logs\n if (basePath) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${basePath}`);\n // Warn if not using an absolute path.\n if (!basePath.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const staticFolder = outputPath;\n const assetsPath = path.join(staticFolder, 'assets');\n const bundlesPath = path.join(staticFolder, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, staticFolder);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n minify,\n // TODO: Breaks asset exports\n // platforms: useServerRendering\n // ? platforms.filter((platform) => platform !== 'web')\n // : platforms,\n dev,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n const bundleEntries = Object.entries(bundles);\n if (bundleEntries.length) {\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n bundleEntries.map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n }\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({\n bundles,\n useServerRendering,\n outputDir: bundlesPath,\n });\n\n Log.log('Finished saving JS Bundles');\n\n if (platforms.includes('web')) {\n if (useServerRendering) {\n await unstable_exportStaticAsync(projectRoot, {\n outputDir: outputPath,\n minify,\n basePath,\n includeMaps: dumpSourcemap,\n // @ts-expect-error: server not on type yet\n exportServer: exp.web?.output === 'server',\n });\n Log.log('Finished saving static files');\n } else {\n const cssLinks = await exportCssAssetsAsync({\n outputDir,\n bundles,\n basePath,\n });\n let html = await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`${basePath}/bundles/${fileNames.web}`],\n cssLinks,\n });\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n basePath,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(path.join(staticFolder, 'index.html'), html);\n }\n\n // TODO: Use a different mechanism for static web.\n if (bundles.web) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // TODO: Update React Native Web to support loading files from asset hashes.\n await persistMetroAssetsAsync(bundles.web.assets, {\n platform: 'web',\n outputDirectory: staticFolder,\n basePath,\n });\n }\n }\n\n // Can be empty during web-only SSG.\n // TODO: Use same asset system across platforms again.\n if (Object.keys(fileNames).length) {\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: staticFolder,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: staticFolder, assets });\n }\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: staticFolder,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir: staticFolder, bundles, fileNames });\n }\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","minify","exp","setNodeEnv","require","load","getPublicExpoManifestAsync","skipValidation","length","useServerRendering","includes","web","output","basePath","experiments","replace","trim","log","chalk","gray","startsWith","yellow","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","staticFolder","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","bundleEntries","Object","entries","printBundleSizes","fromEntries","key","value","undefined","hashes","fileNames","writeBundlesAsync","unstable_exportStaticAsync","includeMaps","exportServer","cssLinks","exportCssAssetsAsync","html","createTemplateHtmlFromExpoConfigAsync","scripts","modifyHtml","getVirtualFaviconAssetsAsync","fs","promises","writeFile","persistMetroAssetsAsync","assets","platform","outputDirectory","keys","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mappings":"AAAA;;;;QAqCsBA,cAAc,GAAdA,cAAc;AArClB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACI,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAC7B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,QAAW,WAAX,WAAW,CAAA;AACb,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AAC5B,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAC7B,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAQ9C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACZC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACuC,IAAA,YAA6B,WAA7B,6BAA6B,CAAA;AACnC,IAAA,IAAc,WAAd,cAAc,CAAA;AAC1C,IAAA,IAAc,WAAd,cAAc,CAAA;AACP,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AActC,eAAeD,cAAc,CAClCE,WAAmB,EACnB,EACEC,SAAS,CAAA,EACTC,SAAS,CAAA,EACTC,KAAK,CAAA,EACLC,GAAG,CAAA,EACHC,YAAY,CAAA,EACZC,aAAa,CAAA,EACbC,MAAM,CAAA,EAIP,EACc;QAS0CC,GAAO,EAC9CA,IAAe;IATjCC,CAAAA,GAAAA,QAAU,AAAoC,CAAA,WAApC,CAACL,GAAG,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;IAC/CM,OAAO,CAAC,WAAW,CAAC,CAACC,IAAI,CAACX,WAAW,CAAC,CAAC;IAEvC,MAAMQ,GAAG,GAAG,MAAMI,CAAA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qB,CAAC,CAAC;YAC/B,MAAMsD,CAAAA,GAAAA,cAAoB,AAKxB,CAAA,qBALwB,CAAC;gBACzBlC,OAAO;gBACPW,MAAM;gBACNpD,SAAS,EAAEmC,WAAW;gBACtBkB,SAAS;aACV,CAAC,CAAC;YAEHxD,GAAG,CAACwB,GAAG,CAAC,sCAAsC,CAAC,CAAC;YAChD,kFAAkF;YAClF,kDAAkD;YAClD,MAAMuD,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;gBACxB5E,SAAS,EAAEgC,YAAY;gBACvBqB,SAAS;aACV,CAAC,CAAC;SACJ;QAED,yDAAyD;QACzD,MAAMwB,CAAAA,GAAAA,cAAsB,AAAiD,CAAA,uBAAjD,CAAC;YAAE7E,SAAS,EAAEgC,YAAY;YAAES,OAAO;YAAEY,SAAS;SAAE,CAAC,CAAC;KAC/E;CACF;AAED;;;;;;;GAOG,CACH,eAAeb,qBAAqB,CAACsC,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAId,GAAE,QAAA,CAACe,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { exportAssetsAsync, exportCssAssetsAsync } from './exportAssets';\nimport { unstable_exportStaticAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { createBundlesAsync } from './fork-bundleAsync';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\nimport * as Log from '../log';\nimport { getBaseUrlFromExpoConfig } from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n minify,\n }: Pick<\n Options,\n 'dumpAssetmap' | 'sourceMaps' | 'dev' | 'clear' | 'outputDir' | 'platforms' | 'minify'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const projectConfig = getConfig(projectRoot);\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n\n // Print out logs\n if (baseUrl) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${baseUrl}`);\n // Warn if not using an absolute path.\n if (!baseUrl.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const staticFolder = outputPath;\n const assetsPath = path.join(staticFolder, 'assets');\n const bundlesPath = path.join(staticFolder, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, staticFolder);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(projectRoot, projectConfig, {\n clear: !!clear,\n minify,\n sourcemaps: sourceMaps,\n platforms: useServerRendering ? platforms.filter((platform) => platform !== 'web') : platforms,\n dev,\n });\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({\n bundles,\n useServerRendering,\n outputDir: bundlesPath,\n });\n const bundleEntries = Object.entries(bundles);\n if (bundleEntries.length) {\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n bundleEntries.map(([key, value]) => {\n if (!sourceMaps) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n\n Log.log('Finished saving JS Bundles');\n\n // Can be empty during web-only SSG.\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: staticFolder,\n bundles,\n baseUrl,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: staticFolder, assets });\n }\n // build source maps\n if (sourceMaps) {\n Log.log('Emitting source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: staticFolder,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir: staticFolder, bundles, fileNames, embeddedHashSet });\n }\n\n // Additional web-only steps...\n\n if (!platforms.includes('web')) {\n return;\n }\n\n if (useServerRendering) {\n await unstable_exportStaticAsync(projectRoot, {\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeMaps: sourceMaps,\n // @ts-expect-error: server not on type yet\n exportServer: exp.web?.output === 'server',\n });\n Log.log('Finished saving static files');\n } else {\n const cssLinks = await exportCssAssetsAsync({\n outputDir,\n bundles,\n baseUrl,\n });\n let html = await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`${baseUrl}/bundles/${fileNames.web}`],\n cssLinks,\n });\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(path.join(staticFolder, 'index.html'), html);\n }\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","minify","exp","setNodeEnv","require","load","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","useServerRendering","includes","web","output","baseUrl","getBaseUrlFromExpoConfig","log","chalk","gray","startsWith","yellow","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","staticFolder","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","sourcemaps","filter","platform","hashes","fileNames","writeBundlesAsync","bundleEntries","Object","entries","printBundleSizes","fromEntries","key","value","undefined","assets","embeddedHashSet","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","unstable_exportStaticAsync","includeMaps","exportServer","cssLinks","exportCssAssetsAsync","html","createTemplateHtmlFromExpoConfigAsync","scripts","modifyHtml","getVirtualFaviconAssetsAsync","fs","promises","writeFile","publicFolder","outputFolder","existsSync","copyAsync"],"mappings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