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

Skip to content

refactor: Make the list of optional dependencies configurable #297

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 2 commits into from
Jan 29, 2025

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Jan 29, 2025

The second commits adds critters and react-dom/server.edge to the list of optional dependencies.

Note that I didn't re-use the comment from wrangler-deps.ts for react-dom/server.edge as it was not fully accurate. pages.runtime.prod.js does actually wrap the import in the same way as Next.js:

"./dist/server/ReactDOMServerPages.js":(e,t,r)=>{"use strict";let n;try{n=r("react-dom/server.edge")}catch(e){if("MODULE_NOT_FOUND"!==e.code&&"ERR_PACKAGE_PATH_NOT_EXPORTED"!==e.code)throw e;n=r("react-dom/server.browser")}e.exports=n}

The problem is when the package is re-exported:

e=>{"use strict";e.exports=require("react-dom/server.edge")}

This last site will be patched by the optional dependencies patch:

"react-dom/server.edge": (e2) => {
                    "use strict";
                    try {
  e2.exports = require("react-dom/server.edge");
} catch {
  throw new Error('The optional dependency "react-dom/server.edge" is not installed');
};

Verified by modifying the app-router according to the initial issue:

-    "next": "catalog:e2e",
-    "react": "catalog:e2e",
-    "react-dom": "catalog:e2e"
+    "next": "^15.0.2",
+    "react": "^18.3.1",
+    "react-dom": "^18.3.1"

Copy link

changeset-bot bot commented Jan 29, 2025

🦋 Changeset detected

Latest commit: 05ed5b0

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 Jan 29, 2025

Open in Stackblitz

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

commit: 05ed5b0

@vicb vicb merged commit 5c90521 into main Jan 29, 2025
7 checks passed
@vicb vicb deleted the opt-dep-list branch January 29, 2025 10:55
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