-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Support running create-react-app inside a monorepo. #3967
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a479ce9
Use `resolve-from` to respect `node_modules` hierarchy in `createReac…
e2d2dec
Resolve `ownPath` in `init.js` using `resolve-from`
3dab136
Test running create-react-app inside monorepo.
bradfordlemley 9670be6
Merge branch 'next' into mono-cra
bradfordlemley 69d822c
Use common strategy to decide whether to use yarn or npm.
bradfordlemley 40bb89c
Workaround yarn workspace bug not creating app/node_modules/.bin link…
bradfordlemley e188e1e
Remove yarn < 1.5 workaround.
bradfordlemley 9d9b057
Revert "Remove yarn < 1.5 workaround."
bradfordlemley 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 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 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
5 changes: 5 additions & 0 deletions
5
packages/react-scripts/fixtures/monorepos/cra-app/.template.dependencies.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"comp2": "^1.0.0" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/react-scripts/fixtures/monorepos/cra-app/gitignore
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# generated test output | ||
testoutput.json | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
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
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
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.
Note, test.js in ejected app gets picked up (and fails because it's not a jest test) when running tests from other cra apps in the monorepo. One way to solve this would be to detect other cra apps in the monorepo (pkgs with dependency on react-scripts?) and either not treat them as cra sources, or use approot/src as their source path instead of approot. Another way could be by explicit cra source inclusion/exclusion.
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.
Can you explain in more detail? I don't follow. Whose test is this? Why is it not a jest test? What directory/package layout does this happen with?
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.
When running "yarn test" in cra-app2, jest tries to run cra-app1/scripts/test.js as a test, same as cra-app1/src/App.test.js. This is because we have given jest cra-app1 as a root and the jest testMatcher pattern '**/?(*.)(spec|test).{js,jsx,mjs}' matches test.js.
Just to be more clear -- this issue isn't related to the current PR, it just came up in testing this PR. The issue comes up when you have multiple cra-apps in a monorepo, and one or more of them has been ejected.
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.
Looking at that structure, my earlier suggestion of detecting based on react-scripts as a dependency won't work. Since that cra-app1 has been ejected, it doesn't have react-scripts as a dependency and wouldn't be detected as a cra app. So, it falls into the category of being just some other thing in the monorepo that has its own build/test/etc. I think we need some inclusion/exclusion config, instead of assuming everything in the monorepo is cra source. (for the sake of posterity, this discussion probably belongs elsewhere -- should I create a new issue for the discussion?)
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.
Let's discuss in a new issue. 👍