yalc
yalc copied to clipboard
Issue with yalc link & react package
I'm developing a React library and I'm using yalc link
to use the development version in a storybook project.
- packages
- my-react-lib
- storybook
I'm doing yalc publish
in react folder, then yalc link my-react-lib
in storybook folder. When running yarn start-storybook
in link mode, I'm getting an error in console : Uncaught TypeError: Cannot read property 'createElement' of undefined
which seems to be related to React.createElement
. If I use yalc add my-react-lib
, everything works fine. Is there some gotcha with links?
I had the issue where I link a local package and I did add new dep to this local version, but when I do yarn start on my solution, I get an error like Couldn't find the package "NewDep". So I yarn install and it overwrite the package. I yalc link localPackage and yarn start and still get the same error where the package wasn't found, so I search in node_module and the package wasn't there. But if I yalc add localPackage which change my package.json to "Package": "^x.xx.xx" -> "file:.yalc/LocalPackage", now it install the NewDep I add locally. Seem like yalc link doesn't make yarn check the package.json of the localPackage. It check the publish package I think.
Also, I have hot-reload and if I use "nodemon /dist/ "yalc push"" with a "yalc add" only, hot-reload isn't working but if I do with "Yalc link" it's working. So in my case, I'm obligated to use "yalc add localPackage && yalc link localPackage" just so it install new added dep and make hot-reload work. I would prefer if link would make "yarn install" install newly added dep on the "yalc link" local package.
You may try yalc add --link localPackage
It will add link:
dependency instead of file: