eject removes linked react-scripts copy instead of symlink
Created by: tuchk4
Starts here https://github.com/facebookincubator/create-react-app/pull/1356#issuecomment-284256947
ownPath
- path to react-scripts
root.
If react-scripts
is linked - app node_modules looks like this
App/
|- node_modules/
|- react-scripts/ -> (symlink)/lib/node_modules/react-scripts
Case | ownPath | Notes |
---|---|---|
resolveApp('node_modules/react-scripts') | APP/node_modules/react-scripts | Path to react-scripts symlink |
resolveOwn('.') | CRA_DIR/packages/react-scripts | Path to local react-scripts copy |
resolveOwn('react-scripts') | LOCAL_CRA/packages/react-scripts/react-scripts | Path is wrong |
1st and 2nd cases are the same expect eject
- we remove (eject.js:160) react-scripts
from node_modules after eject.
In 2nd case local CRA packages/react-scripts will be removed instead of app node_modules/react-scripts.
@Timer We opted to switch to resolveOwn('.') because we don't want to hardcode the package name to be react-scripts.
I had unpleasant situation when run eject at app with linked react-scripts and my local CRA packages/react-scripts were removed with uncommitted changes :(
I have another implementation without name hardcode. I will test it and make new PR