History log of /expo/packages/@expo/cli/src/start/server/middleware/ManifestMiddleware.ts (Results 1 – 19 of 19)
Revision Date Author Comments
# 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 ...


# 573b0ea7 01-Sep-2023 Evan Bacon <[email protected]>

feat(metro, cli, router): production static web source maps support (#24213)

# Why

- Add support for exporting (or skipping) optimally formatted source
maps on web with static rendering enabled.

feat(metro, cli, router): production static web source maps support (#24213)

# Why

- Add support for exporting (or skipping) optimally formatted source
maps on web with static rendering enabled.
- Improved version of https://github.com/expo/expo/pull/22334

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

# How

- Pass a new setting to the custom serializer when exporting for usage
outside of the dev server. This setting will ensure a source map is
created with paths relative to the server root.
- The resources will be adjusted after exporting to reflect the hashed
js filename location.
- When no sourcemap exporting is enabled, the references will be
stripped to prevent getting a chrome warning.


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

# Test Plan

- I added an e2e bundling test for both exporting with and without
sourcemaps.

<!--
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 ...


# 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 ...


# d4de237f 01-Aug-2023 Evan Bacon <[email protected]>

feat(expo)!: drop logging endpoint (#18596)

# Why

- In the new versioned CLI we don't support the logging endpoint,
instead favoring the logging WebSocket setup by `metro-runtime`.
- Dropping s

feat(expo)!: drop logging endpoint (#18596)

# Why

- In the new versioned CLI we don't support the logging endpoint,
instead favoring the logging WebSocket setup by `metro-runtime`.
- Dropping support for `logUrl` will break logging in the legacy
`expo-cli start` command, no logs will show up.
- Drop `Logs` module: `import { Logs } from 'expo';`.
- Drop stack trace filter that removes `react-native-logging.fx` since
we no longer need it.
- Also removes the "temporary workaround"s from 2018 that filter out
warnings from the lottie package.
- Drop direct dependency on `invariant`, `pretty-format`, `fbemitter`

> This doesn't add breaking changes to the local Expo CLI, only the
deprecated global CLI.

# Test Plan

- Copied the JS expo files into a new project and websockets continued
to send logs.

# 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 ...


# 465d3694 26-Jul-2023 Evan Bacon <[email protected]>

feat(cli): dynamically enable lazy bundling (#23675)

# Why

If a package is using `import()` syntax, it needs to have
`@expo/metro-runtime` installed and imported somewhere. This issue
partially

feat(cli): dynamically enable lazy bundling (#23675)

# Why

If a package is using `import()` syntax, it needs to have
`@expo/metro-runtime` installed and imported somewhere. This issue
partially goes away in RN 73, and is not a problem in `expo-router`.

<!--
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 ...


# 47d62600 16-Jun-2023 Kudo Chien <[email protected]>

[cli][packages] unify the default dev server port to 8081 (#22880)

# Why

for historical reasons, when running `npx expo start` the dev-server listens to port 19000, and running `npx expo start --

[cli][packages] unify the default dev server port to 8081 (#22880)

# Why

for historical reasons, when running `npx expo start` the dev-server listens to port 19000, and running `npx expo start --dev-client` it listens to port 8081. since we are now on our effort to deprecate `--dev-client` option, it is better to unify the listening port.
close ENG-8936

# How

- update packages/**/*.ts for port 19000 -> 8081
- search more occurrences for 19000 to 8081

# Test Plan

- ci passed
- bare-expo
- unversioned expo go + ncl

show more ...


# 60d28ff6 03-Jun-2023 Evan Bacon <[email protected]>

feat(cli): Add support for Metro lazy bundling (#22724)

# Why

- Companion to https://github.com/expo/router/pull/622

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

feat(cli): Add support for Metro lazy bundling (#22724)

# Why

- Companion to https://github.com/expo/router/pull/622

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

# How

- Add `lazy` query parameter for Metro requests and `EXPO_NO_METRO_LAZY`
to disable the feature. Abiding by
https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md#__loadbundleasync-in-metro

# Test Plan

- Works when used with https://github.com/expo/router/pull/622

---------

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

show more ...


# 1a3d836e 22-May-2023 Evan Bacon <[email protected]>

feat(cli): Add `--no-minify` flag to `npx expo export` to prevent minifying output JavaScript. (#22544)

# Why

Nice feature to have for debugging.

# How

- Add the `--no-minify` flag to `npx

feat(cli): Add `--no-minify` flag to `npx expo export` to prevent minifying output JavaScript. (#22544)

# Why

Nice feature to have for debugging.

# How

- Add the `--no-minify` flag to `npx expo export`.
- Forward the flag to all Metro invocations.
- Also noticed that in some places, we were minifying Node.js code which
doesn't matter, so now we always skip minification when creating static
functions.

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

# Test Plan

- `npx expo export --no-minify` -> JS and CSS is not minified.

---------

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 ...


# 9fe3dc72 07-Apr-2023 Will Schurman <[email protected]>

[cli] Remove legacy manifest signing in modern manifest format and fix cached development code signing info (#21989)


# ca1e1b92 05-Apr-2023 Will Schurman <[email protected]>

[cli][dev-client] Fix legacy accept signature parsing in CLI and don't require in dev client (#21970)

# Why

This fixes three interconnected bugs:
1. The header that controls this can be named
`

[cli][dev-client] Fix legacy accept signature parsing in CLI and don't require in dev client (#21970)

# Why

This fixes three interconnected bugs:
1. The header that controls this can be named
`exponent-accept-signature` or `expo-accept-signature`. Not sure of the
history here. This PR makes these consistent. And it might have been
fine to leave this as-is but it's easier to reason about this way IMO.
2. The value of this header is either the string "true" or "false".
`Boolean("false") === true`, so this code was always returning true.
This historically seemed to not matter since all clients (including dev
clients) set this to "true".
3. Dev clients were sending `expo-accept-signature: true` header, which
isn't necessary (dev clients don't need signed manifests since they
don't use scoped modules).

Fixes a portion of
https://linear.app/expo/issue/ENG-6980/fall-back-to-serving-unsigned-manifests-if-a-user-isnt-authorized-to

# Test Plan

1. `et gba -n testwat expo-dev-menu expo-dev-client expo-dev-launcher
expo-updates expo-manifests expo-updates-interface`
2. Logged-in to user that owns an account, `eas update:configure`
3. Log out
4. Log in to a different user that is a viewer on that account.
5. Build on android/ios
6. In `packages/@expo/cli` run `nexpo start --dev-client`
7. Before changes, see that it throws
```
ApiV2Error: Not authorized. You must have DEVELOPER or above access on
the wschurman account to develop this project, or you may remove the
owner listed in app.json to develop this project under your own account.
```
8. After changes, see that it works.

# 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 ...


# 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 ...


# be2ffbef 13-Feb-2023 Evan Bacon <[email protected]>

feat(cli, metro-config): implement new unstable_serverRoot feature (#21088)

# Why

- Metro web doesn't work with monorepos because requests that look up
past the project root like `/../../` will

feat(cli, metro-config): implement new unstable_serverRoot feature (#21088)

# Why

- Metro web doesn't work with monorepos because requests that look up
past the project root like `/../../` will be collapsed to `/` which
breaks a number of features.
- Metro added `unstable_serverRoot` which we now automatically set to
the workspace root when `EXPO_USE_METRO_WORKSPACE_ROOT=1` is enabled. If
this works well at scale, we'll enable the feature by default.

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

---------

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

show more ...


# 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 ...


# 2beab412 19-May-2022 Evan Bacon <[email protected]>

chore(cli): make bundler adapter more agnostic (#17575)

* chore(cli): make bundler adapter more agnostic

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

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

chore(cli): make bundler adapter more agnostic (#17575)

* chore(cli): make bundler adapter more agnostic

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

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

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

show more ...


# e377ff85 05-Apr-2022 Will Schurman <[email protected]>

feat(cli): add development code signing (#16845)


# 1fb548e8 31-Mar-2022 Will Schurman <[email protected]>

feat(cli): serve modern manifests in multipart format (#16804)


# 29975bfd 28-Mar-2022 Evan Bacon <[email protected]>

fix(cli): fix type errors (#16724)

* fix(cli): fix type errors

* Update CHANGELOG.md

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

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

fix(cli): fix type errors (#16724)

* fix(cli): fix type errors

* Update CHANGELOG.md

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

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

* fix typecheck

* Update yarn.lock

* Update package.json

* Update MetroTerminalReporter.ts

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 ...