Skip to content

React Library doesn't build in watch mode #7359

@qdozaq

Description

@qdozaq

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "parcel-react-lib-repro",
  "version": "1.0.0",
  "source": "src/index.js",
  "main": "dist/main.js",
  "module": "dist/module.js",
  "scripts": {
    "watch": "parcel watch",
    "build": "parcel build"
  },
  "dependencies": {
    "@parcel/transformer-react-refresh-wrap": "2.0.1",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@parcel/packager-ts": "^2.0.1",
    "parcel": "2.0.1"
  }
}

🤔 Expected Behavior

The react library should build in watch mode

😯 Current Behavior

Throws

🚨 Build failed.

@parcel/packager-js: Asset was skipped or not found.

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:716:29)
  at /Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:820:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:819:37)
  at ScopeHoistingPackager.buildAsset (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:382:48)
  at ScopeHoistingPackager.visitAsset (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)
  at /Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:440:56
  at String.replace (<anonymous>)
  at ScopeHoistingPackager.buildAsset (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:404:19)
  at ScopeHoistingPackager.visitAsset (/Users/paul.mendoza/git/parcel-react-lib/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)

💁 Possible Solution

🔦 Context

Trying to create a react library with parcel.
yarn build works fine and as expected, but yarn watch throws the above error.

I can create a non react library (just js / ts) and it builds in watch mode just fine

💻 Code Sample

minimal reproduction repo: https://github.com/qdozaq/parcel-react-lib-repro

🌍 Your Environment

Software Version(s)
Parcel 2.0.1
Node v12.22.0
npm/Yarn yarn
Operating System mac/osx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions