@expo/cli 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,133 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ ### 🎉 New features
8
+
9
+ ### 🐛 Bug fixes
10
+
11
+ ### 💡 Others
12
+
13
+ ## 0.2.2 — 2022-07-18
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 0.2.1 — 2022-07-11
18
+
19
+ ### 💡 Others
20
+
21
+ - Drop hardcoded web package versions in prerequisite. ([#18172](https://github.com/expo/expo/pull/18172) by [@EvanBacon](https://github.com/EvanBacon))
22
+
23
+ ## 0.2.0 — 2022-07-07
24
+
25
+ ### 🛠 Breaking changes
26
+
27
+ - Change `expo` to `expo-internal` (DO NOT USE) for `@expo/cli`. ([#17468](https://github.com/expo/expo/pull/17468) by [@EvanBacon](https://github.com/EvanBacon))
28
+
29
+ ### 🎉 New features
30
+
31
+ - Validate Android SDK configuration before using ([#17259](https://github.com/expo/expo/pull/17259) by [@byCedric](https://github.com/byCedric))
32
+ - Add CI context to telemetry to help determine support on used CI providers ([#17284](https://github.com/expo/expo/pull/17284) by [@byCedric](https://github.com/byCedric))
33
+ - add `--pnpm` option to `install` command. ([#17366](https://github.com/expo/expo/pull/17366) by [@EvanBacon](https://github.com/EvanBacon))
34
+ - Added `export:web` command. ([#17363](https://github.com/expo/expo/pull/17363) by [@EvanBacon](https://github.com/EvanBacon))
35
+ - Bail out on missing web dependencies. ([#17448](https://github.com/expo/expo/pull/17448) by [@EvanBacon](https://github.com/EvanBacon))
36
+ - Add info about using the `--clear` flag when the `babel.config.js` file changes during `expo start`. ([#17560](https://github.com/expo/expo/pull/17560) by [@EvanBacon](https://github.com/EvanBacon))
37
+ - Automatically enable `DEBUG` when `EXPO_DEBUG` is enabled. ([#17856](https://github.com/expo/expo/pull/17856) by [@EvanBacon](https://github.com/EvanBacon))
38
+ - add migration warning for old commands. ([#17882](https://github.com/expo/expo/pull/17882) by [@EvanBacon](https://github.com/EvanBacon))
39
+ - Add web support for Metro bundler. ([#17927](https://github.com/expo/expo/pull/17927) by [@EvanBacon](https://github.com/EvanBacon))
40
+ - Add multi-platform bundle logging during `expo export`. ([#17992](https://github.com/expo/expo/pull/17992) by [@EvanBacon](https://github.com/EvanBacon))
41
+ - Upgrade react-native to 0.69. ([#18006](https://github.com/expo/expo/pull/18006) by [@kudo](https://github.com/kudo))
42
+
43
+ ### 🐛 Bug fixes
44
+
45
+ - Remove hanging `emulator` process on exit. ([#17273](https://github.com/expo/expo/pull/17273) by [@EvanBacon](https://github.com/EvanBacon))
46
+ - Fix bug where autocomplete prompts crash when escape characters are used. ([#17271](https://github.com/expo/expo/pull/17271) by [@EvanBacon](https://github.com/EvanBacon))
47
+ - add missing `--platform` flag to `export` command. ([#17338](https://github.com/expo/expo/pull/17338) by [@EvanBacon](https://github.com/EvanBacon))
48
+ - Fix ADB device name filtering for windows. ([#17286](https://github.com/expo/expo/pull/17286) by [@byCedric](https://github.com/byCedric))
49
+ - Fix `export` bug failing when no assets are included. ([#17414](https://github.com/expo/expo/pull/17414) by [@EvanBacon](https://github.com/EvanBacon))
50
+ - Add correct packages (`expo-splash-screen`) and drop incorrect required packages (`react-native-unimodules`, `expo-updates`) in prebuild. ([#17447](https://github.com/expo/expo/pull/17447) by [@EvanBacon](https://github.com/EvanBacon))
51
+ - Fix tunnel on web breaking native. ([#17666](https://github.com/expo/expo/pull/17666) by [@EvanBacon](https://github.com/EvanBacon))
52
+ - Add no-op `--experimental-bundle` flag to `expo export`. ([#17886](https://github.com/expo/expo/pull/17886) by [@EvanBacon](https://github.com/EvanBacon))
53
+ - Fix auto TypeScript version check. ([#17911](https://github.com/expo/expo/pull/17911) by [@EvanBacon](https://github.com/EvanBacon))
54
+ - Fix ignored existing plugins on expo install. ([#17936](https://github.com/expo/expo/pull/17936) by [@kbrandwijk](https://github.com/kbrandwijk))
55
+
56
+ ### 💡 Others
57
+
58
+ - Bump `@expo/xcpretty` to link to the troubleshooting guide. ([#17576](https://github.com/expo/expo/pull/17576) by [@EvanBacon](https://github.com/EvanBacon))
59
+ - deduplicate asMock helper function. ([#17294](https://github.com/expo/expo/pull/17294) by [@wschurman](https://github.com/wschurman))
60
+ - Use `nxp expo install` for recommended missing dependency check. ([#17665](https://github.com/expo/expo/pull/17665) by [@EvanBacon](https://github.com/EvanBacon))
61
+ - Make bundler implementation more bundler agnostic. ([#17575](https://github.com/expo/expo/pull/17575) by [@EvanBacon](https://github.com/EvanBacon))
62
+ - Add debug log about unversioned packages. ([#17664](https://github.com/expo/expo/pull/17664) by [@EvanBacon](https://github.com/EvanBacon))
63
+ - Update test fixtures to SDK 45. ([#17934](https://github.com/expo/expo/pull/17934) by [@EvanBacon](https://github.com/EvanBacon))
64
+ - Bump `@expo/xcpretty` with support for `react-native@0.69` build errors. ([#17986](https://github.com/expo/expo/pull/17986) by [@EvanBacon](https://github.com/EvanBacon))
65
+
66
+ ## 0.1.3 — 2022-04-28
67
+
68
+ ### 🐛 Bug fixes
69
+
70
+ - add missing `pretty-bytes` dependency. ([#17235](https://github.com/expo/expo/pull/17235) by [@EvanBacon](https://github.com/EvanBacon))
71
+
72
+ ## 0.1.2 — 2022-04-27
73
+
74
+ _This version does not introduce any user-facing changes._
75
+
76
+ ## 0.1.1 — 2022-04-27
77
+
78
+ ### 🎉 New features
79
+
80
+ - Unify help prompts. ([#17223](https://github.com/expo/expo/pull/17223) by [@EvanBacon](https://github.com/EvanBacon))
81
+ - Added `expo run:android` command. ([#17187](https://github.com/expo/expo/pull/17187) by [@EvanBacon](https://github.com/EvanBacon))
82
+
83
+ ### 🐛 Bug fixes
84
+
85
+ - Add support for `react-native@0.68` dev server API. ([#17189](https://github.com/expo/expo/pull/17189) by [@EvanBacon](https://github.com/EvanBacon))
86
+
87
+ ### 💡 Others
88
+
89
+ - Downgrade `fs-extra` to `8.1.0`. ([#17234](https://github.com/expo/expo/pull/17234) by [@EvanBacon](https://github.com/EvanBacon))
90
+
91
+ ## 0.1.0 — 2022-04-25
92
+
93
+ ### 🎉 New features
94
+
95
+ - [cli] Added modules for interacting with Apple and Android platforms. ([#16516](https://github.com/expo/expo/pull/16516) by [@EvanBacon](https://github.com/EvanBacon))
96
+ - [cli] Added middleware for showing the interstitial page and redirecting users to dev clients. ([#16560](https://github.com/expo/expo/pull/16560) by [@EvanBacon](https://github.com/EvanBacon))
97
+ - [cli] Added middleware for dev servers to host Expo manifests. ([#16559](https://github.com/expo/expo/pull/16559) by [@EvanBacon](https://github.com/EvanBacon))
98
+ - [cli] Added module for starting host tunnels with Ngrok. ([#16556](https://github.com/expo/expo/pull/16556) by [@EvanBacon](https://github.com/EvanBacon))
99
+ - [cli] Added module for updating the "development session" API. ([#16555](https://github.com/expo/expo/pull/16555) by [@EvanBacon](https://github.com/EvanBacon))
100
+ - [cli] Added modules for creating dev server URLs, akin to `UrlUtils` in `xdl`. ([#16557](https://github.com/expo/expo/pull/16557) by [@EvanBacon](https://github.com/EvanBacon))
101
+ - [cli] Added shim for `expo start` command and option resolvers. ([#16587](https://github.com/expo/expo/pull/16587) by [@EvanBacon](https://github.com/EvanBacon))
102
+ - [cli] Added module for interacting with Metro bundler. ([#16631](https://github.com/expo/expo/pull/16631) by [@EvanBacon](https://github.com/EvanBacon))
103
+ - [cli] Added Terminal UI to `expo start`. ([#16518](https://github.com/expo/expo/pull/16518) by [@EvanBacon](https://github.com/EvanBacon))
104
+ - [cli] Added a custom terminal logger for Metro dev server. ([#16658](https://github.com/expo/expo/pull/16658) by [@EvanBacon](https://github.com/EvanBacon))
105
+ - [cli] Added module for interacting with Webpack bundler. ([#16659](https://github.com/expo/expo/pull/16659) by [@EvanBacon](https://github.com/EvanBacon))
106
+ - Added `expo run:ios` command. ([#16662](https://github.com/expo/expo/pull/16662) by [@EvanBacon](https://github.com/EvanBacon))
107
+ - Fixed type errors. ([#16724](https://github.com/expo/expo/pull/16724) by [@EvanBacon](https://github.com/EvanBacon))
108
+ - Disable watch mode in CI. ([#16730](https://github.com/expo/expo/pull/16730) by [@EvanBacon](https://github.com/EvanBacon))
109
+ - Added `install` command. ([#16756](https://github.com/expo/expo/pull/16756) by [@EvanBacon](https://github.com/EvanBacon))
110
+ - Serve modern manifests in multipart format. ([#16804](https://github.com/expo/expo/pull/16804) by [@wschurman](https://github.com/wschurman))
111
+ - Add development code signing. ([#16845](https://github.com/expo/expo/pull/16845) by [@wschurman](https://github.com/wschurman))
112
+ - Added `export` command. ([#17034](https://github.com/expo/expo/pull/17034) by [@EvanBacon](https://github.com/EvanBacon))
113
+ - Add `--fix` and `--check` arguments to `install` command. ([#17048](https://github.com/expo/expo/pull/17048) by [@EvanBacon](https://github.com/EvanBacon))
114
+ - Added `customize` command. ([#17186](https://github.com/expo/expo/pull/17186) by [@EvanBacon](https://github.com/EvanBacon))
115
+
116
+ ### 🐛 Bug fixes
117
+
118
+ - Fix process memory leak warning in `expo start`. ([#16753](https://github.com/expo/expo/pull/16753) by [@EvanBacon](https://github.com/EvanBacon))
119
+ - Fix build watcher. ([#16754](https://github.com/expo/expo/pull/16754) by [@EvanBacon](https://github.com/EvanBacon))
120
+ - Allow bailing out of Terminal UI during long processes. ([#16818](https://github.com/expo/expo/pull/16818) by [@EvanBacon](https://github.com/EvanBacon))
121
+ - Fix web imports and dependency resolution. ([#16820](https://github.com/expo/expo/pull/16820) by [@EvanBacon](https://github.com/EvanBacon))
122
+ - [test] Update login error message to reflect server change. ([#16932](https://github.com/expo/expo/pull/16932) by [@EvanBacon](https://github.com/EvanBacon))
123
+ - Fix webpack imports and server timeouts. ([#17006](https://github.com/expo/expo/pull/17006) by [@EvanBacon](https://github.com/EvanBacon))
124
+ - Skip font parsing on prebuild. ([#17184](https://github.com/expo/expo/pull/17184) by [@EvanBacon](https://github.com/EvanBacon))
125
+ - [ci] Fix `typecheck`. ([#17145](https://github.com/expo/expo/pull/17145) by [@EvanBacon](https://github.com/EvanBacon))
126
+ - Close development session when CLI is stopped ([#17170](https://github.com/expo/expo/pull/17170) by [@FiberJW](https://github.com/FiberJW))
127
+
128
+ ### 💡 Others
129
+
130
+ - Improve contributing. ([#16917](https://github.com/expo/expo/pull/16917) by [@EvanBacon](https://github.com/EvanBacon))
131
+ - Reduce mock clearing and add `Log` import/export. ([#17046](https://github.com/expo/expo/pull/17046) by [@EvanBacon](https://github.com/EvanBacon))
132
+ - Migrate to using `DEBUG=expo:*` instead of `EXPO_DEBUG`. ([#17084](https://github.com/expo/expo/pull/17084) by [@EvanBacon](https://github.com/EvanBacon))
133
+ - Lazily evaluate all environment variables. ([#17082](https://github.com/expo/expo/pull/17082) by [@EvanBacon](https://github.com/EvanBacon))
package/build/bin/cli CHANGED
@@ -118,7 +118,7 @@ const args = (0, _arg).default({
118
118
  });
119
119
  if (args["--version"]) {
120
120
  // Version is added in the build script.
121
- console.log("0.2.1");
121
+ console.log("0.2.2");
122
122
  process.exit(0);
123
123
  }
124
124
  // Check if we are running `npx expo <subcommand>` or `npx expo`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/getNativeModuleVersions.ts"],"sourcesContent":["import { CommandError } from '../utils/errors';\nimport { createCachedFetch } from './rest/client';\n\ninterface NativeModule {\n npmPackage: string;\n versionRange: string;\n}\ntype BundledNativeModuleList = NativeModule[];\n\nexport type BundledNativeModules = Record<string, string>;\n\n/**\n * The endpoint returns the list of bundled native modules for a given SDK version.\n * The data is populated by the `et sync-bundled-native-modules` script from expo/expo repo.\n * See the code for more details:\n * https://github.com/expo/expo/blob/main/tools/src/commands/SyncBundledNativeModules.ts\n *\n * Example result:\n * [\n * {\n * id: \"79285187-e5c4-47f7-b6a9-664f5d16f0db\",\n * sdkVersion: \"41.0.0\",\n * npmPackage: \"expo-analytics-amplitude\",\n * versionRange: \"~10.1.0\",\n * createdAt: \"2021-04-29T09:34:32.825Z\",\n * updatedAt: \"2021-04-29T09:34:32.825Z\"\n * },\n * ...\n * ]\n */\nexport async function getNativeModuleVersionsAsync(\n sdkVersion: string\n): Promise<BundledNativeModules> {\n const fetchAsync = createCachedFetch({\n cacheDirectory: 'native-modules-cache',\n // 1 minute cache\n ttl: 1000 * 60 * 1,\n });\n const results = await fetchAsync(`sdks/${sdkVersion}/native-modules`);\n if (!results.ok) {\n throw new CommandError(\n 'API',\n `Unexpected response when fetching version info from Expo servers: ${results.statusText}.`\n );\n }\n const { data } = await results.json();\n if (!data.length) {\n throw new CommandError('VERSIONS', 'The bundled native module list from the Expo API is empty');\n }\n return fromBundledNativeModuleList(data);\n}\n\nfunction fromBundledNativeModuleList(list: BundledNativeModuleList): BundledNativeModules {\n return list.reduce((acc, i) => {\n acc[i.npmPackage] = i.versionRange;\n return acc;\n }, {} as BundledNativeModules);\n}\n"],"names":["getNativeModuleVersionsAsync","sdkVersion","fetchAsync","createCachedFetch","cacheDirectory","ttl","results","ok","CommandError","statusText","data","json","length","fromBundledNativeModuleList","list","reduce","acc","i","npmPackage","versionRange"],"mappings":"AAAA;;;;QA8BsBA,4BAA4B,GAA5BA,4BAA4B;AA9BrB,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACZ,IAAA,OAAe,WAAf,eAAe,CAAA;AA6B1C,eAAeA,4BAA4B,CAChDC,UAAkB,EACa;IAC/B,MAAMC,UAAU,GAAGC,CAAAA,GAAAA,OAAiB,AAIlC,CAAA,kBAJkC,CAAC;QACnCC,cAAc,EAAE,sBAAsB;QACtC,iBAAiB;QACjBC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC;KACnB,CAAC,AAAC;IACH,MAAMC,OAAO,GAAG,MAAMJ,UAAU,CAAC,CAAC,KAAK,EAAED,UAAU,CAAC,eAAe,CAAC,CAAC,AAAC;IACtE,IAAI,CAACK,OAAO,CAACC,EAAE,EAAE;QACf,MAAM,IAAIC,OAAY,aAAA,CACpB,KAAK,EACL,CAAC,kEAAkE,EAAEF,OAAO,CAACG,UAAU,CAAC,CAAC,CAAC,CAC3F,CAAC;KACH;IACD,MAAM,EAAEC,IAAI,CAAA,EAAE,GAAG,MAAMJ,OAAO,CAACK,IAAI,EAAE,AAAC;IACtC,IAAI,CAACD,IAAI,CAACE,MAAM,EAAE;QAChB,MAAM,IAAIJ,OAAY,aAAA,CAAC,UAAU,EAAE,2DAA2D,CAAC,CAAC;KACjG;IACD,OAAOK,2BAA2B,CAACH,IAAI,CAAC,CAAC;CAC1C;AAED,SAASG,2BAA2B,CAACC,IAA6B,EAAwB;IACxF,OAAOA,IAAI,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,GAAK;QAC7BD,GAAG,CAACC,CAAC,CAACC,UAAU,CAAC,GAAGD,CAAC,CAACE,YAAY,CAAC;QACnC,OAAOH,GAAG,CAAC;KACZ,EAAE,EAAE,CAAyB,CAAC;CAChC"}
1
+ {"version":3,"sources":["../../../src/api/getNativeModuleVersions.ts"],"sourcesContent":["import { CommandError } from '../utils/errors';\nimport { createCachedFetch } from './rest/client';\n\ninterface NativeModule {\n npmPackage: string;\n versionRange: string;\n}\ntype BundledNativeModuleList = NativeModule[];\n\nexport type BundledNativeModules = Record<string, string>;\n\n/**\n * The endpoint returns the list of bundled native modules for a given SDK version.\n * The data is populated by the `et sync-bundled-native-modules` script from expo/expo repo.\n * See the code for more details:\n * https://github.com/expo/expo/blob/main/tools/src/commands/SyncBundledNativeModules.ts\n *\n * Example result:\n * [\n * {\n * id: \"79285187-e5c4-47f7-b6a9-664f5d16f0db\",\n * sdkVersion: \"41.0.0\",\n * npmPackage: \"expo-camera\",\n * versionRange: \"~10.1.0\",\n * createdAt: \"2021-04-29T09:34:32.825Z\",\n * updatedAt: \"2021-04-29T09:34:32.825Z\"\n * },\n * ...\n * ]\n */\nexport async function getNativeModuleVersionsAsync(\n sdkVersion: string\n): Promise<BundledNativeModules> {\n const fetchAsync = createCachedFetch({\n cacheDirectory: 'native-modules-cache',\n // 1 minute cache\n ttl: 1000 * 60 * 1,\n });\n const results = await fetchAsync(`sdks/${sdkVersion}/native-modules`);\n if (!results.ok) {\n throw new CommandError(\n 'API',\n `Unexpected response when fetching version info from Expo servers: ${results.statusText}.`\n );\n }\n const { data } = await results.json();\n if (!data.length) {\n throw new CommandError('VERSIONS', 'The bundled native module list from the Expo API is empty');\n }\n return fromBundledNativeModuleList(data);\n}\n\nfunction fromBundledNativeModuleList(list: BundledNativeModuleList): BundledNativeModules {\n return list.reduce((acc, i) => {\n acc[i.npmPackage] = i.versionRange;\n return acc;\n }, {} as BundledNativeModules);\n}\n"],"names":["getNativeModuleVersionsAsync","sdkVersion","fetchAsync","createCachedFetch","cacheDirectory","ttl","results","ok","CommandError","statusText","data","json","length","fromBundledNativeModuleList","list","reduce","acc","i","npmPackage","versionRange"],"mappings":"AAAA;;;;QA8BsBA,4BAA4B,GAA5BA,4BAA4B;AA9BrB,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACZ,IAAA,OAAe,WAAf,eAAe,CAAA;AA6B1C,eAAeA,4BAA4B,CAChDC,UAAkB,EACa;IAC/B,MAAMC,UAAU,GAAGC,CAAAA,GAAAA,OAAiB,AAIlC,CAAA,kBAJkC,CAAC;QACnCC,cAAc,EAAE,sBAAsB;QACtC,iBAAiB;QACjBC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC;KACnB,CAAC,AAAC;IACH,MAAMC,OAAO,GAAG,MAAMJ,UAAU,CAAC,CAAC,KAAK,EAAED,UAAU,CAAC,eAAe,CAAC,CAAC,AAAC;IACtE,IAAI,CAACK,OAAO,CAACC,EAAE,EAAE;QACf,MAAM,IAAIC,OAAY,aAAA,CACpB,KAAK,EACL,CAAC,kEAAkE,EAAEF,OAAO,CAACG,UAAU,CAAC,CAAC,CAAC,CAC3F,CAAC;KACH;IACD,MAAM,EAAEC,IAAI,CAAA,EAAE,GAAG,MAAMJ,OAAO,CAACK,IAAI,EAAE,AAAC;IACtC,IAAI,CAACD,IAAI,CAACE,MAAM,EAAE;QAChB,MAAM,IAAIJ,OAAY,aAAA,CAAC,UAAU,EAAE,2DAA2D,CAAC,CAAC;KACjG;IACD,OAAOK,2BAA2B,CAACH,IAAI,CAAC,CAAC;CAC1C;AAED,SAASG,2BAA2B,CAACC,IAA6B,EAAwB;IACxF,OAAOA,IAAI,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,GAAK;QAC7BD,GAAG,CAACC,CAAC,CAACC,UAAU,CAAC,GAAGD,CAAC,CAACE,YAAY,CAAC;QACnC,OAAOH,GAAG,CAAC;KACZ,EAAE,EAAE,CAAyB,CAAC;CAChC"}
@@ -60,7 +60,6 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
60
60
  ...options
61
61
  });
62
62
  config = (0, _withMetroMultiPlatform).withMetroMultiPlatform(projectRoot, config, (0, _platformBundlers).getPlatformBundlers(exp));
63
- // @ts-expect-error
64
63
  const metroServer = await metro.runMetro(config, {
65
64
  watch: false
66
65
  });
@@ -95,6 +94,7 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
95
94
  terminalReporter.update({
96
95
  buildID,
97
96
  type: "bundle_build_started",
97
+ // @ts-expect-error: TODO
98
98
  bundleDetails
99
99
  });
100
100
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatform } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n config = withMetroMultiPlatform(projectRoot, config, getPlatformBundlers(exp));\n\n // @ts-expect-error\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? !bundle.dev,\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map,\n bundle.minify\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","withMetroMultiPlatform","getPlatformBundlers","metroServer","runMetro","watch","buildAsync","bundle","buildID","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAgFsBA,WAAW,GAAXA,WAAW;AAhFmC,IAAA,OAAc,WAAd,cAAc,CAAA;AAK3E,IAAA,cAAsC,WAAtC,sCAAsC,CAAA;AAKtC,IAAA,uBAAqD,WAArD,qDAAqD,CAAA;AAE1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEA,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEC,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAC5C,IAAA,uBAA8C,WAA9C,8CAA8C,CAAA;AACjD,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;;;;;;AAwBtE,SAASC,kBAAkB,CACzBC,WAAmB,EACnB,EAAEC,MAAM,CAAA,EAAyC,EACZ;IACrC,IAAI;QACF,OAAOC,CAAAA,GAAAA,uBAAgC,AAAa,CAAA,iCAAb,CAACF,WAAW,CAAC,CAAC;KACtD,CAAC,OAAM;IACN,sFAAsF;KACvF;IAED,MAAMG,kBAAkB,GAAGC,OAAO,CAAC,iCAAiC,CAAC,CAACC,OAAO,AAAC;IAC9EJ,MAAM,CAACK,IAAI,CACT;QAAEC,GAAG,EAAE,MAAM;KAAE,EACfC,MAAK,QAAA,CAACC,IAAI,CACR,CAAC,mBAAmB,EAAED,MAAK,QAAA,CAACE,IAAI,CAAC,mBAAmB,EAAEP,kBAAkB,CAAC,CAAC,CAAC,oGAAoG,EAAEK,MAAK,QAAA,CAACE,IAAI,CAAC,IAAI,CAAC,CAAC,8EAA8E,CAAC,CAClR,CACF,CAAC;IAEF,OAAON,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACtC;AAED,IAAIO,WAAW,GAAG,CAAC,AAAC;AAEp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,CAAE;YACvC,sEAAsE;YACtE,qCAAqC;YACrCD,aAAa,CAACG,IAAI,CAAC,MAAMjB,yBAAyB,CAACpD,OAAO,CAACmE,CAAC,CAAC,EAAEF,mBAAmB,CAACE,CAAC,CAAC,CAAC,CAAC,CAAC;SACzF;QACD,OAAOD,aAAa,CAAC;KACtB,CAAC,OAAOf,KAAK,EAAE;QACd,gEAAgE;QAChEmB,OAAO,CAACZ,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAMP,KAAK,CAAC;KACb,QAAS;QACR3B,WAAW,CAAC+C,GAAG,EAAE,CAAC;KACnB;CACF"}
1
+ {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatform } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n config = withMetroMultiPlatform(projectRoot, config, getPlatformBundlers(exp));\n\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? !bundle.dev,\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n // @ts-expect-error: TODO\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map,\n bundle.minify\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","withMetroMultiPlatform","getPlatformBundlers","metroServer","runMetro","watch","buildAsync","bundle","buildID","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAgFsBA,WAAW,GAAXA,WAAW;AAhFmC,IAAA,OAAc,WAAd,cAAc,CAAA;AAK3E,IAAA,cAAsC,WAAtC,sCAAsC,CAAA;AAKtC,IAAA,uBAAqD,WAArD,qDAAqD,CAAA;AAE1C,IA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F"}
@@ -49,7 +49,6 @@ async function instantiateMetroAsync(projectRoot, options) {
49
49
  return middleware.use(metroMiddleware);
50
50
  };
51
51
  const server1 = await Metro.runServer(metroConfig, {
52
- // @ts-expect-error: TODO: Update the types.
53
52
  hmrEnabled: true,
54
53
  websocketEndpoints
55
54
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { MetroDevServerOptions } from '@expo/dev-server';\nimport http from 'http';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { createDevServerMiddleware } from '../middleware/createDevServerMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importExpoMetroConfigFromProject, importMetroFromProject } from './resolveFromProject';\nimport { withMetroMultiPlatform } from './withMetroMultiPlatform';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n projectRoot: string,\n options: Omit<MetroDevServerOptions, 'logger'>\n): Promise<{\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n let reportEvent: ((event: any) => void) | undefined;\n\n const Metro = importMetroFromProject(projectRoot);\n const ExpoMetroConfig = importExpoMetroConfigFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n let metroConfig = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true, skipPlugins: true });\n const platformBundlers = getPlatformBundlers(exp);\n metroConfig = withMetroMultiPlatform(projectRoot, metroConfig, platformBundlers);\n\n const {\n middleware,\n attachToServer,\n\n // New\n websocketEndpoints,\n eventsSocketEndpoint,\n messageSocketEndpoint,\n } = createDevServerMiddleware(projectRoot, {\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-ignore can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n const server = await Metro.runServer(metroConfig, {\n // @ts-expect-error: TODO: Update the types.\n hmrEnabled: true,\n websocketEndpoints,\n });\n\n if (attachToServer) {\n // Expo SDK 44 and lower\n const { messageSocket, eventsSocket } = attachToServer(server);\n reportEvent = eventsSocket.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket,\n };\n } else {\n // RN +68 -- Expo SDK +45\n reportEvent = eventsSocketEndpoint.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n }\n}\n"],"names":["instantiateMetroAsync","projectRoot","options","reportEvent","Metro","importMetroFromProject","ExpoMetroConfig","importExpoMetroConfigFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","metroConfig","loadAsync","exp","getConfig","skipSDKVersionRequirement","skipPlugins","platformBundlers","getPlatformBundlers","withMetroMultiPlatform","middleware","attachToServer","websocketEndpoints","eventsSocketEndpoint","messageSocketEndpoint","createDevServerMiddleware","port","server","watchFolders","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","use","runServer","hmrEnabled","messageSocket","eventsSocket"],"mappings":"AAAA;;;;QAkBsBA,qBAAqB,GAArBA,qBAAqB;AAlBjB,IAAA,OAAc,WAAd,cAAc,CAAA;AAIf,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEK,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC/C,IAAA,iB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,CAAC;QAE/C,OAAO;YACL8B,MAAM,EAANA,OAAM;YACNP,UAAU;YACVe,aAAa,EAAEX,qBAAqB;SACrC,CAAC;KACH;CACF"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { MetroDevServerOptions } from '@expo/dev-server';\nimport http from 'http';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { createDevServerMiddleware } from '../middleware/createDevServerMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importExpoMetroConfigFromProject, importMetroFromProject } from './resolveFromProject';\nimport { withMetroMultiPlatform } from './withMetroMultiPlatform';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n projectRoot: string,\n options: Omit<MetroDevServerOptions, 'logger'>\n): Promise<{\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n let reportEvent: ((event: any) => void) | undefined;\n\n const Metro = importMetroFromProject(projectRoot);\n const ExpoMetroConfig = importExpoMetroConfigFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n let metroConfig = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true, skipPlugins: true });\n const platformBundlers = getPlatformBundlers(exp);\n metroConfig = withMetroMultiPlatform(projectRoot, metroConfig, platformBundlers);\n\n const {\n middleware,\n attachToServer,\n\n // New\n websocketEndpoints,\n eventsSocketEndpoint,\n messageSocketEndpoint,\n } = createDevServerMiddleware(projectRoot, {\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-ignore can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n const server = await Metro.runServer(metroConfig, {\n hmrEnabled: true,\n websocketEndpoints,\n });\n\n if (attachToServer) {\n // Expo SDK 44 and lower\n const { messageSocket, eventsSocket } = attachToServer(server);\n reportEvent = eventsSocket.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket,\n };\n } else {\n // RN +68 -- Expo SDK +45\n reportEvent = eventsSocketEndpoint.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n }\n}\n"],"names":["instantiateMetroAsync","projectRoot","options","reportEvent","Metro","importMetroFromProject","ExpoMetroConfig","importExpoMetroConfigFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","metroConfig","loadAsync","exp","getConfig","skipSDKVersionRequirement","skipPlugins","platformBundlers","getPlatformBundlers","withMetroMultiPlatform","middleware","attachToServer","websocketEndpoints","eventsSocketEndpoint","messageSocketEndpoint","createDevServerMiddleware","port","server","watchFolders","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","use","runServer","hmrEnabled","messageSocket","eventsSocket"],"mappings":"AAAA;;;;QAkBsBA,qBAAqB,GAArBA,qBAAqB;AAlBjB,IAAA,OAAc,WAAd,cAAc,CAAA;AAIf,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEK,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC/C,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AACU,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACxD,IAA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"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.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 fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { PlatformBundlers } from '../platformBundlers';\nimport { importMetroResolverFromProject } from './resolveFromProject';\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform?: string }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n return originalGetPolyfills(ctx);\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction getDefaultResolveRequest(projectRoot: string) {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<import('metro-resolver').CustomResolver>\n) => import('metro-resolver').Resolution | null;\n\n/** Extend the `resolver.resolveRequest` method with custom methods that can exit early by returning a `Resolution`. */\nfunction withCustomResolvers(\n config: ConfigT,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): ConfigT {\n const originalResolveRequest =\n config.resolver.resolveRequest || getDefaultResolveRequest(projectRoot);\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(...args: Parameters<import('metro-resolver').CustomResolver>) {\n for (const resolver of resolvers) {\n const resolution = resolver(...args);\n if (resolution) {\n return resolution;\n }\n }\n return originalResolveRequest(...args);\n },\n },\n };\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n */\nexport function withWebResolvers(config: ConfigT, projectRoot: string) {\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n\n // Create a resolver which dynamically disables support for\n // `*.native.*` extensions on web.\n\n const { resolve } = importMetroResolverFromProject(projectRoot);\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n },\n };\n\n return withCustomResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n const context = { ...immutableContext };\n\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = extraNodeModules[platform];\n }\n\n const result = resolve(\n {\n ...context,\n preferNativePlatform: platform !== 'web',\n resolveRequest: undefined,\n },\n moduleName,\n platform\n );\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n result.filePath.endsWith('react-native-web/dist/modules/AssetRegistry/index.js')\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n return result;\n },\n ]);\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport function withMetroMultiPlatform(\n projectRoot: string,\n config: ConfigT,\n platformBundlers: PlatformBundlers\n) {\n // Bail out early for performance enhancements if web is not enabled.\n if (platformBundlers.web !== 'metro') {\n return config;\n }\n\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withWebResolvers(config, projectRoot);\n}\n"],"names":["withWebResolvers","withMetroMultiPlatform","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","getDefaultResolveRequest","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","withCustomResolvers","resolvers","originalResolveRequest","resolver","resolveRequest","args","resolution","assetRegistryPath","fs","realpathSync","path","resolveFrom","extraNodeModules","web","require","immutableContext","result","preferNativePlatform","undefined","type","filePath","endsWith","platformBundlers","expoConfigPlatforms","Object","entries","filter","bundler","map","Array","isArray","platforms","Set","concat"],"mappings":"AAMA;;;;QA4EgBA,gBAAgB,GAAhBA,gBAAgB;QAyDhBC,sBAAsB,GAAtBA,sBAAsB;AArIvB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAGS,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;AAErE,SAASC,gBAAgB,CAACC,MAAe,EAAW;IAClD,MAAMC,oBAAoB,GAAGD,MAAM,CAACE,UAAU,CAACC,YAAY,GACvDH,MAAM,CAACE,UAAU,CAACC,YAAY,CAACC,IAAI,CAACJ,MAAM,CAACE,UAAU,CAAC,GACtD,IAAM,EAAE;IAAC;IAEb,MAAMC,YAAY,GAAG,CAACE,GAA0B,GAAwB;QACtE,IAAIA,GAAG,CAACC,QAAQ,KAAK,KAAK,EAAE;YAC1B,OAAO,EAEN,CAAC;SACH;QACD,oCAAoC;QACpC,OAAOL,oBAAoB,CAACI,GAAG,CAAC,CAAC;KAClC,AAAC;IAEF,OAAO;QACL,GAAGL,MAAM;QACTE,UAAU,EAAE;YACV,GAAGF,MAAM,CAACE,UAAU;YACpBC,YAAY;SACb;KACF,CAAC;CACH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mB,EACnBR,MAAe,EACfmC,gBAAkC,EAClC;IACA,qEAAqE;IACrE,IAAIA,gBAAgB,CAACT,GAAG,KAAK,OAAO,EAAE;QACpC,OAAO1B,MAAM,CAAC;KACf;IAED,IAAIoC,mBAAmB,GAAGC,MAAM,CAACC,OAAO,CAACH,gBAAgB,CAAC,CACvDI,MAAM,CAAC,CAAC,GAAGC,OAAO,CAAC,GAAKA,OAAO,KAAK,OAAO;IAAA,CAAC,CAC5CC,GAAG,CAAC,CAAC,CAACnC,QAAQ,CAAC,GAAKA,QAAQ;IAAA,CAAC,AAAC;IAEjC,IAAIoC,KAAK,CAACC,OAAO,CAAC3C,MAAM,CAACgB,QAAQ,CAAC4B,SAAS,CAAC,EAAE;QAC5CR,mBAAmB,GAAG;eAAI,IAAIS,GAAG,CAACT,mBAAmB,CAACU,MAAM,CAAC9C,MAAM,CAACgB,QAAQ,CAAC4B,SAAS,CAAC,CAAC;SAAC,CAAC;KAC3F;IAED,yCAAyC;IACzC5C,MAAM,CAACgB,QAAQ,CAAC4B,SAAS,GAAGR,mBAAmB,CAAC;IAEhDpC,MAAM,GAAGD,gBAAgB,CAACC,MAAM,CAAC,CAAC;IAElC,OAAOH,gBAAgB,CAACG,MAAM,EAAEQ,WAAW,CAAC,CAAC;CAC9C"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.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 fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { PlatformBundlers } from '../platformBundlers';\nimport { importMetroResolverFromProject } from './resolveFromProject';\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null | undefined }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n return originalGetPolyfills(ctx);\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction getDefaultResolveRequest(projectRoot: string) {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<import('metro-resolver').CustomResolver>\n) => import('metro-resolver').Resolution | null;\n\n/** Extend the `resolver.resolveRequest` method with custom methods that can exit early by returning a `Resolution`. */\nfunction withCustomResolvers(\n config: ConfigT,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): ConfigT {\n const originalResolveRequest =\n config.resolver.resolveRequest || getDefaultResolveRequest(projectRoot);\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(...args: Parameters<import('metro-resolver').CustomResolver>) {\n for (const resolver of resolvers) {\n const resolution = resolver(...args);\n if (resolution) {\n return resolution;\n }\n }\n return originalResolveRequest(...args);\n },\n },\n };\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n */\nexport function withWebResolvers(config: ConfigT, projectRoot: string) {\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n\n // Create a resolver which dynamically disables support for\n // `*.native.*` extensions on web.\n\n const { resolve } = importMetroResolverFromProject(projectRoot);\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n },\n };\n\n return withCustomResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n const context = { ...immutableContext };\n\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = extraNodeModules[platform];\n }\n\n const result = resolve(\n {\n ...context,\n preferNativePlatform: platform !== 'web',\n resolveRequest: undefined,\n },\n moduleName,\n platform\n );\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n result.filePath.endsWith('react-native-web/dist/modules/AssetRegistry/index.js')\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n return result;\n },\n ]);\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport function withMetroMultiPlatform(\n projectRoot: string,\n config: ConfigT,\n platformBundlers: PlatformBundlers\n) {\n // Bail out early for performance enhancements if web is not enabled.\n if (platformBundlers.web !== 'metro') {\n return config;\n }\n\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withWebResolvers(config, projectRoot);\n}\n"],"names":["withWebResolvers","withMetroMultiPlatform","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","getDefaultResolveRequest","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","withCustomResolvers","resolvers","originalResolveRequest","resolver","resolveRequest","args","resolution","assetRegistryPath","fs","realpathSync","path","resolveFrom","extraNodeModules","web","require","immutableContext","result","preferNativePlatform","undefined","type","filePath","endsWith","platformBundlers","expoConfigPlatforms","Object","entries","filter","bundler","map","Array","isArray","platforms","Set","concat"],"mappings":"AAMA;;;;QA4EgBA,gBAAgB,GAAhBA,gBAAgB;QAyDhBC,sBAAsB,GAAtBA,sBAAsB;AArIvB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAGS,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;AAErE,SAASC,gBAAgB,CAACC,MAAe,EAAW;IAClD,MAAMC,oBAAoB,GAAGD,MAAM,CAACE,UAAU,CAACC,YAAY,GACvDH,MAAM,CAACE,UAAU,CAACC,YAAY,CAACC,IAAI,CAACJ,MAAM,CAACE,UAAU,CAAC,GACtD,IAAM,EAAE;IAAC;IAEb,MAAMC,YAAY,GAAG,CAACE,GAA4C,GAAwB;QACxF,IAAIA,GAAG,CAACC,QAAQ,KAAK,KAAK,EAAE;YAC1B,OAAO,EAEN,CAAC;SACH;QACD,oCAAoC;QACpC,OAAOL,oBAAoB,CAACI,GAAG,CAAC,CAAC;KAClC,AAAC;IAEF,OAAO;QACL,GAAGL,MAAM;QACTE,UAAU,EAAE;YACV,GAAGF,MAAM,CAACE,UAAU;YACpBC,YAAY;SACb;KACF,CAAC;CACH;AAED,SAASI,wBAAwB,CAACC,WAAmB,EAAE;IACrD,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGC,CAAAA,GAAAA,mBAA8B,AAAa,CAAA,+BAAb,CAACF,WAAW,CAAC,AAAC;IAChE,OAAO,CAACG,OAA0B,EAAEC,UAAkB,EAAEN,QAAuB,GAAK;QAClF,OAAOG,OAAO,CAACE,OAAO,EAAEC,UAAU,EAAEN,QAAQ,CAAC,CAAC;KAC/C,CAAC;CACH;AAMD,uHAAuH,CACvH,SAASO,mBAAmB,CAC1Bb,MAAe,EACfQ,WAAmB,EACnBM,SAAoC,EAC3B;IACT,MAAMC,sBAAsB,GAC1Bf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gB,QAAQ,CAAC4B,SAAS,CAAC,EAAE;QAC5CR,mBAAmB,GAAG;eAAI,IAAIS,GAAG,CAACT,mBAAmB,CAACU,MAAM,CAAC9C,MAAM,CAACgB,QAAQ,CAAC4B,SAAS,CAAC,CAAC;SAAC,CAAC;KAC3F;IAED,yCAAyC;IACzC5C,MAAM,CAACgB,QAAQ,CAAC4B,SAAS,GAAGR,mBAAmB,CAAC;IAEhDpC,MAAM,GAAGD,gBAAgB,CAACC,MAAM,CAAC,CAAC;IAElC,OAAOH,gBAAgB,CAACG,MAAM,EAAEQ,WAAW,CAAC,CAAC;CAC9C"}
@@ -128,7 +128,7 @@ async function createHostInfoAsync() {
128
128
  host: await _userSettings.default.getAnonymousIdentifierAsync(),
129
129
  server: "expo",
130
130
  // Defined in the build step
131
- serverVersion: "0.2.1",
131
+ serverVersion: "0.2.2",
132
132
  serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
133
133
  serverOS: _os.default.platform(),
134
134
  serverOSVersion: _os.default.release()
@@ -80,7 +80,7 @@ function logEvent(event, properties = {}) {
80
80
  ensureIdentified();
81
81
  const { userId , deviceId } = identifyData != null ? identifyData : {};
82
82
  const commonEventProperties = {
83
- source_version: "0.2.1",
83
+ source_version: "0.2.2",
84
84
  source: "expo"
85
85
  };
86
86
  const identity = {
@@ -121,7 +121,7 @@ function getContext() {
121
121
  },
122
122
  app: {
123
123
  name: "expo",
124
- version: "0.2.1"
124
+ version: "0.2.2"
125
125
  },
126
126
  ci: ciInfo.isCI ? {
127
127
  name: ciInfo.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -43,7 +43,7 @@
43
43
  "@expo/dev-server": "~0.1.110",
44
44
  "@expo/devcert": "^1.0.0",
45
45
  "@expo/json-file": "^8.2.35",
46
- "@expo/metro-config": "~0.3.16",
46
+ "@expo/metro-config": "~0.3.18",
47
47
  "@expo/osascript": "^2.0.31",
48
48
  "@expo/package-manager": "~0.0.53",
49
49
  "@expo/plist": "^0.0.18",
@@ -137,5 +137,5 @@
137
137
  "structured-headers": "^0.4.1",
138
138
  "taskr": "1.1.0"
139
139
  },
140
- "gitHead": "8151bf48e683a50e942ef213f7978b35c41f5e11"
140
+ "gitHead": "5d900179d047d9f4d89c0b9953b7121a1f1df8a2"
141
141
  }