-
Notifications
You must be signed in to change notification settings - Fork 1.2k
This is an alternate metro bundler fix for multiple out of tree platforms #4576
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3433374
Use a custom resolver wrapper to allow metro to run for multiple plat…
acoates-ms c7b6a18
Change files
acoates-ms e434358
Merge remote-tracking branch 'upstream/master' into altmetrofix
acoates-ms 4cc1ca2
More simplification of metro configs
acoates-ms 29e80df
CI fixes
acoates-ms f29da7a
Fix bundle command on init app to properly use windows platform
acoates-ms 3a965e0
More simplification of metro configs
acoates-ms 00f1f97
Fix asset loading
acoates-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
8 changes: 8 additions & 0 deletions
8
change/@office-iss-react-native-win32-2020-04-11-18-14-13-altmetrofix.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "Use a custom resolver wrapper to allow metro to run for multiple platforms at once", | ||
| "packageName": "@office-iss/react-native-win32", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch", | ||
| "date": "2020-04-12T01:14:10.605Z" | ||
| } |
8 changes: 8 additions & 0 deletions
8
change/react-native-windows-2020-04-11-18-14-13-altmetrofix.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "Use a custom resolver wrapper to allow metro to run for multiple platforms at once", | ||
| "packageName": "react-native-windows", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch", | ||
| "date": "2020-04-12T01:14:13.308Z" | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
packages/react-native-win32/metro-react-native-platform.js
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * @format | ||
| */ | ||
| const {resolve} = require('metro-resolver'); | ||
|
|
||
| /** | ||
| * platformImplementations is a map of platform to npm package that implements that platform | ||
| * | ||
| * Ex: | ||
| * { | ||
| * windows: 'react-native-windows' | ||
| * macos: 'react-native-macos' | ||
| * } | ||
| */ | ||
| function reactNativePlatformResolver(platformImplementations) { | ||
| return (context, _realModuleName, platform, moduleName) => { | ||
| let backupResolveRequest = context.resolveRequest; | ||
| delete context.resolveRequest; | ||
|
|
||
| try { | ||
| let modifiedModuleName = moduleName; | ||
| if (platformImplementations[platform]) { | ||
| if (moduleName === 'react-native') { | ||
| modifiedModuleName = platformImplementations[platform]; | ||
| } else if (moduleName.startsWith('react-native/')) { | ||
| modifiedModuleName = `${ | ||
| platformImplementations[platform] | ||
| }/${modifiedModuleName.slice('react-native/'.length)}`; | ||
| } | ||
| } | ||
| let result = resolve(context, modifiedModuleName, platform); | ||
| context.resolveRequest = backupResolveRequest; | ||
| return result; | ||
| } catch (e) { | ||
| context.resolveRequest = backupResolveRequest; | ||
| throw e; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| module.exports = {reactNativePlatformResolver}; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.