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

How are we going to import @node-core/ui-components? #236

Closed
avivkeller opened this issue Mar 24, 2025 · 18 comments
Closed

How are we going to import @node-core/ui-components? #236

avivkeller opened this issue Mar 24, 2025 · 18 comments

Comments

@avivkeller
Copy link
Member

avivkeller commented Mar 24, 2025

npm does not support importing packages from subdirectories of git repositories.

According to npm/npm#2974 (comment):

This isn't something that the npm CLI team is interested in adding to the tool.

There are third-party solutions like GitPkg that allow this functionality in npm, but I'm not sure we should rely on a third-party tool to handle imports–lest something bad happen.

However, both Yarn (although, yarn requires the website to also use yarn) and pnpm do support this, so we could convert this repository to use one of them instead.

This would also require any project that runs api-docs-tooling use the same package manager (i.e. pnpm dlx instead of npx for execution).

Reference: nodejs/nodejs.org#7401 (comment)

@AugustinMauroy
Copy link
Member

Why not publish ui-components ?

@avivkeller
Copy link
Member Author

avivkeller commented Mar 24, 2025

That's an option, but I feel like we are going to be constantly updating that package, so it might be easier to keep it imported from the repository.

@AugustinMauroy
Copy link
Member

That's an option, but I feel like we are going to be constantly updating that package, so it might be easier to keep it imported from the repository.

With a CD it's just a git tag to create no needed to create a changelog

@avivkeller
Copy link
Member Author

Personally, I'm in favor of adopting support for pnpm, as it doesn't require the website to also use pnpm, and we can just add the following the package.json file:

"@node-core/ui-components": "github:nodejs/nodejs.org#main&path:packages/ui-components"

However, I think we should get more opinions before making any decision.

@flakey5
Copy link
Member

flakey5 commented Mar 24, 2025

This would also require any project that runs api-docs-tooling use the same package manager (i.e. pnpm dlx instead of npx for execution).

Would that interfere with us using node --run for nodejs/node#57343?

@avivkeller
Copy link
Member Author

avivkeller commented Mar 24, 2025

No, we'd just change the npm installation step to a pnpm installation step, but let's cross that bridge if we get to it.

node --run is package manager ambiguous.

@AugustinMauroy
Copy link
Member

No, we'd just change the npm installation step to a pnpm installation step, but let's cross that bridge if we get to it.

node --run is package manager ambiguous.

it's mean we will need pnpm in node core ?

@avivkeller
Copy link
Member Author

avivkeller commented Mar 24, 2025

We wouldn't need to depend on it, we would just have to assume the user has it installed, which isn't ideal, but every one of our options has a drawback.

  • Switching package managers has the drawbacks of requiring Node.js doc-builders and linters to have it installed

  • Publishing to npm has the drawback of needing to setup a publishing automation, and not control versions by commit

  • Using a third party tool has the drawback of being a third party tool

  • We could also require the user to clone the website, and include like a local file, but that has the drawback of requiring the user to clone the website. (Example: https://stackoverflow.com/a/39195334)

@ovflowd
Copy link
Member

ovflowd commented Mar 24, 2025

I think we should publish the package, but not necessarily npm. It can be as an GitHub artifact. https://docs.github.com/en/packages/quickstart

@avivkeller
Copy link
Member Author

avivkeller commented Mar 24, 2025

It can be as an GitHub artifact.

That could work. Once the ui-components library lands, I'll make a CI/CD pipeline for uploading it to the GitHub packages registry.

I'm gonna leave this issue open until then, just in case anything changes.

@ovflowd
Copy link
Member

ovflowd commented Mar 24, 2025

It can be as an GitHub artifact.

That could work. Once the ui-components library lands, I'll make a CI/CD pipeline for uploading it to the GitHub packages registry.

I'm gonna leave this issue open until then, just in case anything changes.

Are you merging the PR today?

@avivkeller
Copy link
Member Author

Yes, I don't think anyone else is going to object in the next hour, so I'm merge it now, but I'm going to add a workflow in a second PR, in case it needs a revert, we don't need to revert the entire UI package

@avivkeller
Copy link
Member Author

avivkeller commented Mar 25, 2025

We need to verify that Node.js can publish to the @node-core Github packages scope, otherwise, we might need to publish to npm. I know we control that scope on npm, but I'm not sure if we control it on Github Packages, I feel like we only control @nodejs (as that's the organization scope).

Edit: We do not control the @node-core scope (See https://github.com/orgs/community/discussions/52267#discussioncomment-5554918).

We have a few options:

  1. Publish to npm, where we do control the @node-core scope
  2. Rename the package to @nodejs/ui-components, and publish to Github Packages
  3. Make an @node-core organization, and publish there (but I don't think that's the best idea)
  4. All of the original options

@bjohansebas
Copy link
Member

Of those options you gave, the best and simplest one is just renaming the package to nodejs/ui-components. It will only be used here, so I don't think the name change is that bad.

@ovflowd
Copy link
Member

ovflowd commented Mar 25, 2025

We need to verify that Node.js can publish to the @node-core Github packages scope, otherwise, we might need to publish to npm. I know we control that scope on npm, but I'm not sure if we control it on Github Packages, I feel like we only control @nodejs (as that's the organization scope).

Edit: We do not control the @node-core scope (See https://github.com/orgs/community/discussions/52267#discussioncomment-5554918).

We have a few options:

  1. Publish to npm, where we do control the @node-core scope
  2. Rename the package to @nodejs/ui-components, and publish to Github Actions
  3. Make an @node-core organization, and publish there (but I don't think that's the best idea)
  4. All of the original options

cc @nodejs/tsc and @nodejs/build looking for guidance here

@ruyadorno
Copy link
Member

According to npm/npm#2974 (comment):

That's a 9 years old, outdated comment.

npm does not support importing packages from subdirectories of git repositories.

That's wrong, npm does support installing packages from subdirectories. I was there when we implemented it during the npm7 rewrite, although I acknowledge that it doesn't seem to have been properly documented back then. Here's how you use it:

  "dependencies": {
    "@node-core/ui-components": "nodejs/nodejs.org#main::path:packages/ui-components"
  }

I would suggest one of you to contribute back to the npm docs so that it's easier to you all and the rest of the world to know how to use it in the future. Here are some refs on how to use it from its tests.

@ovflowd
Copy link
Member

ovflowd commented Mar 26, 2025

According to npm/npm#2974 (comment):

That's a 9 years old, outdated comment.

npm does not support importing packages from subdirectories of git repositories.

That's wrong, npm does support installing packages from subdirectories. I was there when we implemented it during the npm7 rewrite, although I acknowledge that it doesn't seem to have been properly documented back then. Here's how you use it:

  "dependencies": {
    "@node-core/ui-components": "nodejs/nodejs.org#main::path:packages/ui-components"
  }

I would suggest one of you to contribute back to the npm docs so that it's easier to you all and the rest of the world to know how to use it in the future. Here are some refs on how to use it from its tests.

Thanks for chiming in, Ruy!

@avivkeller
Copy link
Member Author

Thanks! Sorry about my outdated information, I'll check and PR the npm documentation to make this more clear.

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 a pull request may close this issue.

6 participants