yalc icon indicating copy to clipboard operation
yalc copied to clipboard

Issue with yalc link & react package

Open meriouma opened this issue 5 years ago • 2 comments

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?

meriouma avatar Feb 11 '20 19:02 meriouma

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.

maxime4000 avatar Oct 19 '20 19:10 maxime4000

You may try yalc add --link localPackage It will add link: dependency instead of file:

wclr avatar Oct 19 '20 20:10 wclr