Skip to content

fix(build): use named Parcel target to avoid exports field conflict#421

Merged
cchanxzy merged 1 commit intomainfrom
fix/parcel-exports-target
Mar 17, 2026
Merged

fix(build): use named Parcel target to avoid exports field conflict#421
cchanxzy merged 1 commit intomainfrom
fix/parcel-exports-target

Conversation

@cchanxzy
Copy link
Copy Markdown
Owner

Fix: Parcel build failure caused by exports field in package.json

The gh-predeploy step in the release workflow fails with:

@parcel/core: Failed to resolve 'react/jsx-runtime' from './src/examples/index.tsx'
@parcel/resolver-default: file name contained an unexpected NUL byte

Parcel v2 auto-detects certain package.json fields (main, module, types, exports) as build targets. The exports field uses a nested map structure for conditional exports (ESM/CJS), which Parcel cannot interpret as a valid build target distPath. This causes module resolution to break with a NUL byte error when resolving react/jsx-runtime.

The existing targets config already disables main, module, and types with false, but exports cannot be disabled the same way because Parcel validates its value before checking the opt-out.

Solution

Defined a named Parcel target app in the targets config with the distDir and publicUrl settings that were previously passed as CLI flags. Updated both the gh-predeploy and start scripts to use --target app, which tells Parcel to build only the explicitly named target and skip auto-detection of exports.

Changes in package.json

  1. Added "app" target to targets:

    "app": {
      "distDir": "demo/examples",
      "publicUrl": "./"
    }
  2. Updated gh-predeploy script:

    - "gh-predeploy": "parcel build src/examples/index.html --dist-dir demo/examples --public-url ./",
    + "gh-predeploy": "parcel build src/examples/index.html --target app",
  3. Updated start script:

    - "start": "parcel src/examples/index.html --open",
    + "start": "parcel src/examples/index.html --target app --open",

@cchanxzy cchanxzy force-pushed the fix/parcel-exports-target branch from 03298b1 to c6f7a0e Compare March 17, 2026 08:29
@cchanxzy cchanxzy merged commit c634281 into main Mar 17, 2026
5 checks passed
@cchanxzy cchanxzy deleted the fix/parcel-exports-target branch March 17, 2026 08:33
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 4.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant