-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor react-native-windows install to better support Metro config #4522
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4b66781
first version
kmelmon b25318b
Change files
kmelmon beea8af
fixup e2etest
kmelmon 2e1c124
fixup react-native-win32, take 1
kmelmon 087ffe1
fixup react-native-win32, take 2
kmelmon 83dc7da
fix integration tests
kmelmon 3d18fed
Change files
kmelmon a51b233
fixup more references
kmelmon 283746d
fixup another path
kmelmon 50a2675
more fixes for integration tests
kmelmon 88c07ee
fix bug in postinstall, clang format cleanup
kmelmon 0891ee9
fix lint errors
kmelmon 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
8 changes: 8 additions & 0 deletions
8
change/@office-iss-react-native-win32-2020-04-11-14-57-30-metro-fix.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": "refactor react-native-windows installation for better metro support", | ||
| "packageName": "@office-iss/react-native-win32", | ||
| "email": "kmelmon@microsoft.com", | ||
| "dependentChangeType": "patch", | ||
| "date": "2020-04-11T21:57:04.043Z" | ||
| } |
8 changes: 8 additions & 0 deletions
8
change/react-native-windows-2020-04-10-11-55-54-metro-fix.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": "refactor react-native-windows install to better support metro", | ||
| "packageName": "react-native-windows", | ||
| "email": "kmelmon@microsoft.com", | ||
| "dependentChangeType": "patch", | ||
| "date": "2020-04-10T18:55:54.788Z" | ||
| } |
8 changes: 8 additions & 0 deletions
8
change/react-native-windows-2020-04-11-14-57-30-metro-fix.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": "refactor react-native-windows installation for better metro support", | ||
| "packageName": "react-native-windows", | ||
| "email": "kmelmon@microsoft.com", | ||
| "dependentChangeType": "patch", | ||
| "date": "2020-04-11T21:57:30.042Z" | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,3 +40,6 @@ link( | |
| 'rnpm-plugin-windows', | ||
| path.resolve(require.resolve('rnpm-plugin-windows/package.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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| const path = require('path'); | ||
| module.exports = { | ||
| reactNativePath: '../../vnext', | ||
| reactNativePath: path.resolve(__dirname, '../../vnext/react-native-installation'), | ||
| }; |
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
3 changes: 2 additions & 1 deletion
3
packages/microsoft-reactnative-sampleapps/react-native.config.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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| const path = require('path'); | ||
| module.exports = { | ||
| reactNativePath: '../../vnext', | ||
| reactNativePath: path.resolve(__dirname, '../../vnext/react-native-installation'), | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,5 @@ | |
| /RNTester | ||
| /RNTester.* | ||
| /temp | ||
| /WorkingHeaders | ||
| /WorkingHeaders | ||
| /react-native-installation | ||
91 changes: 91 additions & 0 deletions
91
packages/react-native-win32/Scripts/copyRNWin32Libraries.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,91 @@ | ||
| /** | ||
| * @format | ||
| */ | ||
| // @ts-check | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const glob = require('glob'); | ||
| const rimraf = require('rimraf'); | ||
|
|
||
| function retryOnError(errorCode, func) { | ||
| const startTime = Date.now(); | ||
|
|
||
| while (true) { | ||
| try { | ||
| func(); | ||
| return true; | ||
| } catch (ex) { | ||
| if (ex.code !== errorCode) { | ||
| throw ex; | ||
| } | ||
| } | ||
|
|
||
| if (Date.now() - startTime > 5000) { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function copyDirectories(srcPath, targetPath, dirSpecs) { | ||
| dirSpecs.forEach(dirSpec => { | ||
| if (dirSpec.mergeFiles !== true) { | ||
| // rimraf issue 72: We will see ENOTEMPTY if Windows is still holding a | ||
| // lock to a file in our directory. E.g. if we get unlucky with timing | ||
| // and antivirus decides to run. Keep on spinning until we're able to | ||
| // delete the directory. | ||
| let deleted = retryOnError('ENOTEMPTY', () => { | ||
| if (dirSpec.rmFilter === undefined) { | ||
| rimraf.sync(path.resolve(targetPath, dirSpec.dest)); | ||
| } else { | ||
| rimraf.sync( | ||
| path.resolve(targetPath, dirSpec.dest + path.sep + dirSpec.filter), | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| if (!deleted) { | ||
| throw new Error( | ||
| 'Timed out trying to delete directory. Ensure no locks are being held to project files and try again.', | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const curSrcPath = path.resolve(srcPath, dirSpec.src); | ||
| const curTargetPath = path.resolve(targetPath, dirSpec.dest); | ||
|
|
||
| glob.sync('**/*.{js,png,gif,h}', {cwd: curSrcPath}).forEach(file => { | ||
| const dir = path.dirname(file); | ||
| const targetDir = path.resolve(curTargetPath, dir); | ||
| const targetFile = path.resolve(curTargetPath, file); | ||
|
|
||
| fs.mkdirSync(targetDir, {recursive: true}); | ||
| fs.writeFileSync( | ||
| targetFile, | ||
| fs.readFileSync(path.join(curSrcPath, file)), | ||
| ); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| function copyFile(srcPath, targetPath, filename) { | ||
| fs.writeFileSync( | ||
| path.resolve(targetPath, filename), | ||
| fs.readFileSync(path.resolve(srcPath, filename)), | ||
| ); | ||
| } | ||
|
|
||
| exports.copyRNWin32Libraries = baseDir => { | ||
|
|
||
| const rnInstallationPath = path.resolve(baseDir, './react-native-installation'); | ||
|
|
||
| copyDirectories(baseDir, rnInstallationPath, [ | ||
| { | ||
| src: 'RNTester', | ||
| dest: 'RNTester', | ||
| mergeFiles: true, | ||
| }, | ||
| ]); | ||
|
|
||
| copyFile(baseDir, rnInstallationPath, 'RNTester.js'); | ||
| copyFile(baseDir, rnInstallationPath, 'RNTester.js.map'); | ||
| }; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,5 @@ | |
| /RNTester | ||
| /index.* | ||
| /RNTester.* | ||
| /jest | ||
| /jest | ||
| /react-native-installation | ||
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 |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ node_modules | |
| /RNTester | ||
| /RNTester.* | ||
| /index.* | ||
| /react-native-installation | ||
|
|
||
| # Visual Studio | ||
| .vs/ | ||
|
|
||
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
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
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.
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.
nit