@expo/cli 0.7.3 → 0.9.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/README.md +1 -1
- package/build/bin/cli +17 -3
- package/build/bin/cli.map +1 -1
- package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
- package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
- package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
- package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
- package/build/src/api/graphql/queries/AppQuery.js +39 -0
- package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
- package/build/src/api/graphql/queries/UserQuery.js +10 -3
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
- package/build/src/api/graphql/types/App.js +23 -0
- package/build/src/api/graphql/types/App.js.map +1 -0
- package/build/src/api/signManifest.js +0 -12
- package/build/src/api/signManifest.js.map +1 -1
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/config/configAsync.js +3 -0
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/customize/customizeAsync.js +3 -0
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/export/createBundles.js +8 -3
- package/build/src/export/createBundles.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +23 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
- package/build/src/export/embed/index.js +117 -0
- package/build/src/export/embed/index.js.map +1 -0
- package/build/src/export/embed/resolveOptions.js +63 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -0
- package/build/src/export/exportApp.js +58 -31
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +17 -0
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +3 -0
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +179 -0
- package/build/src/export/exportStaticAsync.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +15 -43
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/html.js +21 -0
- package/build/src/export/html.js.map +1 -0
- package/build/src/export/index.js +5 -1
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +2 -2
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -0
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +3 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/writeContents.js +5 -2
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/graphql/generated.js +462 -0
- package/build/src/graphql/generated.js.map +1 -0
- package/build/src/install/checkPackages.js +6 -0
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/installAsync.js +18 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +6 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +3 -33
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/ensureConfigAsync.js +1 -12
- package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +7 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +7 -8
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +5 -0
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -8
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +33 -47
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
- package/build/src/run/android/runAndroidAsync.js +4 -0
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
- package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/run/startBundler.js +4 -0
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +13 -2
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +12 -4
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/index.js +3 -1
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +1 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -2
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +33 -2
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +167 -0
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +262 -3
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/externals.js +72 -0
- package/build/src/start/server/metro/externals.js.map +1 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +47 -48
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +137 -0
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
- package/build/src/start/server/metro/resolveFromProject.js +26 -3
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/router.js +15 -2
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +107 -0
- package/build/src/start/server/metro/runServer-fork.js.map +1 -0
- package/build/src/start/server/metro/symbolicate.js +6 -0
- package/build/src/start/server/metro/symbolicate.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +188 -45
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/CreateFileMiddleware.js +6 -3
- package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +113 -47
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +59 -20
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +27 -0
- package/build/src/start/server/type-generation/expo-env.js.map +1 -0
- package/build/src/start/server/type-generation/index.js +57 -0
- package/build/src/start/server/type-generation/index.js.map +1 -0
- package/build/src/start/server/type-generation/routes.js +291 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -0
- package/build/src/start/server/type-generation/tsconfig.js +89 -0
- package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
- package/build/src/start/server/webTemplate.js +20 -4
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/startAsync.js +30 -8
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +11 -4
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -1
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +31 -7
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/dir.js +16 -6
- 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/mergeGitIgnorePaths.js +42 -0
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/nodeEnv.js +11 -0
- package/build/src/utils/nodeEnv.js.map +1 -0
- package/build/src/utils/resolveArgs.js +43 -0
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/strings.js +24 -0
- package/build/src/utils/strings.js.map +1 -0
- package/build/src/utils/template.js +21 -0
- package/build/src/utils/template.js.map +1 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
- package/package.json +16 -10
- package/static/template/metro.config.js +4 -1
- package/build/src/api/getProject.js +0 -19
- package/build/src/api/getProject.js.map +0 -1
- package/build/src/api/graphql/generated.js +0 -113
- package/build/src/api/graphql/generated.js.map +0 -1
- package/build/src/prebuild/writeMetroConfig.js +0 -89
- package/build/src/prebuild/writeMetroConfig.js.map +0 -1
|
@@ -5,25 +5,60 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.getDeepLinkHandler = getDeepLinkHandler;
|
|
6
6
|
var _config = require("@expo/config");
|
|
7
7
|
var _devServer = require("@expo/dev-server");
|
|
8
|
+
var runtimeEnv = _interopRequireWildcard(require("@expo/env"));
|
|
9
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
var _log = require("../../../log");
|
|
8
14
|
var _getDevClientProperties = _interopRequireDefault(require("../../../utils/analytics/getDevClientProperties"));
|
|
9
15
|
var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
|
|
10
16
|
var _port = require("../../../utils/port");
|
|
11
17
|
var _bundlerDevServer = require("../BundlerDevServer");
|
|
18
|
+
var _getStaticRenderFunctions = require("../getStaticRenderFunctions");
|
|
12
19
|
var _createFileMiddleware = require("../middleware/CreateFileMiddleware");
|
|
13
20
|
var _historyFallbackMiddleware = require("../middleware/HistoryFallbackMiddleware");
|
|
14
21
|
var _interstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
|
|
22
|
+
var _manifestMiddleware = require("../middleware/ManifestMiddleware");
|
|
15
23
|
var _reactDevToolsPageMiddleware = require("../middleware/ReactDevToolsPageMiddleware");
|
|
16
24
|
var _runtimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
|
|
17
25
|
var _serveStaticMiddleware = require("../middleware/ServeStaticMiddleware");
|
|
26
|
+
var _typeGeneration = require("../type-generation");
|
|
18
27
|
var _instantiateMetro = require("./instantiateMetro");
|
|
28
|
+
var _metroErrorInterface = require("./metroErrorInterface");
|
|
29
|
+
var _metroWatchTypeScriptFiles = require("./metroWatchTypeScriptFiles");
|
|
30
|
+
var _waitForMetroToObserveTypeScriptFile = require("./waitForMetroToObserveTypeScriptFile");
|
|
19
31
|
function _interopRequireDefault(obj) {
|
|
20
32
|
return obj && obj.__esModule ? obj : {
|
|
21
33
|
default: obj
|
|
22
34
|
};
|
|
23
35
|
}
|
|
36
|
+
function _interopRequireWildcard(obj) {
|
|
37
|
+
if (obj && obj.__esModule) {
|
|
38
|
+
return obj;
|
|
39
|
+
} else {
|
|
40
|
+
var newObj = {};
|
|
41
|
+
if (obj != null) {
|
|
42
|
+
for(var key in obj){
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
45
|
+
if (desc.get || desc.set) {
|
|
46
|
+
Object.defineProperty(newObj, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
newObj[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
return newObj;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const debug = require("debug")("expo:start:server:metro");
|
|
24
58
|
/** Default port to use for apps running in Expo Go. */ const EXPO_GO_METRO_PORT = 19000;
|
|
25
59
|
/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */ const DEV_CLIENT_METRO_PORT = 8081;
|
|
26
60
|
class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
61
|
+
metro = null;
|
|
27
62
|
get name() {
|
|
28
63
|
return "metro";
|
|
29
64
|
}
|
|
@@ -34,6 +69,122 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
34
69
|
(options.devClient ? Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT : await (0, _port).getFreePortAsync(EXPO_GO_METRO_PORT));
|
|
35
70
|
return port;
|
|
36
71
|
}
|
|
72
|
+
/** Get routes from Expo Router. */ async getRoutesAsync() {
|
|
73
|
+
const url = this.getDevServerUrl();
|
|
74
|
+
(0, _assert).default(url, "Dev server must be started");
|
|
75
|
+
const { getManifest } = await (0, _getStaticRenderFunctions).getStaticRenderFunctions(this.projectRoot, url, {
|
|
76
|
+
// Ensure the API Routes are included
|
|
77
|
+
environment: "node"
|
|
78
|
+
});
|
|
79
|
+
return getManifest({
|
|
80
|
+
fetchData: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async composeResourcesWithHtml({ mode , resources , template , devBundleUrl }) {
|
|
84
|
+
const isDev = mode === "development";
|
|
85
|
+
return htmlFromSerialAssets(resources, {
|
|
86
|
+
dev: isDev,
|
|
87
|
+
template,
|
|
88
|
+
bundleUrl: isDev ? devBundleUrl : undefined
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async getStaticRenderFunctionAsync({ mode , minify =mode !== "development" }) {
|
|
92
|
+
const url = this.getDevServerUrl();
|
|
93
|
+
const { getStaticContent } = await (0, _getStaticRenderFunctions).getStaticRenderFunctions(this.projectRoot, url, {
|
|
94
|
+
minify,
|
|
95
|
+
dev: mode !== "production",
|
|
96
|
+
// Ensure the API Routes are included
|
|
97
|
+
environment: "node"
|
|
98
|
+
});
|
|
99
|
+
return async (path)=>{
|
|
100
|
+
return await getStaticContent(new URL(path, url));
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async getStaticResourcesAsync({ mode , minify =mode !== "development" }) {
|
|
104
|
+
const devBundleUrlPathname = (0, _manifestMiddleware).createBundleUrlPath({
|
|
105
|
+
platform: "web",
|
|
106
|
+
mode,
|
|
107
|
+
minify,
|
|
108
|
+
environment: "client",
|
|
109
|
+
serializerOutput: "static",
|
|
110
|
+
mainModuleName: (0, _manifestMiddleware).resolveMainModuleName(this.projectRoot, (0, _config).getConfig(this.projectRoot), "web")
|
|
111
|
+
});
|
|
112
|
+
const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl());
|
|
113
|
+
// Fetch the generated HTML from our custom Metro serializer
|
|
114
|
+
const results = await (0, _nodeFetch).default(bundleUrl.toString());
|
|
115
|
+
const txt = await results.text();
|
|
116
|
+
try {
|
|
117
|
+
return JSON.parse(txt);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
_log.Log.error("Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.");
|
|
120
|
+
debug(txt);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async renderStaticErrorAsync(error) {
|
|
125
|
+
return (0, _metroErrorInterface).getErrorOverlayHtmlAsync({
|
|
126
|
+
error,
|
|
127
|
+
projectRoot: this.projectRoot
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async getStaticPageAsync(pathname, { mode , minify =mode !== "development" }) {
|
|
131
|
+
const devBundleUrlPathname = (0, _manifestMiddleware).createBundleUrlPath({
|
|
132
|
+
platform: "web",
|
|
133
|
+
mode,
|
|
134
|
+
environment: "client",
|
|
135
|
+
mainModuleName: (0, _manifestMiddleware).resolveMainModuleName(this.projectRoot, (0, _config).getConfig(this.projectRoot), "web")
|
|
136
|
+
});
|
|
137
|
+
const bundleStaticHtml = async ()=>{
|
|
138
|
+
const { getStaticContent } = await (0, _getStaticRenderFunctions).getStaticRenderFunctions(this.projectRoot, this.getDevServerUrl(), {
|
|
139
|
+
minify: false,
|
|
140
|
+
dev: mode !== "production",
|
|
141
|
+
// Ensure the API Routes are included
|
|
142
|
+
environment: "node"
|
|
143
|
+
});
|
|
144
|
+
const location = new URL(pathname, this.getDevServerUrl());
|
|
145
|
+
return await getStaticContent(location);
|
|
146
|
+
};
|
|
147
|
+
const [resources, staticHtml] = await Promise.all([
|
|
148
|
+
this.getStaticResourcesAsync({
|
|
149
|
+
mode,
|
|
150
|
+
minify
|
|
151
|
+
}),
|
|
152
|
+
bundleStaticHtml(),
|
|
153
|
+
]);
|
|
154
|
+
const content = await this.composeResourcesWithHtml({
|
|
155
|
+
mode,
|
|
156
|
+
resources,
|
|
157
|
+
template: staticHtml,
|
|
158
|
+
devBundleUrl: devBundleUrlPathname
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
content,
|
|
162
|
+
resources
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
async watchEnvironmentVariables() {
|
|
166
|
+
if (!this.instance) {
|
|
167
|
+
throw new Error("Cannot observe environment variable changes without a running Metro instance.");
|
|
168
|
+
}
|
|
169
|
+
if (!this.metro) {
|
|
170
|
+
// This can happen when the run command is used and the server is already running in another
|
|
171
|
+
// process.
|
|
172
|
+
debug("Skipping Environment Variable observation because Metro is not running (headless).");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const envFiles = runtimeEnv.getFiles(process.env.NODE_ENV).map((fileName)=>_path.default.join(this.projectRoot, fileName)
|
|
176
|
+
);
|
|
177
|
+
(0, _waitForMetroToObserveTypeScriptFile).observeFileChanges({
|
|
178
|
+
metro: this.metro,
|
|
179
|
+
server: this.instance.server
|
|
180
|
+
}, envFiles, ()=>{
|
|
181
|
+
debug("Reloading environment variables...");
|
|
182
|
+
// Force reload the environment variables.
|
|
183
|
+
runtimeEnv.load(this.projectRoot, {
|
|
184
|
+
force: true
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
37
188
|
async startImplementationAsync(options) {
|
|
38
189
|
options.port = await this.resolvePortAsync(options);
|
|
39
190
|
this.urlCreator = this.getUrlCreator(options);
|
|
@@ -45,7 +196,9 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
45
196
|
// TODO: Deprecate this property when expo-cli goes away.
|
|
46
197
|
unversioned: false
|
|
47
198
|
};
|
|
48
|
-
|
|
199
|
+
// Required for symbolication:
|
|
200
|
+
process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;
|
|
201
|
+
const { metro , server , middleware , messageSocket } = await (0, _instantiateMetro).instantiateMetroAsync(this, parsedOptions);
|
|
49
202
|
const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
|
|
50
203
|
// We need the manifest handler to be the first middleware to run so our
|
|
51
204
|
// routes take precedence over static files. For example, the manifest is
|
|
@@ -53,7 +206,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
53
206
|
// then the manifest handler will never run, the static middleware will run
|
|
54
207
|
// and serve index.html instead of the manifest.
|
|
55
208
|
// https://github.com/expo/expo/issues/13114
|
|
56
|
-
(0, _devServer).prependMiddleware(middleware, manifestMiddleware);
|
|
209
|
+
(0, _devServer).prependMiddleware(middleware, manifestMiddleware.getHandler());
|
|
57
210
|
var _scheme;
|
|
58
211
|
middleware.use(new _interstitialPageMiddleware.InterstitialPageMiddleware(this.projectRoot, {
|
|
59
212
|
// TODO: Prevent this from becoming stale.
|
|
@@ -78,19 +231,54 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
78
231
|
middleware.use(new _createFileMiddleware.CreateFileMiddleware(this.projectRoot).getHandler());
|
|
79
232
|
// Append support for redirecting unhandled requests to the index.html page on web.
|
|
80
233
|
if (this.isTargetingWeb()) {
|
|
234
|
+
var ref2;
|
|
235
|
+
const { exp } = (0, _config).getConfig(this.projectRoot, {
|
|
236
|
+
skipSDKVersionRequirement: true
|
|
237
|
+
});
|
|
238
|
+
const useWebSSG = ((ref2 = exp.web) == null ? void 0 : ref2.output) === "static";
|
|
81
239
|
// This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.
|
|
82
240
|
middleware.use(new _serveStaticMiddleware.ServeStaticMiddleware(this.projectRoot).getHandler());
|
|
241
|
+
if (useWebSSG) {
|
|
242
|
+
middleware.use(async (req, res, next)=>{
|
|
243
|
+
if (!(req == null ? void 0 : req.url)) {
|
|
244
|
+
return next();
|
|
245
|
+
}
|
|
246
|
+
// TODO: Formal manifest for allowed paths
|
|
247
|
+
if (req.url.endsWith(".ico")) {
|
|
248
|
+
return next();
|
|
249
|
+
}
|
|
250
|
+
if (req.url.includes("serializer.output=static")) {
|
|
251
|
+
return next();
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
var _mode;
|
|
255
|
+
const { content } = await this.getStaticPageAsync(req.url, {
|
|
256
|
+
mode: (_mode = options.mode) != null ? _mode : "development"
|
|
257
|
+
});
|
|
258
|
+
res.setHeader("Content-Type", "text/html");
|
|
259
|
+
res.end(content);
|
|
260
|
+
return;
|
|
261
|
+
} catch (error) {
|
|
262
|
+
res.setHeader("Content-Type", "text/html");
|
|
263
|
+
res.end(await this.renderStaticErrorAsync(error));
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
83
267
|
// This MUST run last since it's the fallback.
|
|
84
|
-
|
|
268
|
+
if (!useWebSSG) {
|
|
269
|
+
middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler());
|
|
270
|
+
}
|
|
85
271
|
}
|
|
86
272
|
// Extend the close method to ensure that we clean up the local info.
|
|
87
273
|
const originalClose = server.close.bind(server);
|
|
88
274
|
server.close = (callback)=>{
|
|
89
275
|
return originalClose((err)=>{
|
|
90
276
|
this.instance = null;
|
|
277
|
+
this.metro = null;
|
|
91
278
|
callback == null ? void 0 : callback(err);
|
|
92
279
|
});
|
|
93
280
|
};
|
|
281
|
+
this.metro = metro;
|
|
94
282
|
return {
|
|
95
283
|
server,
|
|
96
284
|
location: {
|
|
@@ -106,6 +294,57 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
106
294
|
messageSocket
|
|
107
295
|
};
|
|
108
296
|
}
|
|
297
|
+
async waitForTypeScriptAsync() {
|
|
298
|
+
if (!this.instance) {
|
|
299
|
+
throw new Error("Cannot wait for TypeScript without a running server.");
|
|
300
|
+
}
|
|
301
|
+
return new Promise((resolve)=>{
|
|
302
|
+
if (!this.metro) {
|
|
303
|
+
// This can happen when the run command is used and the server is already running in another
|
|
304
|
+
// process. In this case we can't wait for the TypeScript check to complete because we don't
|
|
305
|
+
// have access to the Metro server.
|
|
306
|
+
debug("Skipping TypeScript check because Metro is not running (headless).");
|
|
307
|
+
return resolve(false);
|
|
308
|
+
}
|
|
309
|
+
const off = (0, _metroWatchTypeScriptFiles).metroWatchTypeScriptFiles({
|
|
310
|
+
projectRoot: this.projectRoot,
|
|
311
|
+
server: this.instance.server,
|
|
312
|
+
metro: this.metro,
|
|
313
|
+
tsconfig: true,
|
|
314
|
+
throttle: true,
|
|
315
|
+
eventTypes: [
|
|
316
|
+
"change",
|
|
317
|
+
"add"
|
|
318
|
+
],
|
|
319
|
+
callback: async ()=>{
|
|
320
|
+
// Run once, this prevents the TypeScript project prerequisite from running on every file change.
|
|
321
|
+
off();
|
|
322
|
+
const { TypeScriptProjectPrerequisite } = await Promise.resolve().then(function() {
|
|
323
|
+
return _interopRequireWildcard(require("../../doctor/typescript/TypeScriptProjectPrerequisite"));
|
|
324
|
+
});
|
|
325
|
+
try {
|
|
326
|
+
const req = new TypeScriptProjectPrerequisite(this.projectRoot);
|
|
327
|
+
await req.bootstrapAsync();
|
|
328
|
+
resolve(true);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
// Ensure the process doesn't fail if the TypeScript check fails.
|
|
331
|
+
// This could happen during the install.
|
|
332
|
+
_log.Log.log();
|
|
333
|
+
_log.Log.error(_chalk.default.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`);
|
|
334
|
+
_log.Log.exception(error);
|
|
335
|
+
resolve(false);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
async startTypeScriptServices() {
|
|
342
|
+
(0, _typeGeneration).typescriptTypeGeneration({
|
|
343
|
+
server: this.instance.server,
|
|
344
|
+
metro: this.metro,
|
|
345
|
+
projectRoot: this.projectRoot
|
|
346
|
+
});
|
|
347
|
+
}
|
|
109
348
|
getConfigModuleIds() {
|
|
110
349
|
return [
|
|
111
350
|
"./metro.config.js",
|
|
@@ -125,5 +364,25 @@ function getDeepLinkHandler(projectRoot) {
|
|
|
125
364
|
});
|
|
126
365
|
};
|
|
127
366
|
}
|
|
367
|
+
function htmlFromSerialAssets(assets, { dev , template , bundleUrl }) {
|
|
368
|
+
// Combine the CSS modules into tags that have hot refresh data attributes.
|
|
369
|
+
const styleString = assets.filter((asset)=>asset.type === "css"
|
|
370
|
+
).map(({ metadata , filename , source })=>{
|
|
371
|
+
if (dev) {
|
|
372
|
+
return `<style data-expo-css-hmr="${metadata.hmrId}">` + source + "\n</style>";
|
|
373
|
+
} else {
|
|
374
|
+
return [
|
|
375
|
+
`<link rel="preload" href="/${filename}" as="style">`,
|
|
376
|
+
`<link rel="stylesheet" href="/${filename}">`,
|
|
377
|
+
].join("");
|
|
378
|
+
}
|
|
379
|
+
}).join("");
|
|
380
|
+
const jsAssets = assets.filter((asset)=>asset.type === "js"
|
|
381
|
+
);
|
|
382
|
+
const scripts = bundleUrl ? `<script src="${bundleUrl}" defer></script>` : jsAssets.map(({ filename })=>{
|
|
383
|
+
return `<script src="/${filename}" defer></script>`;
|
|
384
|
+
}).join("");
|
|
385
|
+
return template.replace("</head>", `${styleString}</head>`).replace("</body>", `${scripts}\n</body>`);
|
|
386
|
+
}
|
|
128
387
|
|
|
129
388
|
//# sourceMappingURL=MetroBundlerDevServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { prependMiddleware } from '@expo/dev-server';\n\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(this, parsedOptions);\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: getDeepLinkHandler(this.projectRoot),\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This MUST run last since it's the fallback.\n middleware.use(new HistoryFallbackMiddleware(manifestMiddleware.internal).getHandler());\n }\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n\nexport function getDeepLinkHandler(projectRoot: string): DeepLinkHandler {\n return async ({ runtime }) => {\n if (runtime === 'expo') return;\n const { exp } = getConfig(projectRoot);\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n };\n}\n"],"names":["getDeepLinkHandler","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","projectRoot","scheme","location","getHandler","ReactDevToolsPageMiddleware","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","ServeStaticMiddleware","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","instance","host","url","protocol","getConfigModuleIds","exp","getConfig","logEventAsync","status","getDevClientProperties"],"mappings":"AAAA;;;;QAsIgBA,kBAAkB,GAAlBA,kBAAkB;AAtIR,IAAA,OAAc,WAAd,cAAc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QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGC,GAAG,CAAC,AA7GvB,CA6GwB;aACjB,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO;YACL9B,MAAM;YACNW,QAAQ,EAAE;gBACR,mDAAmD;gBACnD1B,IAAI,EAAED,OAAO,CAACC,IAAI;gBAClB,kCAAkC;gBAClC+C,IAAI,EAAE,WAAW;gBACjB,iDAAiD;gBACjDC,GAAG,EAAE,CAAC,iBAAiB,EAAEjD,OAAO,CAACC,IAAI,CAAC,CAAC;gBACvCiD,QAAQ,EAAE,MAAM;aACjB;YACDjC,UAAU;YACVC,aAAa;SACd,CAAC;KACH;IAED,AAAUiC,kBAAkB,GAAa;QACvC,OAAO;YAAC,mBAAmB;YAAE,qBAAqB;YAAE,oBAAoB;SAAC,CAAC;KAC3E;CACF;QA5GYvD,qBAAqB,GAArBA,qBAAqB;AA8G3B,SAASH,kBAAkB,CAACgC,WAAmB,EAAmB;IACvE,OAAO,OAAO,EAAES,OAAO,CAAA,EAAE,GAAK;QAC5B,IAAIA,OAAO,KAAK,MAAM,EAAE,OAAO;QAC/B,MAAM,EAAEkB,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAa,CAAA,UAAb,CAAC5B,WAAW,CAAC,AAAC;QACvC,MAAM6B,CAAAA,GAAAA,kBAAa,AAGjB,CAAA,cAHiB,CAAC,0BAA0B,EAAE;YAC9CC,MAAM,EAAE,SAAS;YACjB,GAAGC,CAAAA,GAAAA,uBAAsB,AAAkB,CAAA,QAAlB,CAAC/B,WAAW,EAAE2B,GAAG,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;CACH"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport { prependMiddleware } from '@expo/dev-server';\nimport * as runtimeEnv from '@expo/env';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fetch from 'node-fetch';\nimport path from 'path';\n\nimport { Log } from '../../../log';\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { getStaticRenderFunctions } from '../getStaticRenderFunctions';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { createBundleUrlPath, resolveMainModuleName } from '../middleware/ManifestMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { ServerNext, ServerRequest, ServerResponse } from '../middleware/server.types';\nimport { typescriptTypeGeneration } from '../type-generation';\nimport { instantiateMetroAsync } from './instantiateMetro';\nimport { getErrorOverlayHtmlAsync } from './metroErrorInterface';\nimport { metroWatchTypeScriptFiles } from './metroWatchTypeScriptFiles';\nimport { observeFileChanges } from './waitForMetroToObserveTypeScriptFile';\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n private metro: import('metro').Server | null = null;\n\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n /** Get routes from Expo Router. */\n async getRoutesAsync() {\n const url = this.getDevServerUrl();\n assert(url, 'Dev server must be started');\n const { getManifest } = await getStaticRenderFunctions(this.projectRoot, url, {\n // Ensure the API Routes are included\n environment: 'node',\n });\n\n return getManifest({ fetchData: true });\n }\n\n async composeResourcesWithHtml({\n mode,\n resources,\n template,\n devBundleUrl,\n }: {\n mode: 'development' | 'production';\n resources: SerialAsset[];\n template: string;\n devBundleUrl?: string;\n }) {\n const isDev = mode === 'development';\n return htmlFromSerialAssets(resources, {\n dev: isDev,\n template,\n bundleUrl: isDev ? devBundleUrl : undefined,\n });\n }\n\n async getStaticRenderFunctionAsync({\n mode,\n minify = mode !== 'development',\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n }) {\n const url = this.getDevServerUrl()!;\n\n const { getStaticContent } = await getStaticRenderFunctions(this.projectRoot, url, {\n minify,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n });\n return async (path: string) => {\n return await getStaticContent(new URL(path, url));\n };\n }\n\n async getStaticResourcesAsync({\n mode,\n minify = mode !== 'development',\n }: {\n mode: string;\n minify?: boolean;\n }): Promise<SerialAsset[]> {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n minify,\n environment: 'client',\n serializerOutput: 'static',\n mainModuleName: resolveMainModuleName(this.projectRoot, getConfig(this.projectRoot), 'web'),\n });\n\n const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl()!);\n\n // Fetch the generated HTML from our custom Metro serializer\n const results = await fetch(bundleUrl.toString());\n\n const txt = await results.text();\n\n try {\n return JSON.parse(txt);\n } catch (error: any) {\n Log.error(\n 'Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.'\n );\n debug(txt);\n throw error;\n }\n }\n\n private async renderStaticErrorAsync(error: Error) {\n return getErrorOverlayHtmlAsync({\n error,\n projectRoot: this.projectRoot,\n });\n }\n\n async getStaticPageAsync(\n pathname: string,\n {\n mode,\n minify = mode !== 'development',\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n }\n ) {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n environment: 'client',\n mainModuleName: resolveMainModuleName(this.projectRoot, getConfig(this.projectRoot), 'web'),\n });\n\n const bundleStaticHtml = async (): Promise<string> => {\n const { getStaticContent } = await getStaticRenderFunctions(\n this.projectRoot,\n this.getDevServerUrl()!,\n {\n minify: false,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n }\n );\n\n const location = new URL(pathname, this.getDevServerUrl()!);\n return await getStaticContent(location);\n };\n\n const [resources, staticHtml] = await Promise.all([\n this.getStaticResourcesAsync({ mode, minify }),\n bundleStaticHtml(),\n ]);\n const content = await this.composeResourcesWithHtml({\n mode,\n resources,\n template: staticHtml,\n devBundleUrl: devBundleUrlPathname,\n });\n return {\n content,\n resources,\n };\n }\n\n async watchEnvironmentVariables() {\n if (!this.instance) {\n throw new Error(\n 'Cannot observe environment variable changes without a running Metro instance.'\n );\n }\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process.\n debug('Skipping Environment Variable observation because Metro is not running (headless).');\n return;\n }\n\n const envFiles = runtimeEnv\n .getFiles(process.env.NODE_ENV)\n .map((fileName) => path.join(this.projectRoot, fileName));\n\n observeFileChanges(\n {\n metro: this.metro,\n server: this.instance.server,\n },\n envFiles,\n () => {\n debug('Reloading environment variables...');\n // Force reload the environment variables.\n runtimeEnv.load(this.projectRoot, { force: true });\n }\n );\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n // Required for symbolication:\n process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;\n\n const { metro, server, middleware, messageSocket } = await instantiateMetroAsync(\n this,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n\n prependMiddleware(middleware, manifestMiddleware.getHandler());\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: getDeepLinkHandler(this.projectRoot),\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const useWebSSG = exp.web?.output === 'static';\n\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n if (useWebSSG) {\n middleware.use(async (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n if (!req?.url) {\n return next();\n }\n\n // TODO: Formal manifest for allowed paths\n if (req.url.endsWith('.ico')) {\n return next();\n }\n if (req.url.includes('serializer.output=static')) {\n return next();\n }\n\n try {\n const { content } = await this.getStaticPageAsync(req.url, {\n mode: options.mode ?? 'development',\n });\n\n res.setHeader('Content-Type', 'text/html');\n res.end(content);\n return;\n } catch (error: any) {\n res.setHeader('Content-Type', 'text/html');\n res.end(await this.renderStaticErrorAsync(error));\n }\n });\n }\n\n // This MUST run last since it's the fallback.\n if (!useWebSSG) {\n middleware.use(\n new HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler()\n );\n }\n }\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n this.metro = null;\n callback?.(err);\n });\n };\n\n this.metro = metro;\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n if (!this.instance) {\n throw new Error('Cannot wait for TypeScript without a running server.');\n }\n\n return new Promise<boolean>((resolve) => {\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process. In this case we can't wait for the TypeScript check to complete because we don't\n // have access to the Metro server.\n debug('Skipping TypeScript check because Metro is not running (headless).');\n return resolve(false);\n }\n\n const off = metroWatchTypeScriptFiles({\n projectRoot: this.projectRoot,\n server: this.instance!.server,\n metro: this.metro,\n tsconfig: true,\n throttle: true,\n eventTypes: ['change', 'add'],\n callback: async () => {\n // Run once, this prevents the TypeScript project prerequisite from running on every file change.\n off();\n const { TypeScriptProjectPrerequisite } = await import(\n '../../doctor/typescript/TypeScriptProjectPrerequisite'\n );\n\n try {\n const req = new TypeScriptProjectPrerequisite(this.projectRoot);\n await req.bootstrapAsync();\n resolve(true);\n } catch (error: any) {\n // Ensure the process doesn't fail if the TypeScript check fails.\n // This could happen during the install.\n Log.log();\n Log.error(\n chalk.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`\n );\n Log.exception(error);\n resolve(false);\n }\n },\n });\n });\n }\n\n public async startTypeScriptServices() {\n typescriptTypeGeneration({\n server: this.instance!.server,\n metro: this.metro,\n projectRoot: this.projectRoot,\n });\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n\nexport function getDeepLinkHandler(projectRoot: string): DeepLinkHandler {\n return async ({ runtime }) => {\n if (runtime === 'expo') return;\n const { exp } = getConfig(projectRoot);\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n };\n}\n\nfunction htmlFromSerialAssets(\n assets: SerialAsset[],\n { dev, template, bundleUrl }: { dev: boolean; template: string; bundleUrl?: string }\n) {\n // Combine the CSS modules into tags that have hot refresh data attributes.\n const styleString = assets\n .filter((asset) => asset.type === 'css')\n .map(({ metadata, filename, source }) => {\n if (dev) {\n return `<style data-expo-css-hmr=\"${metadata.hmrId}\">` + source + '\\n</style>';\n } else {\n return [\n `<link rel=\"preload\" href=\"/${filename}\" as=\"style\">`,\n `<link rel=\"stylesheet\" href=\"/${filename}\">`,\n ].join('');\n }\n })\n .join('');\n\n const jsAssets = assets.filter((asset) => asset.type === 'js');\n\n const scripts = bundleUrl\n ? `<script src=\"${bundleUrl}\" defer></script>`\n : jsAssets\n .map(({ filename }) => {\n return `<script src=\"/${filename}\" defer></script>`;\n })\n .join('');\n\n return template\n .replace('</head>', `${styleString}</head>`)\n .replace('</body>', `${scripts}\\n</body>`);\n}\n"],"names":["getDeepLinkHandler","runtimeEnv","debug","require","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","metro","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","getRoutesAsync","url","getDevServerUrl","assert","getManifest","getStaticRenderFunctions","projectRoot","environment","fetchData","composeResourcesWithHtml","mode","resources","template","devBundleUrl","isDev","htmlFromSerialAssets","dev","bundleUrl","undefined","getStaticRenderFunctionAsync","minify","getStaticContent","path","URL","getStaticResourcesAsync","devBundleUrlPathname","createBundleUrlPath","platform","serializerOutput","mainModuleName","resolveMainModuleName","getConfig","results","fetch","toString","txt","text","JSON","parse","error","Log","renderStaticErrorAsync","getErrorOverlayHtmlAsync","getStaticPageAsync","pathname","bundleStaticHtml","location","staticHtml","Promise","all","content","watchEnvironmentVariables","instance","Error","envFiles","getFiles","NODE_ENV","map","fileName","join","observeFileChanges","server","load","force","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","EXPO_DEV_SERVER_ORIGIN","middleware","messageSocket","instantiateMetroAsync","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","getHandler","use","InterstitialPageMiddleware","scheme","ReactDevToolsPageMiddleware","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","exp","skipSDKVersionRequirement","useWebSSG","web","output","ServeStaticMiddleware","req","res","next","endsWith","includes","setHeader","end","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","host","protocol","waitForTypeScriptAsync","resolve","off","metroWatchTypeScriptFiles","tsconfig","throttle","eventTypes","TypeScriptProjectPrerequisite","bootstrapAsync","log","chalk","red","exception","startTypeScriptServices","typescriptTypeGeneration","getConfigModuleIds","logEventAsync","status","getDevClientProperties","assets","styleString","filter","asset","type","metadata","filename","source","hmrId","jsAssets","scripts","replace"],"mappings":"AAMA;;;;QAwagBA,kBAAkB,GAAlBA,kBAAkB;AAxaR,IAAA,OAAc,WAAd,cAAc,CAAA;AACN,IAAA,UAAkB,WAA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Default(require("chalk"));
|
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _link = require("../../../utils/link");
|
|
11
11
|
var _terminalReporter = require("./TerminalReporter");
|
|
12
|
+
var _externals = require("./externals");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
13
14
|
return obj && obj.__esModule ? obj : {
|
|
14
15
|
default: obj
|
|
@@ -103,7 +104,7 @@ function formatUsingNodeStandardLibraryError(projectRoot, error) {
|
|
|
103
104
|
return `Unable to resolve "${targetModuleName}" from "${relativePath}"`;
|
|
104
105
|
}
|
|
105
106
|
function isNodeStdLibraryModule(moduleName) {
|
|
106
|
-
return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);
|
|
107
|
+
return /^node:/.test(moduleName) || _externals.NODE_STDLIB_MODULES.includes(moduleName);
|
|
107
108
|
}
|
|
108
109
|
/** If the code frame can be found then append it to the existing message. */ function maybeAppendCodeFrame(message, rawMessage) {
|
|
109
110
|
const codeFrame = stripMetroInfo(rawMessage);
|
|
@@ -141,38 +142,5 @@ function stripMetroInfo(errorMessage) {
|
|
|
141
142
|
}
|
|
142
143
|
return "";
|
|
143
144
|
}
|
|
144
|
-
// A list of the Node.js standard library modules.
|
|
145
|
-
const NODE_STDLIB_MODULES = [
|
|
146
|
-
"assert",
|
|
147
|
-
"async_hooks",
|
|
148
|
-
"buffer",
|
|
149
|
-
"child_process",
|
|
150
|
-
"cluster",
|
|
151
|
-
"crypto",
|
|
152
|
-
"dgram",
|
|
153
|
-
"dns",
|
|
154
|
-
"domain",
|
|
155
|
-
"events",
|
|
156
|
-
"fs",
|
|
157
|
-
"fs/promises",
|
|
158
|
-
"http",
|
|
159
|
-
"https",
|
|
160
|
-
"net",
|
|
161
|
-
"os",
|
|
162
|
-
"path",
|
|
163
|
-
"punycode",
|
|
164
|
-
"querystring",
|
|
165
|
-
"readline",
|
|
166
|
-
"repl",
|
|
167
|
-
"stream",
|
|
168
|
-
"string_decoder",
|
|
169
|
-
"tls",
|
|
170
|
-
"tty",
|
|
171
|
-
"url",
|
|
172
|
-
"util",
|
|
173
|
-
"v8",
|
|
174
|
-
"vm",
|
|
175
|
-
"zlib",
|
|
176
|
-
];
|
|
177
145
|
|
|
178
146
|
//# sourceMappingURL=MetroTerminalReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { learnMore } from '../../../utils/link';\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport { BuildPhase, BundleDetails, BundleProgress, SnippetError } from './TerminalReporter.types';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(public projectRoot: string, terminal: Terminal) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: number): number {\n return Date.now() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const platform = getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundling complete ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n const time = startTime != null ? chalk.dim(this._getElapsedTime(startTime) + 'ms') : '';\n // iOS Bundling complete 150ms\n return color(platform + status) + time;\n }\n\n const localPath = path.relative('.', progress.bundleDetails.entryFile);\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}/`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log('Starting Metro Bundler');\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n if (moduleResolutionError) {\n return this.terminal.log(maybeAppendCodeFrame(moduleResolutionError, error.message));\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n\n// A list of the Node.js standard library modules.\nconst NODE_STDLIB_MODULES = [\n 'assert',\n 'async_hooks',\n 'buffer',\n 'child_process',\n 'cluster',\n 'crypto',\n 'dgram',\n 'dns',\n 'domain',\n 'events',\n 'fs',\n 'fs/promises',\n 'http',\n 'https',\n 'net',\n 'os',\n 'path',\n 'punycode',\n 'querystring',\n 'readline',\n 'repl',\n 'stream',\n 'string_decoder',\n 'tls',\n 'tty',\n 'url',\n 'util',\n 'v8',\n 'vm',\n 'zlib',\n];\n"],"names":["formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","MetroTerminalReporter","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","Date","now","_getBundleStatusMessage","progress","phase","platform","getPlatformTagForBuildDetails","bundleDetails","inProgress","status","color","chalk","green","red","_bundleTimers","get","buildID","time","dim","localPath","path","relative","entryFile","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","bold","toFixed","padStart","transformedFileCount","toString","totalFileCount","length","reset","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","maybeAppendCodeFrame","message","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","includes","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web"],"mappings":"AAAA;;;;QAuHgBA,mCAAmC,GAAnCA,mCAAmC;QAwCnCC,sBAAsB,GAAtBA,sBAAsB;QAkBtBC,cAAc,GAAdA,cAAc;AAjLZ,IAAA,MAAO,kCAAP,OAAO,EAAA;AAER,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACF,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;AAGjE,MAAMC,2BAA2B,GAAG,EAAE,AAAC;AACvC,MAAMC,eAAe,GAAG,QAAQ,AAAC;AACjC,MAAMC,gBAAgB,GAAG,QAAQ,AAAC;AAK3B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzDC,YAAmBC,WAAmB,EAAEC,QAAkB,CAAE;QAC1D,KAAK,CAACA,QAAQ,CAAC,CAAC;aADCD,WAAmB,GAAnBA,WAAmB;KAErC;IAED,mBAAmB;IACnBE,eAAe,CAACC,SAAiB,EAAU;QACzC,OAAOC,IAAI,CAACC,GAAG,EAAE,GAAGF,SAAS,CAAC;KAC/B;IACD;;;;KAIG,CACHG,uBAAuB,CAACC,QAAwB,EAAEC,KAAiB,EAAU;QAC3E,MAAMC,QAAQ,GAAGC,6BAA6B,CAACH,QAAQ,CAACI,aAAa,CAAC,AAAC;QACvE,MAAMC,UAAU,GAAGJ,KAAK,KAAK,aAAa,AAAC;QAE3C,IAAI,CAACI,UAAU,EAAE;YACf,MAAMC,MAAM,GAAGL,KAAK,KAAK,MAAM,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,AAAC;YAC5E,MAAMM,KAAK,GAAGN,KAAK,KAAK,MAAM,GAAGO,MAAK,QAAA,CAACC,KAAK,GAAGD,MAAK,QAAA,CAACE,GAAG,AAAC;YAEzD,MAAMd,SAAS,GAAG,IAAI,CAACe,aAAa,CAACC,GAAG,CAACZ,QAAQ,CAAC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CAAC,CAAC,CAAC,CAC1C;CACH;AAED,kEAAkE,CAClE,SAASvE,6BAA6B,CAACC,aAAoC,EAAU;QAClEA,GAAuB;IAAxC,MAAMF,QAAQ,GAAGE,CAAAA,GAAuB,GAAvBA,aAAa,QAAU,GAAvBA,KAAAA,CAAuB,GAAvBA,aAAa,CAAEF,QAAQ,YAAvBE,GAAuB,GAAI,IAAI,AAAC;IACjD,IAAIF,QAAQ,EAAE;QACZ,MAAMyE,SAAS,GAAG;YAAEC,GAAG,EAAE,KAAK;YAAEC,OAAO,EAAE,SAAS;YAAEC,GAAG,EAAE,KAAK;SAAE,CAAC5E,QAAQ,CAAC,IAAIA,QAAQ,AAAC;QACvF,OAAO,CAAC,EAAEM,MAAK,QAAA,CAACqB,IAAI,CAAC8C,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAED,OAAO,EAAE,CAAC;CACX;AAED,kDAAkD;AAClD,MAAMX,mBAAmB,GAAG;IAC1B,QAAQ;IACR,aAAa;IACb,QAAQ;IACR,eAAe;IACf,SAAS;IACT,QAAQ;IACR,OAAO;IACP,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,aAAa;IACb,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;IACJ,MAAM;IACN,UAAU;IACV,aAAa;IACb,UAAU;IACV,MAAM;IACN,QAAQ;IACR,gBAAgB;IAChB,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;CACP,AAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { learnMore } from '../../../utils/link';\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport { BuildPhase, BundleDetails, BundleProgress, SnippetError } from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(public projectRoot: string, terminal: Terminal) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: number): number {\n return Date.now() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const platform = getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundling complete ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n const time = startTime != null ? chalk.dim(this._getElapsedTime(startTime) + 'ms') : '';\n // iOS Bundling complete 150ms\n return color(platform + status) + time;\n }\n\n const localPath = path.relative('.', progress.bundleDetails.entryFile);\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}/`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log('Starting Metro Bundler');\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n if (moduleResolutionError) {\n return this.terminal.log(maybeAppendCodeFrame(moduleResolutionError, error.message));\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n"],"names":["formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","MetroTerminalReporter","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","Date","now","_getBundleStatusMessage","progress","phase","platform","getPlatformTagForBuildDetails","bundleDetails","inProgress","status","color","chalk","green","red","_bundleTimers","get","buildID","time","dim","localPath","path","relative","entryFile","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","bold","toFixed","padStart","transformedFileCount","toString","totalFileCount","length","reset","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","maybeAppendCodeFrame","message","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","includes","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web"],"mappings":"AAAA;;;;QAwHgBA,mCAAmC,GAAnCA,mCAAmC;QAwCnCC,sBAAsB,GAAtBA,sBAAsB;QAkBtBC,cAAc,GAAdA,cAAc;AAlLZ,IAAA,MAAO,kCAAP,OAAO,EAAA;AAER,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACF,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE7B,IAAA,UAAa,WAAb,aAAa,CAAA;;;;;;AAEjD,MAAMC,2BAA2B,GAAG,EAAE,AAAC;AACvC,MAAMC,eAAe,GAAG,QAAQ,AAAC;AACjC,MAAMC,gBAAgB,GAAG,QAAQ,AAAC;AAK3B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzDC,YAAmBC,WAAmB,EAAEC,QAAkB,CAAE;QAC1D,KAAK,CAACA,QAAQ,CAAC,CAAC;aADCD,WAAmB,GAAnBA,WAAmB;KAErC;IAED,mBAAmB;IACnBE,eAAe,CAACC,SAAiB,EAAU;QACzC,OAAOC,IAAI,CAACC,GAAG,EAAE,GAAGF,SAAS,CAAC;KAC/B;IACD;;;;KAI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