[BUG] build with yarn link #2722
Unanswered
lifaon74
asked this question in
Troubleshooting
Replies: 1 comment 1 reply
-
We just created a PR that adds support for better handling of npm linked packages, I'd love your feedback on it and hopefully it fixes your issue: #2707 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I found a bug while building an application with snowpack, where one of the package is
yarn link
: the result file is common-js (snowpack uses common-js entry point of the package.json in this particular situation).This result in a success build, but in an unusable application in the browser (missing
module.exports
andrequire
).Here are the steps to reproduce the bug (I created for you a demo repo to reproduce it):
Install the package locally: https://github.com/lifaon74/hello-world
cd ./hello-world/build yarn install npm run build npm run link:package
Install the snowpack test env: https://github.com/lifaon74/snowpack-test
cd ./snowpack-test npm run link:hello-world npm run build
Here's the build result: https://github.com/lifaon74/snowpack-test/blob/main/build/_snowpack/pkg/%40lifaon/hello-world.js
(I've commit the full build there: https://github.com/lifaon74/snowpack-test/tree/main/build)
As you may see it's common-js resulting in TypeError when loading it on a browser.
The package properly exports boths cjs and mjs: https://www.skypack.dev/view/@lifaon/hello-world
When installing normally the package (
yarn install
instead ofyarn link "@lifaon/hello-world"
), the hello-world package is correctly build and the app works juste fine.I did not test with
npm link
but I guess the problem will be the same.For more precision, don't hesitate to ask for any help.
PS: this issue #429 is related, but it's not really the same problem: in my case the build in incorrect, where in 429, its related to the hot reloading.
Beta Was this translation helpful? Give feedback.
All reactions