-
Notifications
You must be signed in to change notification settings - Fork 205
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
NPM packages are installed as dependencies instead of peerDependencies. #864
Comments
Starting from scratch, when I run:
I do not experience this problem. It's difficult to confirm, but I would make the assumption that the reason you've run into this situation is that you were running In this way, the only way to ensure a flat install at current is to use Separately, were we clean on what's needed to move to 1.0, then we would be able to rely on the fact that post-1.0 NPM only counts If everything above makes sense, I'd prefer that we close this issue as no action needed and start a new issue of "How do we get to 1.0?" where we can expand on the conversation as to what's needed for us to certify the various packages we are vending as 1.0. Thoughts? |
Thanks for looking into this so quickly @Westbrook! You are right. It turns out my project is not up to date and some dependencies were not synced. What I had was... "dependencies": {
"@spectrum-web-components/button": "^0.8.4",
"@spectrum-web-components/dropdown": "^0.7.2",
"@spectrum-web-components/menu": "^0.3.2",
"@spectrum-web-components/styles": "^0.6.0",
"@spectrum-web-components/dialog": "^0.3.0",
"lit-element": "^2.2.1",
"lit-html": "^1.0.0"
}, Regardless, even with the latest I notice that there are two copies of sp-button in node_modules. One in @spectrum-web-components/button and another one in @spectrum-web-components/dialog/node_modules/@spectrum-web-components/button but there is no error this time. I'm OK to close this issue as peerDependencies is not preferred solution but I still think we need a simple way to keep the custom element dependencies flat. |
ref #865 |
When installing SWC packages with
npm i [package]
, very often packages get installed as nested dependencies and this results with redundant and often broken code in the project (cannot register same element twice).For this reason, it is important that there is one and only one @spectrum-web-components directory inside node_modules and that all SWC components live right there - next to each other. This prevents the ability to have multiple versions of the same element, and that is a good thing.
I believe the issue is caused by components installing dependent components as "dependencies" while they should be "peerDependencies".
Here one way to reproduce this problem:
Take the starter project from this repo, run
npm i @spectrum-web-components/dialog
and import it in the project.Notice that sp-icon is imported twice. Once from node_modules/@spectrum-web-components/icon, and another one in node_modules/@spectrum-web-components/dialog/node_modules/@spectrum-web-components/icon
The text was updated successfully, but these errors were encountered: