Skip to content
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

Resolve peers from Glint and/or ember-source #101

Closed

Conversation

NullVoxPopuli
Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli commented Jan 17, 2023

… (and ember-source would be required the moment you import anything anyway)

@glimmer/component is required by Glint
ember-source is required by nearly everything 🙃 (so this addition is more preemptive than anything)

Partially resolves #100 and #77

… (and ember-source would be required the moment you import anything anyway)
@NullVoxPopuli NullVoxPopuli changed the title Add glimmer/component and ember-source, as they are required by glint… Resolve peers from Glint Jan 17, 2023
Copy link
Collaborator

@simonihmig simonihmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, but...

Tbh, I have more than one addon where I historically never cared about peerDeps and put just everything into deps (not ember-source of course, but @glimmer/component for example). I see that the v1 addon blueprint now also has a peer dependency on ember-source, but not for @glimmer/component, I guess because not every addon necessarily will have expose components (but most/a lot will).

Which brings up the question: should we do this here?

You did this specifically because we chose to add Glint types by default, and they rely on the presence of @glimmer/component, right? If so, we only have glint packages as devDependencies, so to satisfy the peer dependency we could just add @glimmer/component to our devDependencies as well, right?

Second, however we decide on this, I think we need better guidance for addon authors on this topic (what is a dependency, what a peer, all with examples specific to the Ember ecosystem). Especially should we decide to not declare @glimmer/component a peer by default here. People - like me 🙈 - will just think, ok, I am actually importing @glimmer/component from exposed run-time code, so I'll just add it to my dependencies.

Of course out of scope for this PR, so sorry for diverging a bit, but wanted to leave this here before I forget... Especially as we have a learning team member here among the reviewers! 😬

@NullVoxPopuli
Copy link
Collaborator Author

NullVoxPopuli commented Jan 19, 2023

@glimmer/component for example
because we chose to add Glint types by default, and they rely on the presence of @glimmer/component, right?

ember-source also has declared a peer on @glimmer/component.

Without this change:

ember addon peer-test -b ../NullVoxPopuli/addon-blueprint-2/ --skip-npm --pnpm
cd peer-test
pnpm i
# ... -> 

 WARN  Issues with peer dependencies found
peer-test
├─┬ ember-source 4.10.0
│ ├── ✕ missing peer @glimmer/component@^1.1.2

This may be an incorrect thing for ember-source to do, as @glimmer/component has no behavioral benefit within ember-source, and the typed-ember folks are only using it to provide some utility types for the Signature and shape-of-a-component type stuff -- see: emberjs/ember.js@6278a8b
also cc @chriskrycho, for vis
I did a search on emberjs/ember.js, and most occurrences of @glimmer/component are in comment blocks (followed by tests)

@@ -25,6 +25,9 @@
"test": "echo 'A v2 addon does not have tests, run tests in test-app'",
"prepack": "rollup --config"
},
"peerDependencies": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonihmig now only ember-source is a peer.

you are correct that it doesn't make sense for us to include @glimmer/component as a peer by default (as many utility libraries may not care about @glimmer/component at all!)

@@ -34,6 +37,7 @@
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.17.0",
"@babel/plugin-syntax-decorators": "^7.17.0",
"@glimmer/component": "^1.1.2",
Copy link
Collaborator Author

@NullVoxPopuli NullVoxPopuli Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this devDep satisfies the peer requirements from ember-source and glint (when used)

@NullVoxPopuli NullVoxPopuli changed the title Resolve peers from Glint Resolve peers from Glint and/or ember-source Jan 19, 2023
@ef4
Copy link
Contributor

ef4 commented Jan 31, 2023

Because everything in ember-source doesn't really resolve normally anyway, there's not much functional reason to have the peerDep on ember-source. The main reason people are forced to add it is if they want to say dependencySatisfies('ember-source', ...).

And because package managers do confusing and painful things with peerDeps, I'm hesitant to encourage every v2 addon to add this unused-but-likely-to-break-your-monorepo peerDep right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect peer setup (revealed with pnpm, npm8)
3 participants