Support yarn/npm link'ed packages by default#5654
Closed
stristr wants to merge 1 commit into
Closed
Conversation
Author
|
Prior art: #3695 |
|
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Author
|
Keep alive! |
|
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Author
|
Keep alive! |
Author
|
Closing in favor of #6207. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR contains a simple update to the dev/prod webpack configurations that enables
yarn linkandnpm linkto work out of the box withreact-scripts.Background
Webpack provides a
resolve.symlinksconfiguration option, and the documentation states:…and it does. A basic failing use case is:
# /some/local/directory/foo/package.json# /some/local/directory/foo/index.jsIf I run
yarn link fooinside areact-scriptsproject, theresolve.symlinksoption will tellwebpackto resolve./node_modules/foo -> /some/local/directory/foowith Node module resolution applied to all therequire(...)s therein. In particular, this means that inside this symlinked module,require('react')will do one of two things:/some/local/directory/foo/node_modules/reactinstead of./node_modules/react)[yarn|npm] installin/some/local/directory/fooyet.Clearly neither of these is desirable—the typical use case for
yarn linkis to shim an in-development library into another project exactly as if it had been installed viayarn, except possibly with local modifications. I have even worked with teams that deploy from codebases withyarn link'ed dependencies.Rationale
I'm proposing this change because I think supporting
yarn linkandnpm linkis a relatively common use case (see #3547 and the various associated issues), and that the use cases in which we would want to resolve symlinks to their actual locations are far more advanced than the use cases in which we wouldn't. So this seems to meet the needs of the pre-ejection CRA target audience better than the defaultwebpacksymlink resolution behavior.