@expo/cli 0.15.0 → 0.16.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 +10 -3
- package/build/bin/cli.map +1 -1
- package/build/src/api/user/actions.js +1 -1
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/export/createMetadataJson.js +2 -1
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +50 -3
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/xcodeCompilerLogger.js +97 -0
- package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -0
- package/build/src/export/exportApp.js +90 -103
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +18 -23
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +1 -1
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportHermes.js +0 -90
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +137 -108
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +12 -4
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +74 -49
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js +1 -1
- package/build/src/export/metroAssetLocalPath.js.map +1 -1
- package/build/src/export/persistMetroAssets.js +28 -17
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/publicFolder.js +7 -0
- package/build/src/export/publicFolder.js.map +1 -1
- package/build/src/export/saveAssets.js +176 -12
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/writeContents.js +8 -107
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/installAsync.js +29 -10
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +9 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/hints.js +4 -0
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/index.js +101 -0
- package/build/src/run/index.js.map +1 -0
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +2 -2
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +10 -3
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/resolvePackages.js +66 -0
- package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -0
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +2 -30
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +24 -8
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +8 -4
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +39 -16
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +6 -2
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +18 -1
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +3 -2
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +22 -5
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- package/build/src/start/server/metro/createJResolver.js +5 -2
- package/build/src/start/server/metro/createJResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +2 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/{inspector-proxy/device.js → debugging/InspectorDevice.js} +8 -38
- package/build/src/start/server/metro/debugging/InspectorDevice.js.map +1 -0
- package/build/src/start/server/metro/debugging/InspectorProxy.js +116 -0
- package/build/src/start/server/metro/debugging/InspectorProxy.js.map +1 -0
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js +45 -0
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/NetworkResponse.js +3 -4
- package/build/src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.js.map +1 -0
- package/build/src/start/server/metro/debugging/inspectorHandlers/PageReload.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerGetPossibleBreakpoints.js +2 -2
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerScriptParsed.js +3 -2
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerSetBreakpointByUrl.js +3 -2
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeCallFunctionOn.js +2 -2
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
- package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeGetProperties.js +5 -4
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.js.map +1 -0
- package/build/src/start/server/metro/debugging/inspectorHandlers/types.js.map +1 -0
- package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js +20 -0
- package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js.map +1 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +8 -5
- 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 +1 -5
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +0 -19
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +20 -4
- package/build/src/start/server/metro/serializeHtml.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +48 -85
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +12 -5
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +22 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +62 -9
- package/build/src/start/server/middleware/metroOptions.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/__typetests__/route.test.js +11 -3
- package/build/src/start/server/type-generation/__typetests__/route.test.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +6 -4
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +11 -1
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/env.js +7 -1
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +3 -11
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +22 -12
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
- package/package.json +10 -10
- package/static/template/index.html +14 -95
- package/build/src/export/printBundleSizes.js +0 -101
- package/build/src/export/printBundleSizes.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/device.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +0 -11
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/index.js +0 -30
- package/build/src/start/server/metro/inspector-proxy/index.js.map +0 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +0 -169
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +0 -1
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +0 -64
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +0 -1
- /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/PageReload.js +0 -0
- /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/types.js +0 -0
|
@@ -5,19 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.exportAppAsync = exportAppAsync;
|
|
6
6
|
var _config = require("@expo/config");
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _createMetadataJson = require("./createMetadataJson");
|
|
10
10
|
var _exportAssets = require("./exportAssets");
|
|
11
11
|
var _exportStaticAsync = require("./exportStaticAsync");
|
|
12
12
|
var _favicon = require("./favicon");
|
|
13
13
|
var _forkBundleAsync = require("./fork-bundleAsync");
|
|
14
14
|
var _getPublicExpoManifest = require("./getPublicExpoManifest");
|
|
15
|
-
var
|
|
15
|
+
var _publicFolder = require("./publicFolder");
|
|
16
|
+
var _saveAssets = require("./saveAssets");
|
|
16
17
|
var _writeContents = require("./writeContents");
|
|
17
18
|
var Log = _interopRequireWildcard(require("../log"));
|
|
19
|
+
var _router = require("../start/server/metro/router");
|
|
20
|
+
var _serializeHtml = require("../start/server/metro/serializeHtml");
|
|
18
21
|
var _metroOptions = require("../start/server/middleware/metroOptions");
|
|
19
22
|
var _webTemplate = require("../start/server/webTemplate");
|
|
20
|
-
var _dir = require("../utils/dir");
|
|
21
23
|
var _env = require("../utils/env");
|
|
22
24
|
var _nodeEnv = require("../utils/nodeEnv");
|
|
23
25
|
function _interopRequireDefault(obj) {
|
|
@@ -46,7 +48,7 @@ function _interopRequireWildcard(obj) {
|
|
|
46
48
|
return newObj;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev , dumpAssetmap , sourceMaps , minify }) {
|
|
51
|
+
async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev , dumpAssetmap , sourceMaps , minify , maxWorkers }) {
|
|
50
52
|
var ref;
|
|
51
53
|
(0, _nodeEnv).setNodeEnv(dev ? "development" : "production");
|
|
52
54
|
require("@expo/env").load(projectRoot);
|
|
@@ -72,14 +74,9 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
72
74
|
}
|
|
73
75
|
const publicPath = _path.default.resolve(projectRoot, _env.env.EXPO_PUBLIC_FOLDER);
|
|
74
76
|
const outputPath = _path.default.resolve(projectRoot, outputDir);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await Promise.all([
|
|
79
|
-
assetsPath,
|
|
80
|
-
bundlesPath
|
|
81
|
-
].map(_dir.ensureDirectoryAsync));
|
|
82
|
-
await copyPublicFolderAsync(publicPath, staticFolder);
|
|
77
|
+
// NOTE(kitten): The public folder is currently always copied, regardless of targetDomain
|
|
78
|
+
// split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`
|
|
79
|
+
await (0, _publicFolder).copyPublicFolderAsync(publicPath, outputPath);
|
|
83
80
|
// Run metro bundler and create the JS bundles/source maps.
|
|
84
81
|
const bundles = await (0, _forkBundleAsync).createBundlesAsync(projectRoot, projectConfig, {
|
|
85
82
|
clear: !!clear,
|
|
@@ -87,126 +84,116 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
87
84
|
sourcemaps: sourceMaps,
|
|
88
85
|
platforms: useServerRendering ? platforms.filter((platform)=>platform !== "web"
|
|
89
86
|
) : platforms,
|
|
90
|
-
dev
|
|
87
|
+
dev,
|
|
88
|
+
maxWorkers
|
|
91
89
|
});
|
|
92
90
|
// Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
const files = new Map();
|
|
92
|
+
Object.values(bundles).forEach((bundle)=>{
|
|
93
|
+
(0, _saveAssets).getFilesFromSerialAssets(bundle.artifacts, {
|
|
94
|
+
includeSourceMaps: sourceMaps,
|
|
95
|
+
files
|
|
96
|
+
});
|
|
97
97
|
});
|
|
98
98
|
const bundleEntries = Object.entries(bundles);
|
|
99
|
+
// Can be empty during web-only SSG.
|
|
99
100
|
if (bundleEntries.length) {
|
|
100
|
-
// Log bundle size info to the user
|
|
101
|
-
(0, _printBundleSizes).printBundleSizes(Object.fromEntries(bundleEntries.map(([key, value])=>{
|
|
102
|
-
if (!sourceMaps) {
|
|
103
|
-
return [
|
|
104
|
-
key,
|
|
105
|
-
{
|
|
106
|
-
...value,
|
|
107
|
-
// Remove source maps from the bundles if they aren't going to be written.
|
|
108
|
-
map: undefined
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
}
|
|
112
|
-
return [
|
|
113
|
-
key,
|
|
114
|
-
value
|
|
115
|
-
];
|
|
116
|
-
})));
|
|
117
|
-
Log.log("Finished saving JS Bundles");
|
|
118
|
-
// Can be empty during web-only SSG.
|
|
119
101
|
// TODO: Use same asset system across platforms again.
|
|
120
102
|
const { assets , embeddedHashSet } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
|
|
103
|
+
files,
|
|
121
104
|
exp,
|
|
122
|
-
outputDir:
|
|
105
|
+
outputDir: outputPath,
|
|
123
106
|
bundles,
|
|
124
107
|
baseUrl
|
|
125
108
|
});
|
|
126
109
|
if (dumpAssetmap) {
|
|
127
|
-
Log.log("
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
110
|
+
Log.log("Creating asset map");
|
|
111
|
+
files.set("assetmap.json", {
|
|
112
|
+
contents: JSON.stringify((0, _writeContents).createAssetMap({
|
|
113
|
+
assets
|
|
114
|
+
}))
|
|
131
115
|
});
|
|
132
116
|
}
|
|
117
|
+
const fileNames = Object.fromEntries(Object.entries(bundles).map(([platform, bundle])=>[
|
|
118
|
+
platform,
|
|
119
|
+
bundle.artifacts.filter((asset)=>asset.type === "js"
|
|
120
|
+
).map((asset)=>asset.filename
|
|
121
|
+
),
|
|
122
|
+
]
|
|
123
|
+
));
|
|
133
124
|
// build source maps
|
|
134
125
|
if (sourceMaps) {
|
|
135
|
-
Log.log("Emitting source maps");
|
|
136
|
-
await (0, _writeContents).writeSourceMapsAsync({
|
|
137
|
-
bundles,
|
|
138
|
-
hashes,
|
|
139
|
-
outputDir: bundlesPath,
|
|
140
|
-
fileNames
|
|
141
|
-
});
|
|
142
126
|
Log.log("Preparing additional debugging files");
|
|
143
127
|
// If we output source maps, then add a debug HTML file which the user can open in
|
|
144
128
|
// the web browser to inspect the output like web.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
files.set("debug.html", {
|
|
130
|
+
contents: (0, _writeContents).createSourceMapDebugHtml({
|
|
131
|
+
fileNames: Object.values(fileNames).flat()
|
|
132
|
+
})
|
|
148
133
|
});
|
|
149
134
|
}
|
|
150
|
-
// Generate a `metadata.json`
|
|
151
|
-
|
|
152
|
-
outputDir: staticFolder,
|
|
135
|
+
// Generate a `metadata.json` for EAS Update.
|
|
136
|
+
const contents = (0, _createMetadataJson).createMetadataJson({
|
|
153
137
|
bundles,
|
|
154
138
|
fileNames,
|
|
155
139
|
embeddedHashSet
|
|
156
140
|
});
|
|
141
|
+
files.set("metadata.json", {
|
|
142
|
+
contents: JSON.stringify(contents)
|
|
143
|
+
});
|
|
157
144
|
}
|
|
158
145
|
// Additional web-only steps...
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
146
|
+
if (platforms.includes("web")) {
|
|
147
|
+
if (useServerRendering) {
|
|
148
|
+
var ref2;
|
|
149
|
+
const exportServer = ((ref2 = exp.web) == null ? void 0 : ref2.output) === "server";
|
|
150
|
+
if (exportServer) {
|
|
151
|
+
// TODO: Remove when this is abstracted into the files map
|
|
152
|
+
await (0, _publicFolder).copyPublicFolderAsync(publicPath, _path.default.resolve(outputPath, "client"));
|
|
153
|
+
}
|
|
154
|
+
await (0, _exportStaticAsync).unstable_exportStaticAsync(projectRoot, {
|
|
155
|
+
files,
|
|
156
|
+
clear: !!clear,
|
|
157
|
+
outputDir: outputPath,
|
|
158
|
+
minify,
|
|
159
|
+
baseUrl,
|
|
160
|
+
includeSourceMaps: sourceMaps,
|
|
161
|
+
asyncRoutes: (0, _metroOptions).getAsyncRoutesFromExpoConfig(exp, dev ? "development" : "production", "web"),
|
|
162
|
+
routerRoot: (0, _router).getRouterDirectoryModuleIdWithManifest(projectRoot, exp),
|
|
163
|
+
exportServer,
|
|
164
|
+
maxWorkers
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
// TODO: Unify with exportStaticAsync
|
|
168
|
+
// TODO: Maybe move to the serializer.
|
|
169
|
+
let html = await (0, _serializeHtml).serializeHtmlWithAssets({
|
|
170
|
+
mode: "production",
|
|
171
|
+
resources: bundles.web.artifacts,
|
|
172
|
+
template: await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(projectRoot, {
|
|
173
|
+
scripts: [],
|
|
174
|
+
cssLinks: []
|
|
175
|
+
}),
|
|
176
|
+
baseUrl
|
|
177
|
+
});
|
|
178
|
+
// Add the favicon assets to the HTML.
|
|
179
|
+
const modifyHtml = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, {
|
|
180
|
+
outputDir,
|
|
181
|
+
baseUrl,
|
|
182
|
+
files
|
|
183
|
+
});
|
|
184
|
+
if (modifyHtml) {
|
|
185
|
+
html = modifyHtml(html);
|
|
186
|
+
}
|
|
187
|
+
// Generate SPA-styled HTML file.
|
|
188
|
+
// If web exists, then write the template HTML file.
|
|
189
|
+
files.set("index.html", {
|
|
190
|
+
contents: html,
|
|
191
|
+
targetDomain: "client"
|
|
192
|
+
});
|
|
193
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);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Copy the contents of the public folder into the output folder.
|
|
201
|
-
* This enables users to add static files like `favicon.ico` or `serve.json`.
|
|
202
|
-
*
|
|
203
|
-
* The contents of this folder are completely universal since they refer to
|
|
204
|
-
* static network requests which fall outside the scope of React Native's magic
|
|
205
|
-
* platform resolution patterns.
|
|
206
|
-
*/ async function copyPublicFolderAsync(publicFolder, outputFolder) {
|
|
207
|
-
if (_fs.default.existsSync(publicFolder)) {
|
|
208
|
-
await (0, _dir).copyAsync(publicFolder, outputFolder);
|
|
209
194
|
}
|
|
195
|
+
// Write all files at the end for unified logging.
|
|
196
|
+
await (0, _saveAssets).persistMetroFilesAsync(files, outputPath);
|
|
210
197
|
}
|
|
211
198
|
|
|
212
199
|
//# sourceMappingURL=exportApp.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"AAAA;;;;QAsCsBA,cAAc,GAAdA,cAAc;AAtCV,IAAA,OAAc,WAAd,cAAc,CAAA;AACtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEiC,IAAA,aAAgB,WAAhB,gBAAgB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AIJ,GAAE,QAAA,CAACK,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 path from 'path';\n\nimport { createMetadataJson } from './createMetadataJson';\nimport { exportAssetsAsync } from './exportAssets';\nimport { unstable_exportStaticAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { createBundlesAsync } from './fork-bundleAsync';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync } from './publicFolder';\nimport { Options } from './resolveOptions';\nimport { ExportAssetMap, getFilesFromSerialAssets, persistMetroFilesAsync } from './saveAssets';\nimport { createAssetMap, createSourceMapDebugHtml } from './writeContents';\nimport * as Log from '../log';\nimport { getRouterDirectoryModuleIdWithManifest } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getAsyncRoutesFromExpoConfig,\n getBaseUrlFromExpoConfig,\n} from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { env } from '../utils/env';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n minify,\n maxWorkers,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'maxWorkers'\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 const outputPath = path.resolve(projectRoot, outputDir);\n\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\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 maxWorkers,\n });\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n\n const files: ExportAssetMap = new Map();\n\n Object.values(bundles).forEach((bundle) => {\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n });\n });\n\n const bundleEntries = Object.entries(bundles);\n // Can be empty during web-only SSG.\n if (bundleEntries.length) {\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts.filter((asset) => asset.type === 'js').map((asset) => asset.filename),\n ])\n );\n\n // build source maps\n if (sourceMaps) {\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 files.set('debug.html', {\n contents: createSourceMapDebugHtml({\n fileNames: Object.values(fileNames).flat(),\n }),\n });\n }\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web')) {\n if (useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n await unstable_exportStaticAsync(projectRoot, {\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n asyncRoutes: getAsyncRoutesFromExpoConfig(exp, dev ? 'development' : 'production', 'web'),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n exportServer,\n maxWorkers,\n });\n } else {\n // TODO: Unify with exportStaticAsync\n // TODO: Maybe move to the serializer.\n let html = await serializeHtmlWithAssets({\n mode: 'production',\n resources: bundles.web!.artifacts,\n template: await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [],\n cssLinks: [],\n }),\n baseUrl,\n });\n\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n files.set('index.html', {\n contents: html,\n targetDomain: 'client',\n });\n }\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","minify","maxWorkers","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","copyPublicFolderAsync","bundles","createBundlesAsync","sourcemaps","filter","platform","files","Map","Object","values","forEach","bundle","getFilesFromSerialAssets","artifacts","includeSourceMaps","bundleEntries","entries","assets","embeddedHashSet","exportAssetsAsync","set","contents","JSON","stringify","createAssetMap","fileNames","fromEntries","map","asset","type","filename","createSourceMapDebugHtml","flat","createMetadataJson","exportServer","unstable_exportStaticAsync","asyncRoutes","getAsyncRoutesFromExpoConfig","routerRoot","getRouterDirectoryModuleIdWithManifest","html","serializeHtmlWithAssets","mode","resources","template","createTemplateHtmlFromExpoConfigAsync","scripts","cssLinks","modifyHtml","getVirtualFaviconAssetsAsync","targetDomain","persistMetroFilesAsync"],"mappings":"AAAA;;;;QAyBsBA,cAAc,GAAdA,cAAc;AAzBV,IAAA,OAAc,WAAd,cAAc,CAAA;AACtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AACP,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,QAAW,WAAX,WAAW,CAAA;AACrB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AACZ,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AAC9B,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAE2B,IAAA,WAAc,WAAd,cAAc,CAAA;AACtC,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAC9DC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACwC,IAAA,OAA8B,WAA9B,8BAA8B,CAAA;AAC7C,IAAA,cAAqC,WAArC,qCAAqC,CAAA;AAItE,IAAA,aAAyC,WAAzC,yCAAyC,CAAA;AACM,IAAA,YAA6B,WAA7B,6BAA6B,CAA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
6
6
|
exports.resolveAssetPatternsToBeBundled = resolveAssetPatternsToBeBundled;
|
|
7
7
|
exports.exportAssetsAsync = exportAssetsAsync;
|
|
8
|
-
exports.exportCssAssetsAsync = exportCssAssetsAsync;
|
|
9
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
9
|
var _minimatch = _interopRequireDefault(require("minimatch"));
|
|
11
10
|
var _path = _interopRequireDefault(require("path"));
|
|
12
11
|
var _persistMetroAssets = require("./persistMetroAssets");
|
|
13
|
-
var _saveAssets = require("./saveAssets");
|
|
14
12
|
var Log = _interopRequireWildcard(require("../log"));
|
|
15
13
|
var _resolveAssets = require("../start/server/middleware/resolveAssets");
|
|
16
14
|
var _array = require("../utils/array");
|
|
@@ -112,13 +110,14 @@ function shouldBundleAsset(asset, patterns) {
|
|
|
112
110
|
return !!("__packager_asset" in asset && asset.__packager_asset && file && patterns.some((pattern)=>(0, _minimatch).default(file, pattern)
|
|
113
111
|
));
|
|
114
112
|
}
|
|
115
|
-
async function exportAssetsAsync(projectRoot, { exp , outputDir , bundles: { web , ...bundles } , baseUrl }) {
|
|
113
|
+
async function exportAssetsAsync(projectRoot, { exp , outputDir , bundles: { web , ...bundles } , baseUrl , files =new Map() }) {
|
|
116
114
|
var ref;
|
|
117
115
|
// NOTE: We use a different system for static web
|
|
118
116
|
if (web) {
|
|
119
117
|
// Save assets like a typical bundler, preserving the file paths on web.
|
|
120
118
|
// TODO: Update React Native Web to support loading files from asset hashes.
|
|
121
119
|
await (0, _persistMetroAssets).persistMetroAssetsAsync(web.assets, {
|
|
120
|
+
files,
|
|
122
121
|
platform: "web",
|
|
123
122
|
outputDirectory: outputDir,
|
|
124
123
|
baseUrl
|
|
@@ -149,10 +148,20 @@ async function exportAssetsAsync(projectRoot, { exp , outputDir , bundles: { web
|
|
|
149
148
|
});
|
|
150
149
|
debug(`Filtered assets count = ${filteredAssets.length}`);
|
|
151
150
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
const hashes = new Set();
|
|
152
|
+
// Add assets to copy.
|
|
153
|
+
filteredAssets.forEach((asset)=>{
|
|
154
|
+
const assetId = "fileSystemLocation" in asset ? _path.default.relative(projectRoot, _path.default.join(asset.fileSystemLocation, asset.name)) + (asset.type ? "." + asset.type : "") : undefined;
|
|
155
|
+
asset.files.forEach((fp, index)=>{
|
|
156
|
+
const hash = asset.fileHashes[index];
|
|
157
|
+
if (hashes.has(hash)) return;
|
|
158
|
+
hashes.add(hash);
|
|
159
|
+
files.set(_path.default.join("assets", hash), {
|
|
160
|
+
originFilename: _path.default.relative(projectRoot, fp),
|
|
161
|
+
contents: _fs.default.readFileSync(fp),
|
|
162
|
+
assetId
|
|
163
|
+
});
|
|
164
|
+
});
|
|
156
165
|
});
|
|
157
166
|
}
|
|
158
167
|
// Add google services file if it exists
|
|
@@ -160,23 +169,9 @@ async function exportAssetsAsync(projectRoot, { exp , outputDir , bundles: { web
|
|
|
160
169
|
return {
|
|
161
170
|
exp,
|
|
162
171
|
assets,
|
|
163
|
-
embeddedHashSet
|
|
172
|
+
embeddedHashSet,
|
|
173
|
+
files
|
|
164
174
|
};
|
|
165
175
|
}
|
|
166
|
-
async function exportCssAssetsAsync({ outputDir , bundles , baseUrl }) {
|
|
167
|
-
var ref;
|
|
168
|
-
const assets = (0, _array).uniqBy(Object.values(bundles).flatMap((bundle)=>bundle.css
|
|
169
|
-
), (asset)=>asset.filename
|
|
170
|
-
);
|
|
171
|
-
const cssDirectory = (ref = assets[0]) == null ? void 0 : ref.filename;
|
|
172
|
-
if (!cssDirectory) return [];
|
|
173
|
-
await _fs.default.promises.mkdir(_path.default.join(outputDir, _path.default.dirname(cssDirectory)), {
|
|
174
|
-
recursive: true
|
|
175
|
-
});
|
|
176
|
-
await Promise.all(assets.map((v)=>_fs.default.promises.writeFile(_path.default.join(outputDir, v.filename), v.source)
|
|
177
|
-
));
|
|
178
|
-
return assets.map((v)=>baseUrl + "/" + v.filename
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
176
|
|
|
182
177
|
//# sourceMappingURL=exportAssets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportAssets.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport minimatch from 'minimatch';\nimport path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { Asset, saveAssetsAsync } from './saveAssets';\nimport * as Log from '../log';\nimport { resolveGoogleServicesFile } from '../start/server/middleware/resolveAssets';\nimport { uniqBy } from '../utils/array';\n\nconst debug = require('debug')('expo:export:exportAssets') as typeof console.log;\n\nfunction mapAssetHashToAssetString(asset: Asset, hash: string) {\n return 'asset_' + hash + ('type' in asset && asset.type ? '.' + asset.type : '');\n}\n\nexport function assetPatternsToBeBundled(\n exp: ExpoConfig & { extra?: { updates?: { assetPatternsToBeBundled?: string[] } } }\n): string[] | undefined {\n return exp?.extra?.updates?.assetPatternsToBeBundled?.length\n ? exp?.extra?.updates?.assetPatternsToBeBundled\n : undefined;\n}\n\n/**\n * Given an asset and a set of strings representing the assets to be bundled, returns true if\n * the asset is part of the set to be bundled.\n * @param asset Asset object\n * @param bundledAssetsSet Set of strings\n * @returns true if the asset should be bundled\n */\nfunction assetShouldBeIncludedInExport(asset: Asset, bundledAssetsSet: Set<string> | undefined) {\n if (!bundledAssetsSet) {\n return true;\n }\n return (\n asset.fileHashes.filter((hash) => bundledAssetsSet.has(mapAssetHashToAssetString(asset, hash)))\n .length > 0\n );\n}\n\n/**\n * Computes a set of strings representing the assets to be bundled with an export, given an array of assets,\n * and a set of patterns to match\n * @param assets The asset array\n * @param assetPatternsToBeBundled An array of strings with glob patterns to match\n * @param projectRoot The project root\n * @returns A set of asset strings\n */\nfunction setOfAssetsToBeBundled(\n assets: Asset[],\n assetPatternsToBeBundled: string[],\n projectRoot: string\n): Set<string> | undefined {\n // Convert asset patterns to a list of asset strings that match them.\n // Assets strings are formatted as `asset_<hash>.<type>` and represent\n // the name that the file will have in the app bundle. The `asset_` prefix is\n // needed because android doesn't support assets that start with numbers.\n\n const fullPatterns: string[] = assetPatternsToBeBundled.map((p: string) =>\n path.join(projectRoot, p)\n );\n\n logPatterns(fullPatterns);\n\n const allBundledAssets = assets\n .map((asset) => {\n const shouldBundle = shouldBundleAsset(asset, fullPatterns);\n if (shouldBundle) {\n debug(`${shouldBundle ? 'Include' : 'Exclude'} asset ${asset.files?.[0]}`);\n return asset.fileHashes.map((hash) => mapAssetHashToAssetString(asset, hash));\n }\n return [];\n })\n .flat();\n\n // The assets returned by the RN packager has duplicates so make sure we\n // only bundle each once.\n return new Set(allBundledAssets);\n}\n\n/**\n * Resolves the assetBundlePatterns from the manifest and returns the set of assets to bundle.\n *\n * @modifies {exp}\n */\nexport function resolveAssetPatternsToBeBundled<T extends ExpoConfig>(\n projectRoot: string,\n exp: T,\n assets: Asset[]\n): Set<string> | undefined {\n if (!assetPatternsToBeBundled(exp)) {\n return undefined;\n }\n const bundledAssets = setOfAssetsToBeBundled(\n assets,\n assetPatternsToBeBundled(exp) ?? ['**/*'],\n projectRoot\n );\n return bundledAssets;\n}\n\nfunction logPatterns(patterns: string[]) {\n // Only log the patterns in debug mode, if they aren't already defined in the app.json, then all files will be targeted.\n Log.log('\\nProcessing asset bundle patterns:');\n patterns.forEach((p) => Log.log('- ' + p));\n}\n\nfunction shouldBundleAsset(asset: Asset, patterns: string[]) {\n const file = asset.files?.[0];\n return !!(\n '__packager_asset' in asset &&\n asset.__packager_asset &&\n file &&\n patterns.some((pattern) => minimatch(file, pattern))\n );\n}\n\nexport async function exportAssetsAsync(\n projectRoot: string,\n {\n exp,\n outputDir,\n bundles: { web, ...bundles },\n baseUrl,\n }: {\n exp: ExpoConfig;\n bundles: Partial<Record<string, BundleOutput>>;\n outputDir: string;\n baseUrl: string;\n }\n) {\n // NOTE: We use a different system for static web\n if (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(web.assets, {\n platform: 'web',\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n const assets: Asset[] = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.assets),\n (asset) => asset.hash\n );\n\n let bundledAssetsSet: Set<string> | undefined = undefined;\n let filteredAssets = assets;\n const embeddedHashSet: Set<string> = new Set();\n\n if (assets[0]?.fileHashes) {\n debug(`Assets = ${JSON.stringify(assets, null, 2)}`);\n // Updates the manifest to reflect additional asset bundling + configs\n // Get only asset strings for assets we will save\n bundledAssetsSet = resolveAssetPatternsToBeBundled(projectRoot, exp, assets);\n if (bundledAssetsSet) {\n debug(`Bundled assets = ${JSON.stringify([...bundledAssetsSet], null, 2)}`);\n // Filter asset objects to only ones that include assetPatternsToBeBundled matches\n filteredAssets = assets.filter((asset) => {\n const shouldInclude = assetShouldBeIncludedInExport(asset, bundledAssetsSet);\n if (!shouldInclude) {\n embeddedHashSet.add(asset.hash);\n }\n return shouldInclude;\n });\n debug(`Filtered assets count = ${filteredAssets.length}`);\n }\n Log.log('Saving assets');\n await saveAssetsAsync({ assets: filteredAssets, outputDir });\n }\n\n // Add google services file if it exists\n await resolveGoogleServicesFile(projectRoot, exp);\n\n return { exp, assets, embeddedHashSet };\n}\n\nexport async function exportCssAssetsAsync({\n outputDir,\n bundles,\n baseUrl,\n}: {\n bundles: Partial<Record<ModPlatform, BundleOutput>>;\n outputDir: string;\n baseUrl: string;\n}) {\n const assets = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.css),\n (asset) => asset.filename\n );\n\n const cssDirectory = assets[0]?.filename;\n if (!cssDirectory) return [];\n\n await fs.promises.mkdir(path.join(outputDir, path.dirname(cssDirectory)), { recursive: true });\n\n await Promise.all(\n assets.map((v) => fs.promises.writeFile(path.join(outputDir, v.filename), v.source))\n );\n\n return assets.map((v) => baseUrl + '/' + v.filename);\n}\n"],"names":["assetPatternsToBeBundled","resolveAssetPatternsToBeBundled","exportAssetsAsync","exportCssAssetsAsync","Log","debug","require","mapAssetHashToAssetString","asset","hash","type","exp","extra","updates","length","undefined","assetShouldBeIncludedInExport","bundledAssetsSet","fileHashes","filter","has","setOfAssetsToBeBundled","assets","projectRoot","fullPatterns","map","p","path","join","logPatterns","allBundledAssets","shouldBundle","shouldBundleAsset","files","flat","Set","bundledAssets","patterns","log","forEach","file","__packager_asset","some","pattern","minimatch","outputDir","bundles","web","baseUrl","persistMetroAssetsAsync","platform","outputDirectory","uniqBy","Object","values","flatMap","bundle","filteredAssets","embeddedHashSet","JSON","stringify","shouldInclude","add","saveAssetsAsync","resolveGoogleServicesFile","css","filename","cssDirectory","fs","promises","mkdir","dirname","recursive","Promise","all","v","writeFile","source"],"mappings":"AAAA;;;;QAmBgBA,wBAAwB,GAAxBA,wBAAwB;QAsExBC,+BAA+B,GAA/BA,+BAA+B;QAgCzBC,iBAAiB,GAAjBA,iBAAiB;QA6DjBC,oBAAoB,GAApBA,oBAAoB;AApL3B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACG,IAAA,UAAW,kCAAX,WAAW,EAAA;AAChB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGiB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,WAAc,WAAd,cAAc,CAAA;AACzCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,cAA0C,WAA1C,0CAA0C,CAAA;AAC7D,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAsB,AAAC;AAEjF,SAASC,yBAAyB,CAACC,KAAY,EAAEC,IAAY,EAAE;IAC7D,OAAO,QAAQ,GAAGA,IAAI,GAAG,CAAC,MAAM,IAAID,KAAK,IAAIA,KAAK,CAACE,IAAI,G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AEF,OAAOvD,MAAM,CAACG,GAAG,CAAC,CAACkD,CAAC,GAAK3B,OAAO,GAAG,GAAG,GAAG2B,CAAC,CAACT,QAAQ;IAAA,CAAC,CAAC;CACtD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportAssets.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport fs from 'fs';\nimport minimatch from 'minimatch';\nimport path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { Asset, ExportAssetMap } from './saveAssets';\nimport * as Log from '../log';\nimport { resolveGoogleServicesFile } from '../start/server/middleware/resolveAssets';\nimport { uniqBy } from '../utils/array';\n\nconst debug = require('debug')('expo:export:exportAssets') as typeof console.log;\n\nfunction mapAssetHashToAssetString(asset: Asset, hash: string) {\n return 'asset_' + hash + ('type' in asset && asset.type ? '.' + asset.type : '');\n}\n\nexport function assetPatternsToBeBundled(\n exp: ExpoConfig & { extra?: { updates?: { assetPatternsToBeBundled?: string[] } } }\n): string[] | undefined {\n return exp?.extra?.updates?.assetPatternsToBeBundled?.length\n ? exp?.extra?.updates?.assetPatternsToBeBundled\n : undefined;\n}\n\n/**\n * Given an asset and a set of strings representing the assets to be bundled, returns true if\n * the asset is part of the set to be bundled.\n * @param asset Asset object\n * @param bundledAssetsSet Set of strings\n * @returns true if the asset should be bundled\n */\nfunction assetShouldBeIncludedInExport(asset: Asset, bundledAssetsSet: Set<string> | undefined) {\n if (!bundledAssetsSet) {\n return true;\n }\n return (\n asset.fileHashes.filter((hash) => bundledAssetsSet.has(mapAssetHashToAssetString(asset, hash)))\n .length > 0\n );\n}\n\n/**\n * Computes a set of strings representing the assets to be bundled with an export, given an array of assets,\n * and a set of patterns to match\n * @param assets The asset array\n * @param assetPatternsToBeBundled An array of strings with glob patterns to match\n * @param projectRoot The project root\n * @returns A set of asset strings\n */\nfunction setOfAssetsToBeBundled(\n assets: Asset[],\n assetPatternsToBeBundled: string[],\n projectRoot: string\n): Set<string> | undefined {\n // Convert asset patterns to a list of asset strings that match them.\n // Assets strings are formatted as `asset_<hash>.<type>` and represent\n // the name that the file will have in the app bundle. The `asset_` prefix is\n // needed because android doesn't support assets that start with numbers.\n\n const fullPatterns: string[] = assetPatternsToBeBundled.map((p: string) =>\n path.join(projectRoot, p)\n );\n\n logPatterns(fullPatterns);\n\n const allBundledAssets = assets\n .map((asset) => {\n const shouldBundle = shouldBundleAsset(asset, fullPatterns);\n if (shouldBundle) {\n debug(`${shouldBundle ? 'Include' : 'Exclude'} asset ${asset.files?.[0]}`);\n return asset.fileHashes.map((hash) => mapAssetHashToAssetString(asset, hash));\n }\n return [];\n })\n .flat();\n\n // The assets returned by the RN packager has duplicates so make sure we\n // only bundle each once.\n return new Set(allBundledAssets);\n}\n\n/**\n * Resolves the assetBundlePatterns from the manifest and returns the set of assets to bundle.\n *\n * @modifies {exp}\n */\nexport function resolveAssetPatternsToBeBundled<T extends ExpoConfig>(\n projectRoot: string,\n exp: T,\n assets: Asset[]\n): Set<string> | undefined {\n if (!assetPatternsToBeBundled(exp)) {\n return undefined;\n }\n const bundledAssets = setOfAssetsToBeBundled(\n assets,\n assetPatternsToBeBundled(exp) ?? ['**/*'],\n projectRoot\n );\n return bundledAssets;\n}\n\nfunction logPatterns(patterns: string[]) {\n // Only log the patterns in debug mode, if they aren't already defined in the app.json, then all files will be targeted.\n Log.log('\\nProcessing asset bundle patterns:');\n patterns.forEach((p) => Log.log('- ' + p));\n}\n\nfunction shouldBundleAsset(asset: Asset, patterns: string[]) {\n const file = asset.files?.[0];\n return !!(\n '__packager_asset' in asset &&\n asset.__packager_asset &&\n file &&\n patterns.some((pattern) => minimatch(file, pattern))\n );\n}\n\nexport async function exportAssetsAsync(\n projectRoot: string,\n {\n exp,\n outputDir,\n bundles: { web, ...bundles },\n baseUrl,\n files = new Map(),\n }: {\n exp: ExpoConfig;\n bundles: Partial<Record<string, BundleOutput>>;\n outputDir: string;\n baseUrl: string;\n files?: ExportAssetMap;\n }\n) {\n // NOTE: We use a different system for static web\n if (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(web.assets, {\n files,\n platform: 'web',\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n const assets: Asset[] = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.assets),\n (asset) => asset.hash\n );\n\n let bundledAssetsSet: Set<string> | undefined = undefined;\n let filteredAssets = assets;\n const embeddedHashSet: Set<string> = new Set();\n\n if (assets[0]?.fileHashes) {\n debug(`Assets = ${JSON.stringify(assets, null, 2)}`);\n // Updates the manifest to reflect additional asset bundling + configs\n // Get only asset strings for assets we will save\n bundledAssetsSet = resolveAssetPatternsToBeBundled(projectRoot, exp, assets);\n if (bundledAssetsSet) {\n debug(`Bundled assets = ${JSON.stringify([...bundledAssetsSet], null, 2)}`);\n // Filter asset objects to only ones that include assetPatternsToBeBundled matches\n filteredAssets = assets.filter((asset) => {\n const shouldInclude = assetShouldBeIncludedInExport(asset, bundledAssetsSet);\n if (!shouldInclude) {\n embeddedHashSet.add(asset.hash);\n }\n return shouldInclude;\n });\n debug(`Filtered assets count = ${filteredAssets.length}`);\n }\n\n const hashes = new Set<string>();\n\n // Add assets to copy.\n filteredAssets.forEach((asset) => {\n const assetId =\n 'fileSystemLocation' in asset\n ? path.relative(projectRoot, path.join(asset.fileSystemLocation, asset.name)) +\n (asset.type ? '.' + asset.type : '')\n : undefined;\n\n asset.files.forEach((fp: string, index: number) => {\n const hash = asset.fileHashes[index];\n if (hashes.has(hash)) return;\n hashes.add(hash);\n files.set(path.join('assets', hash), {\n originFilename: path.relative(projectRoot, fp),\n contents: fs.readFileSync(fp),\n assetId,\n });\n });\n });\n }\n\n // Add google services file if it exists\n await resolveGoogleServicesFile(projectRoot, exp);\n\n return { exp, assets, embeddedHashSet, files };\n}\n"],"names":["assetPatternsToBeBundled","resolveAssetPatternsToBeBundled","exportAssetsAsync","Log","debug","require","mapAssetHashToAssetString","asset","hash","type","exp","extra","updates","length","undefined","assetShouldBeIncludedInExport","bundledAssetsSet","fileHashes","filter","has","setOfAssetsToBeBundled","assets","projectRoot","fullPatterns","map","p","path","join","logPatterns","allBundledAssets","shouldBundle","shouldBundleAsset","files","flat","Set","bundledAssets","patterns","log","forEach","file","__packager_asset","some","pattern","minimatch","outputDir","bundles","web","baseUrl","Map","persistMetroAssetsAsync","platform","outputDirectory","uniqBy","Object","values","flatMap","bundle","filteredAssets","embeddedHashSet","JSON","stringify","shouldInclude","add","hashes","assetId","relative","fileSystemLocation","name","fp","index","set","originFilename","contents","fs","readFileSync","resolveGoogleServicesFile"],"mappings":"AAAA;;;;QAkBgBA,wBAAwB,GAAxBA,wBAAwB;QAsExBC,+BAA+B,GAA/BA,+BAA+B;QAgCzBC,iBAAiB,GAAjBA,iBAAiB;AAvHxB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACG,IAAA,UAAW,kCAAX,WAAW,EAAA;AAChB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGiB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAElDC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,cAA0C,WAA1C,0CAA0C,CAAA;AAC7D,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAsB,AAAC;AAEjF,SAASC,yBAAyB,CAACC,KAAY,EAAEC,IAAY,EAAE;IAC7D,OAAO,QAAQ,GAAGA,IAAI,GAAG,CAAC,MAAM,IAAID,KAAK,IAAIA,KAAK,CAACE,IAAI,GAAG,GAAG,GAAGF,KAAK,CAACE,IAAI,GAAG,EAAE,CAAC,CAAC;CAClF;AAEM,SAAST,wBAAwB,CACtCU,GAAmF,EAC7D;QACfA,GAAU,cACbA,IAAU;IADd,OAAOA,CAAA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KAAI,QAAA,CAACC,IAAI,CAACpB,KAAK,CAAC2D,kBAAkB,EAAE3D,KAAK,CAAC4D,IAAI,CAAC,CAAC,GAC3E,CAAC5D,KAAK,CAACE,IAAI,GAAG,GAAG,GAAGF,KAAK,CAACE,IAAI,GAAG,EAAE,CAAC,GACpCK,SAAS,AAAC;YAEhBP,KAAK,CAACyB,KAAK,CAACM,OAAO,CAAC,CAAC8B,EAAU,EAAEC,KAAa,GAAK;gBACjD,MAAM7D,IAAI,GAAGD,KAAK,CAACU,UAAU,CAACoD,KAAK,CAAC,AAAC;gBACrC,IAAIN,MAAM,CAAC5C,GAAG,CAACX,IAAI,CAAC,EAAE,OAAO;gBAC7BuD,MAAM,CAACD,GAAG,CAACtD,IAAI,CAAC,CAAC;gBACjBwB,KAAK,CAACsC,GAAG,CAAC5C,KAAI,QAAA,CAACC,IAAI,CAAC,QAAQ,EAAEnB,IAAI,CAAC,EAAE;oBACnC+D,cAAc,EAAE7C,KAAI,QAAA,CAACuC,QAAQ,CAAC3C,WAAW,EAAE8C,EAAE,CAAC;oBAC9CI,QAAQ,EAAEC,GAAE,QAAA,CAACC,YAAY,CAACN,EAAE,CAAC;oBAC7BJ,OAAO;iBACR,CAAC,CAAC;aACJ,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ;IAED,wCAAwC;IACxC,MAAMW,CAAAA,GAAAA,cAAyB,AAAkB,CAAA,0BAAlB,CAACrD,WAAW,EAAEZ,GAAG,CAAC,CAAC;IAElD,OAAO;QAAEA,GAAG;QAAEW,MAAM;QAAEqC,eAAe;QAAE1B,KAAK;KAAE,CAAC;CAChD"}
|
|
@@ -46,7 +46,7 @@ async function exportAsync(projectRoot, options) {
|
|
|
46
46
|
// Stop any file watchers to prevent the CLI from hanging.
|
|
47
47
|
_fileNotifier.FileNotifier.stopAll();
|
|
48
48
|
// Final notes
|
|
49
|
-
Log.log(`
|
|
49
|
+
Log.log(`App exported to: ${options.outputDir}`);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
//# sourceMappingURL=exportAsync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportAsync.ts"],"sourcesContent":["import path from 'path';\n\nimport { exportAppAsync } from './exportApp';\nimport { Options } from './resolveOptions';\nimport * as Log from '../log';\nimport { FileNotifier } from '../utils/FileNotifier';\nimport { ensureDirectoryAsync, removeAsync } from '../utils/dir';\n\nexport async function exportAsync(projectRoot: string, options: Options) {\n // Ensure the output directory is created\n const outputPath = path.resolve(projectRoot, options.outputDir);\n // Delete the output directory if it exists\n await removeAsync(outputPath);\n // Create the output directory\n await ensureDirectoryAsync(outputPath);\n\n // Export the app\n await exportAppAsync(projectRoot, options);\n\n // Stop any file watchers to prevent the CLI from hanging.\n FileNotifier.stopAll();\n\n // Final notes\n Log.log(`
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportAsync.ts"],"sourcesContent":["import path from 'path';\n\nimport { exportAppAsync } from './exportApp';\nimport { Options } from './resolveOptions';\nimport * as Log from '../log';\nimport { FileNotifier } from '../utils/FileNotifier';\nimport { ensureDirectoryAsync, removeAsync } from '../utils/dir';\n\nexport async function exportAsync(projectRoot: string, options: Options) {\n // Ensure the output directory is created\n const outputPath = path.resolve(projectRoot, options.outputDir);\n // Delete the output directory if it exists\n await removeAsync(outputPath);\n // Create the output directory\n await ensureDirectoryAsync(outputPath);\n\n // Export the app\n await exportAppAsync(projectRoot, options);\n\n // Stop any file watchers to prevent the CLI from hanging.\n FileNotifier.stopAll();\n\n // Final notes\n Log.log(`App exported to: ${options.outputDir}`);\n}\n"],"names":["exportAsync","Log","projectRoot","options","outputPath","path","resolve","outputDir","removeAsync","ensureDirectoryAsync","exportAppAsync","FileNotifier","stopAll","log"],"mappings":"AAAA;;;;QAQsBA,WAAW,GAAXA,WAAW;AARhB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEQ,IAAA,UAAa,WAAb,aAAa,CAAA;AAEhCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,aAAuB,WAAvB,uBAAuB,CAAA;AACF,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzD,eAAeD,WAAW,CAACE,WAAmB,EAAEC,OAAgB,EAAE;IACvE,yCAAyC;IACzC,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACJ,WAAW,EAAEC,OAAO,CAACI,SAAS,CAAC,AAAC;IAChE,2CAA2C;IAC3C,MAAMC,CAAAA,GAAAA,IAAW,AAAY,CAAA,YAAZ,CAACJ,UAAU,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,MAAMK,CAAAA,GAAAA,IAAoB,AAAY,CAAA,qBAAZ,CAACL,UAAU,CAAC,CAAC;IAEvC,iBAAiB;IACjB,MAAMM,CAAAA,GAAAA,UAAc,AAAsB,CAAA,eAAtB,CAACR,WAAW,EAAEC,OAAO,CAAC,CAAC;IAE3C,0DAA0D;IAC1DQ,aAAY,aAAA,CAACC,OAAO,EAAE,CAAC;IAEvB,cAAc;IACdX,GAAG,CAACY,GAAG,CAAC,CAAC,iBAAiB,EAAEV,OAAO,CAACI,SAAS,CAAC,CAAC,CAAC,CAAC;CAClD"}
|
|
@@ -2,59 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.importHermesCommandFromProject = importHermesCommandFromProject;
|
|
6
5
|
exports.isEnableHermesManaged = isEnableHermesManaged;
|
|
7
|
-
exports.buildHermesBundleAsync = buildHermesBundleAsync;
|
|
8
|
-
exports.createHermesSourcemapAsync = createHermesSourcemapAsync;
|
|
9
6
|
exports.parseGradleProperties = parseGradleProperties;
|
|
10
7
|
exports.maybeThrowFromInconsistentEngineAsync = maybeThrowFromInconsistentEngineAsync;
|
|
11
8
|
exports.maybeInconsistentEngineAndroidAsync = maybeInconsistentEngineAndroidAsync;
|
|
12
9
|
exports.maybeInconsistentEngineIosAsync = maybeInconsistentEngineIosAsync;
|
|
13
10
|
exports.isHermesBytecodeBundleAsync = isHermesBytecodeBundleAsync;
|
|
14
11
|
exports.getHermesBytecodeBundleVersionAsync = getHermesBytecodeBundleVersionAsync;
|
|
15
|
-
var _spawnAsync = _interopRequireDefault(require("@expo/spawn-async"));
|
|
16
12
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
17
|
-
var _metroSourceMap = require("metro-source-map");
|
|
18
|
-
var _os = _interopRequireDefault(require("os"));
|
|
19
13
|
var _path = _interopRequireDefault(require("path"));
|
|
20
|
-
var _process = _interopRequireDefault(require("process"));
|
|
21
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
22
14
|
function _interopRequireDefault(obj) {
|
|
23
15
|
return obj && obj.__esModule ? obj : {
|
|
24
16
|
default: obj
|
|
25
17
|
};
|
|
26
18
|
}
|
|
27
|
-
function importHermesCommandFromProject(projectRoot) {
|
|
28
|
-
const platformExecutable = getHermesCommandPlatform();
|
|
29
|
-
const hermescLocations = [
|
|
30
|
-
// Override hermesc dir by environment variables
|
|
31
|
-
_process.default.env["REACT_NATIVE_OVERRIDE_HERMES_DIR"] ? `${_process.default.env["REACT_NATIVE_OVERRIDE_HERMES_DIR"]}/build/bin/hermesc` : "",
|
|
32
|
-
// Building hermes from source
|
|
33
|
-
"react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc",
|
|
34
|
-
// Prebuilt hermesc in official react-native 0.69+
|
|
35
|
-
`react-native/sdks/hermesc/${platformExecutable}`,
|
|
36
|
-
// Legacy hermes-engine package
|
|
37
|
-
`hermes-engine/${platformExecutable}`,
|
|
38
|
-
];
|
|
39
|
-
for (const location of hermescLocations){
|
|
40
|
-
try {
|
|
41
|
-
return (0, _resolveFrom).default(projectRoot, location);
|
|
42
|
-
} catch {}
|
|
43
|
-
}
|
|
44
|
-
throw new Error("Cannot find the hermesc executable.");
|
|
45
|
-
}
|
|
46
|
-
function getHermesCommandPlatform() {
|
|
47
|
-
switch(_os.default.platform()){
|
|
48
|
-
case "darwin":
|
|
49
|
-
return "osx-bin/hermesc";
|
|
50
|
-
case "linux":
|
|
51
|
-
return "linux64-bin/hermesc";
|
|
52
|
-
case "win32":
|
|
53
|
-
return "win64-bin/hermesc.exe";
|
|
54
|
-
default:
|
|
55
|
-
throw new Error(`Unsupported host platform for Hermes compiler: ${_os.default.platform()}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
19
|
function isEnableHermesManaged(expoConfig, platform) {
|
|
59
20
|
switch(platform){
|
|
60
21
|
case "android":
|
|
@@ -73,57 +34,6 @@ function isEnableHermesManaged(expoConfig, platform) {
|
|
|
73
34
|
return false;
|
|
74
35
|
}
|
|
75
36
|
}
|
|
76
|
-
async function buildHermesBundleAsync(projectRoot, { code , map , minify =false }) {
|
|
77
|
-
const tempDir = _path.default.join(_os.default.tmpdir(), `expo-bundler-${_process.default.pid}`);
|
|
78
|
-
await _fsExtra.default.ensureDir(tempDir);
|
|
79
|
-
try {
|
|
80
|
-
const tempBundleFile = _path.default.join(tempDir, "index.bundle");
|
|
81
|
-
await _fsExtra.default.writeFile(tempBundleFile, code);
|
|
82
|
-
if (map) {
|
|
83
|
-
const tempSourcemapFile = _path.default.join(tempDir, "index.bundle.map");
|
|
84
|
-
await _fsExtra.default.writeFile(tempSourcemapFile, map);
|
|
85
|
-
}
|
|
86
|
-
const tempHbcFile = _path.default.join(tempDir, "index.hbc");
|
|
87
|
-
const hermesCommand = importHermesCommandFromProject(projectRoot);
|
|
88
|
-
const args = [
|
|
89
|
-
"-emit-binary",
|
|
90
|
-
"-out",
|
|
91
|
-
tempHbcFile,
|
|
92
|
-
tempBundleFile
|
|
93
|
-
];
|
|
94
|
-
if (minify) {
|
|
95
|
-
args.push("-O");
|
|
96
|
-
}
|
|
97
|
-
if (map) {
|
|
98
|
-
args.push("-output-source-map");
|
|
99
|
-
}
|
|
100
|
-
await (0, _spawnAsync).default(hermesCommand, args);
|
|
101
|
-
let hbc;
|
|
102
|
-
let sourcemap = null;
|
|
103
|
-
if (!map) {
|
|
104
|
-
hbc = await _fsExtra.default.readFile(tempHbcFile);
|
|
105
|
-
} else {
|
|
106
|
-
[hbc, sourcemap] = await Promise.all([
|
|
107
|
-
_fsExtra.default.readFile(tempHbcFile),
|
|
108
|
-
createHermesSourcemapAsync(projectRoot, map, `${tempHbcFile}.map`),
|
|
109
|
-
]);
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
hbc,
|
|
113
|
-
sourcemap
|
|
114
|
-
};
|
|
115
|
-
} finally{
|
|
116
|
-
await _fsExtra.default.remove(tempDir);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async function createHermesSourcemapAsync(projectRoot, sourcemap, hermesMapFile) {
|
|
120
|
-
const bundlerSourcemap = JSON.parse(sourcemap);
|
|
121
|
-
const hermesSourcemap = await _fsExtra.default.readJSON(hermesMapFile);
|
|
122
|
-
return JSON.stringify((0, _metroSourceMap).composeSourceMaps([
|
|
123
|
-
bundlerSourcemap,
|
|
124
|
-
hermesSourcemap
|
|
125
|
-
]));
|
|
126
|
-
}
|
|
127
37
|
function parseGradleProperties(content) {
|
|
128
38
|
const result = {};
|
|
129
39
|
for (let line of content.split("\n")){
|