History log of /expo/packages/@expo/cli/src/start/server/metro/instantiateMetro.ts (Results 1 – 23 of 23)
Revision Date Author Comments
# 1c8e3ea0 25-Sep-2023 Mark Lawlor <[email protected]>

feat(cli): Enable tsconfigPaths by default (#24490)

# Why

ENG-9888

# How

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

<!--
Please describe how you t

feat(cli): Enable tsconfigPaths by default (#24490)

# Why

ENG-9888

# How

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: Aman Mittal <[email protected]>

show more ...


# 46f023fa 15-Sep-2023 Evan Bacon <[email protected]>

[RFC] API Routes in Expo Router (#24429)

# Why

Servers are an important part of developing many different types of
apps, but they're much harder to configure than they need to be.

API Routes

[RFC] API Routes in Expo Router (#24429)

# Why

Servers are an important part of developing many different types of
apps, but they're much harder to configure than they need to be.

API Routes will enable users to express some abstract JavaScript code
that runs in a server by simply creating a file in the app directory,
and adding the `+api.js` suffix. For example, to securely interact with
OpenAI, simply:

```ts
// app/generate+api.ts
import { ExpoRequest, ExpoResponse } from 'expo-router/server';

export async function POST(req: ExpoRequest): Promise<ExpoResponse> {
const { prompt } = await req.json();

const json = await fetch('https://api.openai.com/v1/engines/text-davinci-003/completions', {
headers: {
'Content-Type': 'application/json',
// `OPENAI_API_KEY` is pulled from the .env file when running in Expo CLI.
Authorization: `Bearer ${process.env.OPENAI_API_KEY ?? ''}`,
},
method: 'POST',
body: JSON.stringify({
prompt,
max_tokens: 100,
}),
}).then(res => res.json());

// Return as JSON
return ExpoResponse.json(json);
}
```

This will be served at `http://localhost:8081/generate` with `npx expo`
and can be used by making a request:

```sh
$ curl -X POST -H "Content-Type: application/json" -d \'{"prompt":"Hello, my name is"}\' http://localhost:8081/generate
```

Expo Router polyfills the URL and `window.location` object on native to
allow for universally requesting with a relative URL:

```js
// Expo prepends the host and port to the URL automatically in development.
const json = await fetch('/generate').then(res => res.json());
```

# How

- API Routes are bundled with Metro, leveraging all the same
functionality as the rest of the app and website.
- The project babel config is used to transpile the API routes.
Indication is passed to the Babel caller via the `isServer` boolean.
This can be used to change the preset based on the environment.
- Each API route is bundled into a standalone file in the `dist/_expo`
directory. This is akin to ncc, the tool we use to make Create Expo App
download in ~1 second.
- Create a new package `@expo/server` which includes the requisite
middleware and runtime polyfills for the Expo server environment.
- Add a new routes manifest which will be used by `@expo/server` to
serve up the three types of routes: HTML routes, API routes, and not
found routes (404s).
- Add a new export `expo-router/server` (potentially will be moved to
`expo/server`) which contains the `ExpoRequest` and `ExpoResponse`
objects. These are all based on the WinterCG specification, and include
some additional properties for interop with the Expo Router filesystem
convention. These are inspired by Remix, SvelteKit, and Next.js for
simplicity.
- Add a new export mode `web.output: "server"` which can be used to
export a dynamic server. Note: I may drop this for now and make server
the default since there's no expo-specific hosting code that must be
exported.
- This PR adds the ability to host the app with an express server,
different production adapters to follow.

# Test Plan

In addition to all the E2E Metro tests, I've added a new E2E runner
which starts a server and pings different requests to ensure expected
behavior. These run in the CLI as opposed to the `@expo/server` package.

- resolve ENG-10057 ENG-8243 ENG-8082 ENG-8079 ENG-8242 ENG-8081
ENG-8080 ENG-9625

---------

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: Cedric van Putten <[email protected]>

show more ...


# 7c98c357 14-Sep-2023 Evan Bacon <[email protected]>

feat(cli, router, metro, asset): add basePath support (#23911)

# Why

- Add the ability to export websites for hosting from a custom path.
This is required for GitHub pages.
- Resolve ENG-9193

feat(cli, router, metro, asset): add basePath support (#23911)

# Why

- Add the ability to export websites for hosting from a custom path.
This is required for GitHub pages.
- Resolve ENG-9193
- Resolve https://github.com/expo/expo/issues/20562
- Resolve https://github.com/expo/router/issues/165

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

- Add `expo.experiments.basePath` which can be used during `npx expo
export` to modify how assets are referenced.
- Set the `publicPath` in Metro to output as expected.
- Add custom asset writing for web to support stripping the unused
prefix.

- It's unclear if this should also apply to native, and if we should
have platform-specific variations.
- Update Expo Router to support automatically adjusting paths to support
basePath in production builds.
<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- [ ] New `expo export` test.

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: Aman Mittal <[email protected]>

show more ...


# edeec536 06-Sep-2023 Evan Bacon <[email protected]>

chore(cli): delete @expo/dev-server (#24272)

# Why

- I tried this before but the logs endpoint was blocking it.
- I forked the dev server when I wrote the original `expo/cli`, been
meaning to d

chore(cli): delete @expo/dev-server (#24272)

# Why

- I tried this before but the logs endpoint was blocking it.
- I forked the dev server when I wrote the original `expo/cli`, been
meaning to delete the original for a while. The duplicate code and
indirection is making the new server features harder to implement.

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

- Copy/paste remaining code from `@expo/dev-server` in to `@expo/cli`.
- Delete `@expo/dev-server`.
- Drop unused `/logs` and json parser middleware.
- Drop logging mocks.
- Drop experimental Webpack native support.
- Drop legacy react-native middleware support (no longer needed since
everything is versioned).

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- Tests should keep passing.
- Need to do some actual runs since there aren't any e2e tests for
various parts of dev-server.

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 429dc7fc 26-Aug-2023 Evan Bacon <[email protected]>

fix(expo, asset, cli)!: unify asset hashing (#24090)

# Why

Convert the `../` segments of the server URL to `_` to support
monorepos. This same transformation takes place in
`AssetSourceResolver

fix(expo, asset, cli)!: unify asset hashing (#24090)

# Why

Convert the `../` segments of the server URL to `_` to support
monorepos. This same transformation takes place in
`AssetSourceResolver.web` (expo-assets, expo-image) and
`persistMetroAssets` of Expo CLI, this originally came from the [Metro
opinion](https://github.com/react-native-community/cli/blob/2204d357379e2067cebe2791e90388f7e97fc5f5/packages/cli-plugin-metro/src/commands/bundle/getAssetDestPathIOS.ts#L19C5-L19C10).

The purpose is to ensure no URL like `/foo/../bar.png` is requested, as
the result would be `/bar.png` which wouldn't work. The of how to handle
this didn't come from us, but we do need to ensure it's unified. At a
high-level, this does prevent the usage of certain files, as
`/foo/../bar.png` will be `/foo/_bar.png`, meaning a file named
`/foo/_bar.png` cannot also exist. This logic, while applied at runtime,
is actually only valid for production exports as we don't move or alias
files in development. The only way to have valid development files is to
ensure `../` never appears in the URL, i.e. by using
`unstable_serverRoot`.

- Drop legacy `expo/tools/hashAssetFiles.js` in favor of `expo-asset`
version.
- Unify runtime logic of asset file loading for monorepos.
- Split out of https://github.com/expo/expo/pull/23911

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

show more ...


# 8a424beb 11-Aug-2023 James Ide <[email protected]>

[lint] Upgrade to Prettier v3, typescript-eslint to v6 (#23544)

Why
---
Prettier 3 is out. Add support for it with this linter config.

**Note for reviewer:** the first commit is the one with th

[lint] Upgrade to Prettier v3, typescript-eslint to v6 (#23544)

Why
---
Prettier 3 is out. Add support for it with this linter config.

**Note for reviewer:** the first commit is the one with the actual
changes. The rest of this PR are changes to get the linter passing
(mostly autofix).

How
---
Update eslint-config-prettier and eslint-plugin-prettier. To address
deprecation warnings, also update typescript-eslint/parser and
typescript-eslint/eslint-plugin.
Because of an update to typescript-eslint/parser, we need to suppress
deprecation warnings (documented in a comment).

Regenerated test snapshots. Due to the upgraded dependencies, typecasts
and optional chaining are now auto-fixable by lint. This converts
warnings into autofixes.

Test Plan
---
`yarn test` in the linter config. Run `expotools check --all --fix-lint
--no-build --no-test --no-uniformity-check` to try this config on the
whole repo.

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# da5824c9 12-Jun-2023 Kudo Chien <[email protected]>

[cli] fix typecheck from react-native 0.72 upgrade (#22766)

# Why

follow up #22588 which disabled the cli typecheck

# How

using types from metro and fix typing issues

# Test Plan

cli

[cli] fix typecheck from react-native 0.72 upgrade (#22766)

# Why

follow up #22588 which disabled the cli typecheck

# How

using types from metro and fix typing issues

# Test Plan

cli ci passed

show more ...


# 8010f0ca 10-Jun-2023 Evan Bacon <[email protected]>

feat(cli,router): support src/app directory in Expo Router (#22748)

# Why

- related https://github.com/expo/router/pull/629

<!--
Please describe the motivation for this PR, and link to releva

feat(cli,router): support src/app directory in Expo Router (#22748)

# Why

- related https://github.com/expo/router/pull/629

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 9580591f 30-Apr-2023 Evan Bacon <[email protected]>

feat(metro-config, cli): CSS serializer (#22325)

# Why

In order to support static CSS in development mode, we need to update
the metro serializer to support returning the JS and CSS assets. We n

feat(metro-config, cli): CSS serializer (#22325)

# Why

In order to support static CSS in development mode, we need to update
the metro serializer to support returning the JS and CSS assets. We now
inline the CSS in the HTML before sending to the client, this allows for
testing how the website works with JS disabled. We use the same style
tag id to continue to support HMR for styles during subsequent updates.

This change also refactors how exports work to serialize JS and CSS at
the same time (i.e. after the native transformations).

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# f479be69 30-Mar-2023 Evan Bacon <[email protected]>

chore(cli): switch `EXPO_USE_PATH_ALIASES` to `expo.experiments.tsconfigPaths`. (#21897)

# Why

- It's a bit harder to set env vars and users will want this either
always on or always off.
- Exp

chore(cli): switch `EXPO_USE_PATH_ALIASES` to `expo.experiments.tsconfigPaths`. (#21897)

# Why

- It's a bit harder to set env vars and users will want this either
always on or always off.
- Expo Config makes it easier to deprecate values on a per-version
basis. https://github.com/expo/universe/pull/11872
- Comment out references to the path aliases feature until we're closer
to launch. Users are getting confused when they see the feature
documented.

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 036e9444 28-Mar-2023 Evan Bacon <[email protected]>

feat(metro-config): support any entry file in development builds that don't use Expo dev client (#21643)

# Why

- React Native enforces that apps must use `index.js` as the entry file,
this is hi

feat(metro-config): support any entry file in development builds that don't use Expo dev client (#21643)

# Why

- React Native enforces that apps must use `index.js` as the entry file,
this is highly inconvenient and forces us to change the app entry on
`expo prebuild` (cite: [prebuild side
effects](https://github.com/expo/expo/blob/4d2795e/docs/pages/workflow/prebuild.mdx#side-effects)
(`index.js` and `package.json` `scripts`)).
- In #14964 I added support for production Android apps to use any entry
point.
- In #18381 I added the same support to iOS apps in production.
- Development builds using `expo-dev-client` and Expo Go both use a
manifest which support arbitrary entry points.
- This just leaves development builds that don't have Expo code-loading
support (e.g. no manifest/index.html where the script can be changed
dynamically).

# How

- This PR introduces the virtual entry file `.expo/.virtual-metro-entry`
which should never physically exist. When this endpoint is pinged, Expo
CLI will rewrite the the URL to the correct entry point based on the
project configuration. This enables us to fully drop the prebuild
side-effect as no case will require an `index.js` (`index.bundle`) as
the entry file.
- The rewrite means Metro will never support a physical file located at
`.expo/.virtual-metro-entry.js` as this will always be ignored. We could
support forwarding the request if this file exists but we'll probably go
the other way and assert if this file exists to mitigate possible
confusion.
- The name `.expo/.virtual-metro-entry.js` was chosen to be clear and
long enough that users wouldn't try to actually create this file.
- I originally tried using a middleware to perform the redirect but this
wouldn't work with the HMR server which emulates pinging the endpoint
in-memory. Because of this, I went with the metro
`server.rewriteRequestUrl` function.

> This feature is implemented in Expo's Metro configuration, meaning it
should apply to `npx react-native start` (but this is untested and not
officially supported).

## New Setup Instructions for non-prebuild users

Non-prebuild projects will need to modify their `AppDelegate.mm` as
follows:

```diff
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
- return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
```

And their `android/app/src/main/java/***/MainApplication.java`:

```diff
@Override
protected String getJSMainModuleName() {
- return "index";
+ return ".expo/.virtual-metro-entry";
}
```

This is of course in addition to the `android/app/build.gradle`:

```groovy
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
```

And iOS production change:

```
shellScript = "if [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" $PROJECT_ROOT ios relative | tail -n 1)\"\nfi\n\n`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"`\n\n";
```

# Test Plan

### Continuous(-ish)

- Updated the templates to use this new format.

### Quick test

- Start the dev server and ping the entry URL directly:
-
`http://localhost:8081/.expo/.virtual-metro-entry.bundle?platform=web&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true`
- The redirected URL should show in the `sourceURL` at the end of the
file.

### E2E

- Prebuild, then apply the native changes in a local projects
- Use the following `metro.config.js` (you don't need to use the latest
Expo CLI for this to work):

```js
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require("../../expo/packages/@expo/metro-config");
// const { getDefaultConfig } = require('expo/metro-config');

module.exports = getDefaultConfig(__dirname);
```
- `npx expo run:ios` and `npx expo run:android` should point to
`index.bundle`
- Changing the `main` field in the package.json or deleting `index.js`
should continue to work when you reload the app.


# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 03d43e7d 28-Mar-2023 Cedric van Putten <[email protected]>

feature(cli): add basic `Page.reload` support to reload the app from inspector (#21827)

# Why

This implements the `Page.reload` CDP event, to reload the app itself.

> Would be nice if there is

feature(cli): add basic `Page.reload` support to reload the app from inspector (#21827)

# Why

This implements the `Page.reload` CDP event, to reload the app itself.

> Would be nice if there is a way to send this to _JUST_ the device you
are inspecting. But not sure what socket connection that would be, don't
think it's the actual device socket in the inspector (that's inspector
messages only).

# How

- Provided the reference of `MetroBundlerDevServer` to the inspector
- Called `MetroBundlerDevServer.broadcastMessage('reload')`

# Test Plan

- Open chrome inspector (`j`)
- Anywhere in the inspector, press `cmd+r`

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 0a6ddb20 13-Mar-2023 Evan Bacon <[email protected]>

feat(cli): add basic static rendering for router projects (#21572)

# Why

- Implement an experimental static rendering system for Metro websites
using Expo Router.
- Behavior is undocumented and

feat(cli): add basic static rendering for router projects (#21572)

# Why

- Implement an experimental static rendering system for Metro websites
using Expo Router.
- Behavior is undocumented and highly experimental.

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

- Add support to `start` and `export` which pre-renders static web pages
to HTML to improve SEO support on web.
- The system implements [React Navigation's
SSR](https://reactnavigation.org/docs/server-rendering) support.
- Head elements can be used with `import { Head } from
'expo-router/head'`.
- The root HTML is not exposed to the user.
- There are no data fetching mechanisms.
- There's no ability to provide a 404 page or other server features.


<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- e2e test for exporting a router project statically.
- `EXPO_USE_STATIC=1 yarn expo` -> websites are pre-rendered before
being served.
- `EXPO_USE_STATIC=1 yarn expo export -p web` -> static routes are
rendered to static HTML files by the same name (dynamic routes are not
supported).


<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# b6b91c50 06-Mar-2023 Evan Bacon <[email protected]>

feat(cli)!: use Expo CLI to bundle production apps (#21396)

# Why

Most of our new Metro bundler features won't work unless we use Expo CLI
for every bundler operation (ex:
[aliases](https://git

feat(cli)!: use Expo CLI to bundle production apps (#21396)

# Why

Most of our new Metro bundler features won't work unless we use Expo CLI
for every bundler operation (ex:
[aliases](https://github.com/expo/expo/pull/21262)). Right now this is
the case when building for production on both platforms or building for
development on iOS.

> Using `npx expo start` when building from Xcode will be added in
another PR.

# How

This PR introduces a new "export:embed" command which is hidden from the
`--help` prompt. `npx expo export:embed` accepts the same arguments as
`npx react-native bundle` and passes them to the same internal function,
but it ensures we use the correct variation of Metro before doing such.

This change (and `start` PR) will add more steps for migrating to "Expo
CLI" but it will also remove the need for us to generate the
`metro.config.js` file in the project on `npx expo prebuild` since we
can now reliably default to `@expo/metro-config`.

The change should only apply to Metro bundler features (all application
code could be affected), but it won't obstruct Expo Modules Core or
using Expo CLI.

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- All of our existing E2E tests should use the new command, if they
contain features like aliases then they'll work.
- Copied the changes from `@expo/cli` into a new project's node_modules,
added template changes:
- Built for production from Android Studio and Xcode.

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: James Ide <[email protected]>

show more ...


# 33643b60 04-Mar-2023 Evan Bacon <[email protected]>

feat(cli): auto setup typescript during start (#21475)

# Why

- Some users are confused about how to use the fully automated
TypeScript setup. It currently runs when you run `npx expo start` in a

feat(cli): auto setup typescript during start (#21475)

# Why

- Some users are confused about how to use the fully automated
TypeScript setup. It currently runs when you run `npx expo start` in a
project with `tsconfig.json` or any TypeScript file in the project.
- This change will run the TypeScript check continuously until
TypeScript is setup. This only applies to projects using Metro, and
currently is only run in `npx expo start`, and the run commands (when
the server is started in the current window, e.g. not headless mode).

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

- Fork the `runServer` function from Metro into the CLI so we can access
the Metro bundler instance directly.
- Use Metro's native file watching to observe new TypeScript files being
added to the project (within the observable files). This is fast and
ensures we don't accidentally block a thread that otherwise could've
been used for bundling.
- The TypeScript continuous check only runs once, if you remove
TypeScript and add it back in the same process, then nothing happens.
This is a performance optimization.
- If TypeScript is enabled while the process is running, the user will
not be prompted to install, the packages will just install in the
project. Failures will be displayed in the running process, and no more
attempts will be made.
- If TypeScript is detected on start then the existing system will be
used and the continuous check will be skipped, this means projects
already using TypeScript won't have any technical performance hit.


<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- In a project without TypeScript:
- `npx expo`
- `touch tsconfig.json` or `mv index.js index.tsx` or `touch foo.tsx`
- TypeScript is automatically installed for the project.
- `EXPO_NO_TYPESCRIPT_SETUP` voids this behavior
- Added unit tests.

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: Cedric van Putten <[email protected]>

show more ...


# d42dd5d4 09-Feb-2023 Cedric van Putten <[email protected]>

feature(cli): add experimental metro config telemetry (#20885)

# Why

We need to have visibility on what experimental features are being used,
in order to prioritize supporting or finishing these

feature(cli): add experimental metro config telemetry (#20885)

# Why

We need to have visibility on what experimental features are being used,
in order to prioritize supporting or finishing these features.

# How

Added a telemetry event when instantiating Metro, for both `npx expo
start` and `npx expo export`.

# Test Plan

See added test, if a property isn't available, it doesn't matter.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 0f61c876 25-Jan-2023 Cedric van Putten <[email protected]>

fix(cli): simplify Metro watch mode and communicate when disabled (#20939)

# Why

Fixes ENG-7089

# How

Because this option is only exposed through `Metro.runServer`, I added
the override in

fix(cli): simplify Metro watch mode and communicate when disabled (#20939)

# Why

Fixes ENG-7089

# How

Because this option is only exposed through `Metro.runServer`, I added
the override in `@expo/cli`. Alternative, we could add a custom Metro
config option to move this to the config itself, however, that would
create a significant diversion of the normal Metro config.

> **Note**
> We could add a Metro version check and disable the warning, but I
think it's safe to skip that and leave it in for older Metro versions.
It's not really synced, but if the message pops up, it's very very
likely Metro actually is running without watch.

# Test Plan

See added tests.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

show more ...


# ca84f1cd 14-Oct-2022 Evan Bacon <[email protected]>

feat(cli): Make Expo Metro config for web resolve projects using same `package.json` main fields as Expo Webpack (#19529)

* fix: ensure web is setup every time

* fix(cli): use correct main fields

feat(cli): Make Expo Metro config for web resolve projects using same `package.json` main fields as Expo Webpack (#19529)

* fix: ensure web is setup every time

* fix(cli): use correct main fields for Metro web

* Update packages/@expo/cli/CHANGELOG.md

Co-authored-by: Expo Bot <[email protected]>

* Update docs/pages/workflow/expo-cli.mdx

Co-authored-by: Aman Mittal <[email protected]>

* Update docs/pages/workflow/expo-cli.mdx

Co-authored-by: Aman Mittal <[email protected]>

Co-authored-by: Expo Bot <[email protected]>
Co-authored-by: Aman Mittal <[email protected]>

show more ...


# e87e8ea8 26-Sep-2022 Evan Bacon <[email protected]>

feat(cli): add touch middleware and app entry (#19231)

* add middleware for creating files

* fix touch request

* added support for auto entry

* added tests for touch middleware

* added r

feat(cli): add touch middleware and app entry (#19231)

* add middleware for creating files

* fix touch request

* added support for auto entry

* added tests for touch middleware

* added router tests

* Update CHANGELOG.md

* Update packages/@expo/cli/CHANGELOG.md

Co-authored-by: Expo Bot <[email protected]>

* Update instantiateMetro.ts

Co-authored-by: Expo Bot <[email protected]>

show more ...


# aef260d6 15-Jul-2022 Evan Bacon <[email protected]>

chore: migrate metro-config, dev-server (#18221)

* chore: migrate metro CLI packages

* fix deps

* fix types

* Update withMetroMultiPlatform.ts

* Update yarn.lock


# 6d6b81f9 23-Jun-2022 Evan Bacon <[email protected]>

feat(cli): add web support to metro (#17927)

* feat: add web support for metro

* undo patch

* Update index.js

* Update MetroBundlerDevServer.ts

* Add second bundler dev server

* Add d

feat(cli): add web support to metro (#17927)

* feat: add web support for metro

* undo patch

* Update index.js

* Update MetroBundlerDevServer.ts

* Add second bundler dev server

* Add dev loading view to web

* Put feature behind EXPO_USE_METRO_WEB flag

* Move custom config into CLI

* Add support for assets across platforms

* reduce

* Added upstream web support

* Update webTemplate.ts

* Update CHANGELOG.md

* Update instantiateMetro.ts

* Update instantiateMetro.ts

* Update index.js

* Added bundle splitting support

* Update startAsync.ts

* Fixed default settings

* Add ability to copy from public folder

* wip: redirect unmatched routes to `/` on web

* fix fallback api

* Update exportApp.ts

* Update instantiateMetro.ts

* Update exportApp.ts

* clean up handler

* fixup

* clean up

* add web to export test

* Update start-test.ts

* added static serving for web

* Update packages/@expo/cli/CHANGELOG.md

Co-authored-by: Expo Bot <[email protected]>

* Update yarn.lock

lint fix

fix tests

* Update export-test.ts

* added template tests

* Create HistoryFallbackMiddleware-test.ts

* test ManifestMiddleware

* Create ServeStaticMiddleware-test.ts

* refactor multiplatform

* Update ManifestMiddleware-test.ts

* Update withMetroMultiPlatform.ts

* Update for latest metro

* Update packages/@expo/cli/src/export/resolveOptions.ts

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 8a782c0f 27-Apr-2022 Evan Bacon <[email protected]>

feat(cli): use new dev server API (#17189)

* chore(cli): use new dev server API

* Update CHANGELOG.md

* Update packages/@expo/cli/CHANGELOG.md

Co-authored-by: Expo Bot <34669131+expo-bot@us

feat(cli): use new dev server API (#17189)

* chore(cli): use new dev server API

* Update CHANGELOG.md

* Update packages/@expo/cli/CHANGELOG.md

Co-authored-by: Expo Bot <[email protected]>

* Fix downloading the beta client

* Update downloadExpoGoAsync.ts

* Update downloadExpoGoAsync-test.ts

* bump packages

* forward correct exit code

* Update CHANGELOG.md

Co-authored-by: Expo Bot <[email protected]>

show more ...


# 8d307f52 23-Mar-2022 Evan Bacon <[email protected]>

chore: refactor `expo/cli` to `@expo/cli` package (#16717)

* chore: refactor `expo/cli` to `@expo/cli` package

* Update CODEOWNERS

* fix linking

* fix lint script

* fix build file

* f

chore: refactor `expo/cli` to `@expo/cli` package (#16717)

* chore: refactor `expo/cli` to `@expo/cli` package

* Update CODEOWNERS

* fix linking

* fix lint script

* fix build file

* fix e2e tests

* lint before build

* use mock version

show more ...