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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel library setup not working in Lerna package #7496

Closed
diego-hourly opened this issue Dec 29, 2021 · 5 comments
Closed

Parcel library setup not working in Lerna package #7496

diego-hourly opened this issue Dec 29, 2021 · 5 comments

Comments

@diego-hourly
Copy link

diego-hourly commented Dec 29, 2021

馃悰 bug report

I'm setting up a parcel library for a react component by using https://parceljs.org/getting-started/library/ and exporting a simple component in a Lerna monorepo (here is a sample repo). But got this error.

> parcel watch

馃毃 Build failed.

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

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution

馃帥 Configuration (.babelrc, package.json, cli command)

package.json

{
  "name": "poc",
  "private": true,
  "devDependencies": {
    "lerna": "^4.0.0"
  },
  "scripts": {
    "start:common": "lerna exec --scope @poc/common -- npm start",
    "start:client": "lerna exec --scope @poc/client -- npm start",
    "build": "lerna exec -- npm run build",
    "postinstall": "lerna clean -y && lerna bootstrap"
  }
}

packages/commons/package.json:

{
  "name": "@poc/common",
  "version": "1.0.0",
  "source": "src/index.js",
  "main": "dist/main.js",
  "scripts": {
    "start": "parcel watch",
    "build": "parcel build"
  },
  "dependencies": {
    "@parcel/transformer-react-refresh-wrap": "^2.0.1",
    "parcel": "^2.0.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

packages/client/package.json

{
  "name": "@poc/client",
  "version": "1.0.0",
  "dependencies": {
    "@poc/common": "1.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devDependencies": {
    "react-scripts": "5.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build"
  }
}

NOTE: not sure why is @parcel/transformer-react-refresh-wrap required but if not included in dependencies section the cli throws an error

NOTE 2: running npm run build works like a charm

cli command

First install dependencies and then

start:common # which is basically parcel watch

馃 Expected Behavior

The app should watch and compile the source code

馃槸 Current Behavior

CLI throws this error:

> parcel watch

馃毃 Build failed.

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

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution
  (/Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:716:29)
  at /Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:820:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude
  (/Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:819:37)
  at ScopeHoistingPackager.buildAsset
  (/Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:382:48)
  at ScopeHoistingPackager.visitAsset
  (/Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)
  at /Users/diegotoro/code/poc-parcel/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:153:40
  at /Users/diegotoro/code/poc-parcel/node_modules/@parcel/graph/lib/Graph.js:520:16
  at /Users/diegotoro/code/poc-parcel/node_modules/@parcel/graph/lib/Graph.js:520:16
  at /Users/diegotoro/code/poc-parcel/node_modules/@parcel/graph/lib/Graph.js:520:16

馃拋 Possible Solution

馃敠 Context

Trying to create a common package in a Lerna monorepo.

馃捇 Code Sample

Here I created a simple sample of the setup I have.

https://github.com/diego-toro/poc-monorepo-parcel

馃實 Your Environment

Software Version(s)
Parcel 2.0.1
Node v14.18.2
npm 6.14.15
Operating System MacOS 11.6.1
@diego-hourly diego-hourly changed the title Parcel library setup not transpiling JSX on watch mode Parcel library setup not working in Lerna package Dec 29, 2021
@overtone1000
Copy link

overtone1000 commented Jan 22, 2022

I'm also seeing this error with a web app after I migrated react from v16 to v17 and material-ui from v4 to v5. parcel watch worked prior to this migration but now yields very similar error output to what you report.

> parcel watch ./src/*.html --dist-dir ../../backend/static --cache-dir ../build/cache --target browser

Debugger attached.
Debugger attached.
Debugger attached.
馃毃 Build failed.

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

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:732:29)
  at /home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:836:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:835:37)
  at ScopeHoistingPackager.buildAsset (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:398:48)
  at ScopeHoistingPackager.visitAsset (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:357:17)
  at /home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:456:56
  at String.replace (<anonymous>)
  at ScopeHoistingPackager.buildAsset (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:420:19)
  at ScopeHoistingPackager.visitAsset (/home/tyler/repos/AutoScheda/SourceCode/frontend/v3/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:357:17)

parcel build also works fine for me. I'm not using the lerna package.

Software Version(s)
Parcel 2.2.1
Node 14.16.1
npm 8.3.1
Operating System Ubuntu 20.10
react 17.0.2
@mui/material 5.3.0

I haven't been able to narrow it down to a single component yet. The react version is the only thing we seem to have in common.

lettertwo added a commit that referenced this issue Apr 6, 2022
For library targets:
  - Skips applying refresh transforms in JSTransformer
  - Skips applying ReactRefreshRuntime
  - Skips applying transforms in ReactRefreshWrapTransformer
  - Adds test asserting that runtime and transforms are not applied

Fixes #7359, #7496, #7652, #7900
See also: #6892
devongovett pushed a commit that referenced this issue Apr 7, 2022
For library targets:
  - Skips applying refresh transforms in JSTransformer
  - Skips applying ReactRefreshRuntime
  - Skips applying transforms in ReactRefreshWrapTransformer
  - Adds test asserting that runtime and transforms are not applied

Fixes #7359, #7496, #7652, #7900
See also: #6892

Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
@lettertwo
Copy link
Member

#7914 should resolve this.

@overtone1000
Copy link

@diego-hourly, did this fix work for you? My build target is browser, and I still see this error after upgrading to v2.4.1.

@lettertwo
Copy link
Member

@overtone1000 the fix will be in the next release. You could try installing parcel@nightly if you want to try it before then.

@overtone1000
Copy link

馃悜 Apologies, I mistakenly thought #7914 was merged into the latest release. Indeed, parcel version 2.0.0-nightly.1041 successfully builds this project with the parcel watch command. I'm seeing a "redeclaration of let _" error in the web console that doesn't occur when I build using the parcel build command. I'll test this again with the next release version.

Many thanks!

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

3 participants