Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: inline optional dependencies when bundling the server #325

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

Merged
merged 4 commits into from
Feb 3, 2025
Merged

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Feb 3, 2025

Fixes examples/e2e/pages-router

The regression was introduced in #297

Before that PR, react-dom/server.edge was patch before the bundling that happens in bundle-server.ts.

#297 marks react-dom/server.edge as external - then it is no more bundled in bundle-server.ts but it is bundled later by wrangler dev/deploy.

The issue here is that wrangler dev/deploy uses the ["workerd", "worker", "browser"] build conditions and then whatever is imported for react-dom/server.edge does not match what's expected.

The fix in this PR inline dependencies during the bundling in bundle-server.ts. We rely on the ESBuild dependency resolution. If an optional dependencies is not found, we require a throwing module. When an optional dependency is actually installed, it will be inlined during the build.

Meaning that react-dom/server.edge will be inline with the expected build condition (node)

/cc @dario-piotrowicz

Copy link

changeset-bot bot commented Feb 3, 2025

🦋 Changeset detected

Latest commit: ca4c87c

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 3, 2025

Open in Stackblitz

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

commit: ca4c87c

Copy link
Contributor

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

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

Very nice 😄

"@opennextjs/cloudflare": patch
---

fix: inline optional dependencies when bundling the server
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this changeset could use some extra info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changelog is mostly for users - I don't think we should describe too much about the implementation details.
But I can add more details to the PR description if you feel like something is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolving the convo to merge, but feel free to send your feedback and I'll update the description.
Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nono the PR description has everything

What I meant is that if I were a user and I saw: fix: inline optional dependencies when bundling the server I don't think I would understand what that means/fixes, and I would have questions such as:

  • why optional dependencies need to be inlined?
  • what does inlining mean?
  • what wasn't working before and is now?

Not a huge deal anyways (and you merged as I was writing this comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think most users do not care about the changelog and how this adapter works. They just want their app to work.
Adding too many info to the changelog might make it more difficult for users to find what they are interested in: the changes they need to do to their app after they update.

IMO

why optional dependencies need to be inlined?
what does inlining mean?
what wasn't working before and is now?

is only of interest for power users - they would know how to find the PR (from the changelog) and check the description and/or the comments in the code.

That being said, one thing I should have mentioned is how this issue manifest (i.e. the generated error).

That's my 2 cents but feel free to add an item to the weekly agenda if you think we should discuss more about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think most users do not care about the changelog and how this adapter works. They just want their app to work.
Adding too many info to the changelog might make it more difficult for users to find what they are interested in: the changes they need to do to their app after they update.

IMO

why optional dependencies need to be inlined?
what does inlining mean?
what wasn't working before and is now?

is only of interest for power users - they would know how to find the PR (from the changelog) and check the description and/or the comments in the code.

That being said, one thing I should have mentioned is how this issue manifest (i.e. the generated error).

That's my 2 cents but feel free to add an item to the weekly agenda if you think we should discuss more about that.

@vicb vicb merged commit 0892679 into main Feb 3, 2025
7 checks passed
@vicb vicb deleted the opt-dep branch February 3, 2025 10:51
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.

3 participants