Skip to content

Conversation

@nyannyacha
Copy link
Contributor

@nyannyacha nyannyacha commented Oct 28, 2025

What kind of change does this PR introduce?

Enhancement

Description

Make CLI conditionally toggle DENO_NO_PACKAGE_JSON based on what files are in each function folder.
This only applies when deploying functions locally/Docker and not using the deploy api.

Related supabase/supabase#38402
Towards FUNC-304

@nyannyacha nyannyacha requested a review from a team as a code owner October 28, 2025 07:39
@coveralls
Copy link

coveralls commented Oct 28, 2025

Pull Request Test Coverage Report for Build 19086331832

Details

  • 11 of 16 (68.75%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 54.688%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/functions/deploy/deploy.go 4 6 66.67%
internal/functions/deploy/bundle.go 7 10 70.0%
Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 19065008112: -0.01%
Covered Lines: 6398
Relevant Lines: 11699

💛 - Coveralls

[functions.{{ . }}]
enabled = true
verify_jwt = true
use_package_json = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is the right fix. Based on their example, the error seems to be caused by health function failing to import package.json on Windows.

Most likely we have a bug in path resolution that's preventing package.json at root repo directory from being volume mounted into the edge runtime container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sweatybridge Hello qiao 😄

Well.... I think their reproduction code in that link you mentioned is definitely a bug, but I believe what they reproduce is actually a different bug that seems similar to the issue they're having.

Apparently, the cli is parsing the script directly and passing it a list of the paths that should be bound from the host to pass to Docker.
That link is reproducing a bug that occurred there, but the issue that originally caused that issue was that it was automatically reading the package.json and subtly changing the way the Deno codebase resolves modules.

This is a PR for that.

@nyannyacha nyannyacha force-pushed the ny/add-use-pkg-json-flag branch from 840f37d to 13e2832 Compare October 29, 2025 11:27
@nyannyacha nyannyacha changed the title fix: introduce new flag in function section to handle DENO_NO_PACKAGE_JSON fix: toggle DENO_NO_PACKAGE_JSON conditionally Oct 29, 2025
@nyannyacha nyannyacha marked this pull request as draft October 29, 2025 11:42
@nyannyacha nyannyacha force-pushed the ny/add-use-pkg-json-flag branch 2 times, most recently from 8c43045 to d5a211c Compare November 4, 2025 02:08
@nyannyacha nyannyacha force-pushed the ny/add-use-pkg-json-flag branch from f135c39 to 27988b5 Compare November 4, 2025 21:42
@nyannyacha nyannyacha marked this pull request as ready for review November 4, 2025 23:13
}

func (b *dockerBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) (function.FunctionDeployMetadata, error) {
func (b *dockerBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, usePackageJson bool, output io.Writer) (function.FunctionDeployMetadata, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to avoid changing the Bundle method signature? This interface is part of our public package so I'd rather not break it.

If we need to pass in additional args, we can use variadic editor args for backwards compatibility.

Copy link
Contributor Author

@nyannyacha nyannyacha Nov 5, 2025

Choose a reason for hiding this comment

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

Hey @sweatybridge

I also dislike the lengthening iface signature, but I can't think of a suitable way to pass usePackageJson.
Should I define it directly as a field in the dockerBundler struct (and any struct that implements the Bundle interface)?

@nyannyacha
Copy link
Contributor Author

nyannyacha commented Nov 5, 2025

Could you guide me on how to correctly reference usePackageJson within the Bundle method?
You linked https://github.com/supabase/cli/blob/develop/pkg/config/config.go#L324
But ultimately, to use it within the Bundle method, wouldn't we need to add a variadic argument after the arg list? Is that acceptable?

I just need to be able to reference it within the Bundle, and I'd appreciate it if you could let me know any way to do that. 🥹

@sweatybridge
Copy link
Contributor

But ultimately, to use it within the Bundle method, wouldn't we need to add a variadic argument after the arg list? Is that acceptable?

Yea kinda of. Because adding variadic args is backwards compatible.

Let me think about it a bit more too.

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.

4 participants