Skip to content
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

Broken build if a dependency's package.json uses the production export condition #430

Closed
marbemac opened this issue Dec 5, 2024 · 2 comments

Comments

@marbemac
Copy link

marbemac commented Dec 5, 2024

I believe this will affect any projects with dependencies that make use of the production conditional in their package.json exports.

I've updated one of the vinxi examples here to surface the bug: marbemac@4ff57bc

  1. switch to that commit or copy the changes
  2. pnpm i
  3. cd examples/react/ssr/basic
  4. pnpm build
  5. pnpm start - see error

In this example I've added the @zedux/react package, which uses the production conditional in their package.json exports.

Here is what the original package.json looks like:

{
  "name": "@zedux/react",
  "exports": {
    ".": {
      "import": "./dist/esm/index.js",
      "require": "./dist/cjs/index.js",
      "production": {
        "import": "./dist/zedux-react.es.min.js",
        "require": "./dist/zedux-react.umd.min.js",
        "default": "./dist/zedux-react.umd.min.js"
      },
      "default": "./dist/cjs/index.js"
    }
  }
}

And here is what it looks like in the build .output folder's node_modules:

{
  "name": "@zedux/react",
  "exports": {
    ".": {
      "import": "./dist/zedux-react.es.min.js",
      "require": "./dist/zedux-react.umd.min.js",
      "production": {
        "import": "./dist/zedux-react.es.min.js",
        "require": "./dist/zedux-react.umd.min.js",
        "default": "./dist/zedux-react.umd.min.js"
      },
      "default": "./dist/zedux-react.umd.min.js"
    }
  }
}

And only the dist/esm folder is included in the build output's node_modules, perhaps because Vinxi ignored the production conditional, and moved files over according to the "import" export? And then some other logic in vinxi (or vite/nitro) did correctly pick up the production conditional when re-writing the final package.json exports? Resulting in a mismatch.

Screenshot 2024-12-05 at 3 50 02 PM
@marbemac
Copy link
Author

marbemac commented Dec 5, 2024

Looks like it's actually an issue in nitro - I'll open over there and close this shortly.

@marbemac
Copy link
Author

marbemac commented Dec 5, 2024

Closing in favor of nitrojs/nitro#2923

@marbemac marbemac closed this as completed Dec 5, 2024
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

No branches or pull requests

1 participant