Skip to content

feat(cli): Allow prebuild from monorepo expo-template-bare-minimum template#41383

Merged
kitten merged 8 commits intomainfrom
@kitten/feat/cli-prebuild-from-local-module-2
Dec 3, 2025
Merged

feat(cli): Allow prebuild from monorepo expo-template-bare-minimum template#41383
kitten merged 8 commits intomainfrom
@kitten/feat/cli-prebuild-from-local-module-2

Conversation

@kitten
Copy link
Copy Markdown
Member

@kitten kitten commented Dec 3, 2025

Why

Note

Supersedes #41306.
This hides the template way in a CLI dev-only dependency, so it's not as publicly visible, since it's only meant for our own testing and monorepo.

We're often making changes to local templates, e.g.:

Since we don't have a concept of local templates, we then have to make sure to specify a local prebuild template manually. However, this seems pretty redundant because expo-template-bare-minimum is just a package and in the monorepo.

Failing to apply template changes to prebuild CNG folders often causes build issues on main as we upgrade React Native.

Applying the monorepo template automatically seems like a good idea, since we then automatically test against any template changes on main.

How

  • Add packages/@expo/cli/local-template -> templates/expo-template-bare-minimum symlink
  • Exclude /local-template symlink explicitly in CLI's .npmignore
  • Extend resolveLocalTemplateAsync to try to load from @expo/cli/local-template locally first

This means in expo/expo, we'll now always look at the up-to-date templates/expo-template-bare-minimum contents, instead of expo/template.tgz

Test Plan

  • CI covers this behaviour

Checklist

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 3, 2025

Subscribed to pull request

File Patterns Mentions
packages/@expo/cli/** @EvanBacon, @byCedric

Generated by CodeMention

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Dec 3, 2025
@kitten kitten force-pushed the @kitten/feat/cli-prebuild-from-local-module-2 branch from 8ca39b2 to 4bb4bee Compare December 3, 2025 17:38
@kitten kitten force-pushed the @kitten/feat/cli-prebuild-from-local-module-2 branch from 4bb4bee to 5d446ff Compare December 3, 2025 18:37
/** Returns the `local-template` target path, only for the `expo/expo` monorepo */
const getMonorepoTemplatePath = async () => {
const cliPath = path.dirname(require.resolve('@expo/cli/package.json'));
const localTemplateOriginPath = path.join(cliPath, 'local-template');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would lean toward to use __dirname/../../... than resolving @expo/cli/package.json again. think the case where people in a project outside of expo/expo and execute expo-cli from expo/expo. maybe good to keep behavior consistent

$ cd sdk54
$ /path/to/expo/expo/packages/@expo/cli/build/bin/cli prebuild

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use require.resolve('@expo/cli') pretty often because the build/ output path is shifted, i.e. it shifts to build/src/. That in itself is (currently) consistent of course, but we use this pattern in other places in the CLI to prevent this from being based on a different path (since the src/ path doesn't match the build path unfortunately, and we don't use a bundling/build tool that accounts for this and modifies the path)

@kitten kitten force-pushed the @kitten/feat/cli-prebuild-from-local-module-2 branch from 7e79a96 to e5c6626 Compare December 3, 2025 19:38
@kitten kitten merged commit 585fcca into main Dec 3, 2025
17 of 18 checks passed
@kitten kitten deleted the @kitten/feat/cli-prebuild-from-local-module-2 branch December 3, 2025 20:38
aleqsio pushed a commit that referenced this pull request Dec 5, 2025
…template (#41383)

# Why

> [!NOTE]
> Supersedes #41306.
> This hides the template way in a CLI dev-only dependency, so it's not
as publicly visible, since it's only meant for our own testing and
monorepo.

We're often making changes to local templates, e.g.:
- #41264
- #39418

Since we don't have a concept of local templates, we then have to make
sure to specify a local prebuild template manually. However, this seems
pretty redundant because `expo-template-bare-minimum` is just a package
and in the monorepo.

Failing to apply template changes to prebuild CNG folders often causes
build issues on `main` as we upgrade React Native.

Applying the monorepo template automatically seems like a good idea,
since we then automatically test against any template changes on `main`.

# How

- Add `packages/@expo/cli/local-template ->
templates/expo-template-bare-minimum` symlink
- Exclude `/local-template` symlink explicitly in CLI's `.npmignore`
- Extend `resolveLocalTemplateAsync` to try to load from
`@expo/cli/local-template` locally first

This means in `expo/expo`, we'll now always look at the up-to-date
`templates/expo-template-bare-minimum` contents, instead of
`expo/template.tgz`

# Test Plan

- CI covers this behaviour

# Checklist

- [x] I added a `changelog.md` entry and rebuilt the package sources
according to [this short
guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)

---------

Co-authored-by: Kudo Chien <kudo@expo.dev>
kitten added a commit that referenced this pull request Dec 10, 2025
# Why

See CI failure in:
https://github.com/expo/expo/actions/runs/19916741962/job/57096975273
Caused by symlink added in: #41383

# How

- ~~Update the workspaces pattern to only find Expo package folders by
workspace specifier name (mirroring the path in `Project.ts` and root
`package.json:workspaces`)~~
- Ignore `local-template` in `@expo/cli`

# Test Plan

- CI should pass the mentioned run

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
-->

- [ ] I added a `changelog.md` entry and rebuilt the package sources
according to [this short
guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
aleqsio pushed a commit that referenced this pull request Dec 22, 2025
# Why

See CI failure in:
https://github.com/expo/expo/actions/runs/19916741962/job/57096975273
Caused by symlink added in: #41383

# How

- ~~Update the workspaces pattern to only find Expo package folders by
workspace specifier name (mirroring the path in `Project.ts` and root
`package.json:workspaces`)~~
- Ignore `local-template` in `@expo/cli`

# Test Plan

- CI should pass the mentioned run

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
-->

- [ ] I added a `changelog.md` entry and rebuilt the package sources
according to [this short
guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants