Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] build with yarn link #2681

Closed
lifaon74 opened this issue Feb 20, 2021 · 1 comment
Closed

[BUG] build with yarn link #2681

lifaon74 opened this issue Feb 20, 2021 · 1 comment

Comments

@lifaon74
Copy link

lifaon74 commented Feb 20, 2021

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 and require).

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 of yarn 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.

@FredKSchott
Copy link
Owner

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

Repository owner locked and limited conversation to collaborators Feb 24, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants