-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli, router, metro, asset): add basePath support #23911
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expo-bot
added
bot: passed checks
ExpoBot has nothing to complain about
bot: suggestions
ExpoBot has some suggestions
and removed
bot: suggestions
ExpoBot has some suggestions
bot: passed checks
ExpoBot has nothing to complain about
labels
Aug 21, 2023
This was referenced Aug 23, 2023
EvanBacon
added a commit
that referenced
this pull request
Aug 24, 2023
# Why <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> - Prevent writing a `metadata.json` and `bundles/web-xxx.js` with static Metro web. - We have two systems for exporting with Metro in here, just haven't had time to migrate native over to use the new one. Also haven't had time to add sourcemap support or asset manifests to the new one either. - Split out of #23911 # 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 <34669131+expo-bot@users.noreply.github.com>
EvanBacon
added a commit
that referenced
this pull request
Aug 24, 2023
# Why <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> - Prevent writing a `metadata.json` and `bundles/web-xxx.js` with static Metro web. - We have two systems for exporting with Metro in here, just haven't had time to migrate native over to use the new one. Also haven't had time to add sourcemap support or asset manifests to the new one either. - Split out of #23911 # 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 <34669131+expo-bot@users.noreply.github.com>
EvanBacon
added a commit
that referenced
this pull request
Aug 26, 2023
# 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 #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).
EvanBacon
force-pushed
the
@evanbacon/cli/assetPrefix
branch
from
August 26, 2023 03:04
2dcbed0
to
0262aac
Compare
expo-bot
added
bot: suggestions
ExpoBot has some suggestions
and removed
bot: passed checks
ExpoBot has nothing to complain about
labels
Aug 26, 2023
EvanBacon
changed the title
feat(cli): add asset prefix support
feat(cli): add basePath support
Aug 28, 2023
EvanBacon
changed the title
feat(cli): add basePath support
feat(cli, router, metro, font, asset): add basePath support
Aug 28, 2023
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
EvanBacon
requested review from
Simek,
amandeepmittal,
marklawlor,
tsapeta,
byCedric and
douglowder
as code owners
September 1, 2023 02:07
marklawlor
approved these changes
Sep 1, 2023
@@ -250,6 +250,10 @@ export interface ExpoConfig { | |||
* Enable experimental features that may be unstable, unsupported, or removed without deprecation notices. | |||
*/ | |||
experiments?: { | |||
/** | |||
* Export a website relative to a subpath of a domain. The path will be prepended as-is to links to all bundled resources. Prefix the path with a `/` (recommended) to load all resources relative to the server root. If the path **does not** start with a `/` then resources will be loaded relative to the code that requests them, this could lead to unexpected behavior. Example '/subpath'. Defaults to '' (empty string). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should warn if the basePath is not absolute with an ENV to disable the warning. I'd rather help protect against typos than cater for an edge case
packages/expo-router/src/fork/__tests__/getPathFromState-upstream.test.node.ts
Show resolved
Hide resolved
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
EvanBacon
added a commit
that referenced
this pull request
Sep 12, 2023
# Why - Split out of #23911 - This PR also adds server tests for static rendering. - Make it easier to run and test e2e metro code. <!-- 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 <34669131+expo-bot@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
How
Add
expo.experiments.basePath
which can be used duringnpx 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.
Test Plan
expo export
test.Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).