Skip to content

Conversation

conico974
Copy link
Collaborator

Remove other exports and imports (than workerd) when found in package.json. This fix an issue with build conditions order in esbuild because we use platform:node
It also fix an issue with wasm file not properly working if imported without ?module
Fix #623

Copy link

changeset-bot bot commented May 2, 2025

🦋 Changeset detected

Latest commit: 284cc98

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 May 2, 2025

Open in StackBlitz

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

commit: 284cc98

@conico974 conico974 marked this pull request as draft May 2, 2025 09:15
@conico974 conico974 marked this pull request as ready for review May 2, 2025 10:48
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks!

Great that this will enable prisma 🎉

@conico974 conico974 merged commit a169b76 into opennextjs:main May 2, 2025
7 checks passed
@lujjjh
Copy link

lujjjh commented May 4, 2025

Thanks for your contribution. While trying to use the main branch to fix the Sentry import issue (#587), I noticed that Sentry’s exports are not treated as hasBuildCondition:

https://github.com/getsentry/sentry-javascript/blob/eb495521e94f7808b26db5dc7e9c2f290fee6141/packages/nextjs/package.json#L18-L48

After checking the spec, it seems this is by design?

test("only consider leaves", () => {
const exports = {
".": "/path/to/index.js",
"./server": {
workerd: {
default: "./server.edge.js",
},
},
};
const workerd = transformBuildCondition(exports, "workerd");
expect(workerd.hasBuildCondition).toBe(false);

@vicb
Copy link
Contributor

vicb commented May 4, 2025

I think OpenNext is correct here:

getsentry/sentry-javascript@eb49552/packages/nextjs/package.json#L18-L48 has

  "exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./build/types/index.types.d.ts",
      // ...
      "workerd": {
        "import": "./build/esm/edge/index.js",
        "require": "./build/cjs/edge/index.js",
        "default": "./build/esm/edge/index.js"
      },

workerd looks to be a path here and the conditions are import, require, and default

@lujjjh
Copy link

lujjjh commented May 4, 2025

workerd looks to be a path here and the conditions are import, require, and default

After reading the nested conditions section, I believe this should be interpreted as a case of nested conditions.

And workerd cannot be a path here because:

All paths defined in the "exports" must be relative file URLs starting with ./.

Meanwhile:

In node, conditions have very few restrictions, but specifically these include: [...]
2. They cannot start with "." since they may appear in places that also allow relative paths.

@Noitidart
Copy link

I tried npm i https://pkg.pr.new/@opennextjs/cloudflare@628 but this didn't fix the issue for me.

@Noitidart
Copy link

I have shared a minimum repro here - #623 (comment)

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.

[BUG] Prisma throws Error: [unenv] fs.readdir is not implemented yet! when querying

4 participants