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

feat: support specifying npm registries via .npmrc #427

Merged
merged 15 commits into from
Oct 17, 2024

Conversation

nyannyacha
Copy link
Contributor

@nyannyacha nyannyacha commented Oct 15, 2024

What kind of change does this PR introduce?

Feature

Description

Add support for importing packages from the private npm registry via .npmrc.

Also, the packages imported from these registries are added together during the bundling process, so it shouldn't change existing behavior.

Resolves #402

@nyannyacha nyannyacha force-pushed the feat-enable-private-registry branch from 604925e to f4ba3b6 Compare October 16, 2024 03:02
@nyannyacha nyannyacha marked this pull request as ready for review October 16, 2024 03:02
@nyannyacha nyannyacha requested a review from laktek October 16, 2024 03:42
@nyannyacha nyannyacha force-pushed the feat-enable-private-registry branch from 773727e to baba456 Compare October 16, 2024 05:13
@nyannyacha nyannyacha force-pushed the feat-enable-private-registry branch from 862f128 to fb36a4a Compare October 16, 2024 06:05
@elyobo
Copy link

elyobo commented Oct 16, 2024

Thanks @nyannyacha 🎉

@nyannyacha
Copy link
Contributor Author

I apologize for the delay.😅 The other work is taking longer than I expected, so I decided to prioritize this.
Thanks for your patience!

@elyobo
Copy link

elyobo commented Oct 16, 2024

No need for apologies at all!

@nyannyacha nyannyacha merged commit 051a276 into supabase:main Oct 17, 2024
3 checks passed
@nyannyacha nyannyacha deleted the feat-enable-private-registry branch October 17, 2024 02:11
Copy link

🎉 This PR is included in version 1.59.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@israpasos
Copy link

@elyobo is this working for you on local? I'm running v.1.65.3 but still getting:

InvalidWorkerCreation: worker boot error: Failed resolving '@...'.
    at async UserWorker.create (ext:sb_user_workers/user_workers.js:139:15)
    at async Object.handler (file:///root/index.ts:156:22)
    at async respond (ext:sb_core_main_js/js/http.js:163:14) {
  name: "InvalidWorkerCreation"
}```

@elyobo
Copy link

elyobo commented Dec 16, 2024

@israpasos thanks for reminding me to revisit this; I had to backport some changes that I'd make locally for the specific private package code that I'd just copied in as a workaround, but after getting them sorted I have... ran into a very similar sounding issue. deno type checks and tests run as expected but the edge functions crash.

worker boot error: failed to create the graph: npm package '@my/private-package' does not exist.
    at file:///Users/elyobo/src/project/supabase/functions/_shared/auth.ts:14:8
worker boot error: failed to create the graph: npm package '@my/private-package' does not exist.
    at file:///Users/elyobo/src/uplist/supabase/functions/_shared/auth.ts:14:8
InvalidWorkerCreation: worker boot error: failed to create the graph: npm package '@my/private-package' does not exist.
    at file:///Users/elyobo/src/uplist/supabase/functions/_shared/auth.ts:14:8
    at async UserWorker.create (ext:sb_user_workers/user_workers.js:139:15)
    at async Object.handler (file:///root/index.ts:156:22)
    at async respond (ext:sb_core_main_js/js/http.js:163:14) {
  name: "InvalidWorkerCreation"

I'm running the most recent supabase

supabase --version
2.0.0

@nyannyacha
Copy link
Contributor Author

Hello @israpasos and @elyobo 😁

I think that problem is not a problem with the edge runtime itself, but a problem caused by cli.
@supabase/cli uses docker to perform deploy or serve commands, but .npmrc does not seem to be mounted.

I have confirmed that if you place .npmrc in each function folder, it is properly mounted in the docker container and the private npm registry works well.

If you have time, please open this issue with @supabase/cli.

btw, if you guys are commenting on a closed PR, I will not be able to respond quickly to your comments, so please create a new issue next time 🤗

@elyobo
Copy link

elyobo commented Dec 17, 2024

Thanks @nyannyacha, I'll check this out this afternoon and open an issue with @supabase/cli as you suggest.

@nyannyacha
Copy link
Contributor Author

@elyobo Thank you!

@elyobo
Copy link

elyobo commented Dec 17, 2024

@nyannyacha I've confirmed what you said above, it works if a valid .npmrc is copied to all function directories - I initially only copied it to the function that required the private package and the problem remained, it seems surprising to me (without the appropriate context) that all functions need to have the .npmrc and not just the one that actually uses the private package.

I'll open a @supabase/cli issue and reference this, thanks for your assistance.

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

Successfully merging this pull request may close these issues.

Private npm packages cannot be imported in edge functions: npm package '@org/package' does not exist.
4 participants