Skip to content

feat: custom worker entrypoint #397

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

Closed

Conversation

imconnorngl
Copy link

We've recently attempted to adopt OpenNext to run some of our applications but have struggled to do so due to it lacking a feature which exists on Next On Pages.

This PR attempts to implement this through the use of a option which allows the user to provide an entrypoint to use in favour of the templated entrypoint (opennextjs-cloudflare --customWorkerEntrypoint=./entrypoint.ts).

We're currently using this through a fork for our application.

Copy link

changeset-bot bot commented Feb 19, 2025

🦋 Changeset detected

Latest commit: 4dbb13d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Feb 19, 2025

Open in Stackblitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@397

commit: 4dbb13d

@vicb
Copy link
Contributor

vicb commented Feb 20, 2025

We've recently attempted to adopt OpenNext to run some of our applications but have struggled to do so due to it lacking a feature which exists on Next On Pages.

This PR attempts to implement this through the use of a option which allows the user to provide an entrypoint to use in favour of the templated entrypoint (opennextjs-cloudflare --customWorkerEntrypoint=./entrypoint.ts).

We're currently using this through a fork for our application.

Thanks for the PR!

It's probably a bit early in the lifecycle of the project to consider merging this now.

Few comments:

  • I'm not sure if ON should compile user code (vs wrangler) - maybe it should only expose a documented request handler
  • We probably don't want to add more CLI options but rather remove them as we plan to merge with the aws adapter - additional options should go to the open next config file.

Maybe the simplest for now is to start from the generated .open-next/worker.js (or source worker.ts), copy edit the file somewhere in your project - you will need to adjust the relative paths. Then you can point your wrangler config (`wrangler.json') to that file.

You should think about checking the diffs in worker.js/ts when updating to a new version. Things will probably change there before 1.0.

I hope this helps

@vicb vicb marked this pull request as draft February 20, 2025 08:18
@vicb
Copy link
Contributor

vicb commented Apr 16, 2025

See #591

@vicb vicb closed this Apr 16, 2025
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.

2 participants