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

parcel build works, but parcel watch and parcel serve fail. #7083

Closed
drewolson opened this issue Oct 14, 2021 · 3 comments · Fixed by #7114
Closed

parcel build works, but parcel watch and parcel serve fail. #7083

drewolson opened this issue Oct 14, 2021 · 3 comments · Fixed by #7114

Comments

@drewolson
Copy link

🐛 bug report

I'm using parcel to build a site with an HTML entry point. It requires a javascript file generated by the PureScript compiler. This whole setup worked fine with parcel 1 and correctly builds with parcel 2:

$ npx parcel build public/index.html 
✨ Built in 3.75s

dist/index.html                  878 B    337ms
dist/favicon.6b361303.ico        318 B      9ms
dist/index.479febd2.js       662.61 KB    3.01s

However, if I try to serve or watch, I get the following error:

$ npx parcel watch public/index.html
⠙ Building index.html...
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_transforms_react-0.46.1/src/refresh/mod.rs:594:54
🚨 Build failed.

@parcel/transformer-js: index out of bounds: the len is 0 but the index is 0

  Error: index out of bounds: the len is 0 but the index is 0
  at Object.transform (/<project-path>/node_modules/@parcel/transformer-js/lib/JSTransformer.js:365:31)
  at async Transformation.runTransformer (/<project-path>/node_modules/@parcel/core/lib/Transformation.js:617:5)
  at async Transformation.runPipeline (/<project-path>/node_modules/@parcel/core/lib/Transformation.js:366:36)
  at async Transformation.runPipelines (/<project-path>/node_modules/@parcel/core/lib/Transformation.js:244:40)
  at async Transformation.run (/<project-path>/node_modules/@parcel/core/lib/Transformation.js:170:19)
  at async Child.handleRequest (/<project-path>/node_modules/@parcel/workers/lib/child.js:217:9)

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

package.json:

{
  "scripts": {
    "test": "spago -c skip test && purs-tidy check 'src/**/*.purs' 'test/**/*.purs'",
    "format": "purs-tidy format-in-place 'src/**/*.purs' 'test/**/*.purs'",
    "prod": "rm -rf dist && spago build && parcel build --no-source-maps public/index.html"
  },
  "devDependencies": {
    "parcel": "^2.0",
    "purescript": "^0.14",
    "purs-tidy": "^0.5.4",
    "react": "^17.0",
    "react-dom": "^17.0",
    "spago": "^0.20"
  }
}

🤔 Expected Behavior

parcel watch and parcel serve work, just as parcel build does.

😯 Current Behavior

parcel watch and parcel serve fail, but parcel build works.

💁 Possible Solution

Unsure.

🔦 Context

💻 Code Sample

🌍 Your Environment

$ node --version
v16.11.0
$ npm --version
8.0.0
@devongovett
Copy link
Member

Seems like possibly a bug in SWC's react refresh transform. Do you have a code sample that can reproduce this?

@drewolson
Copy link
Author

This is the simplest reproduction I could come up with https://github.com/drewolson/parcel-purescript

@mischnic
Copy link
Member

mischnic commented Oct 19, 2021

This is indeed caused by the React Refresh transform. Minimal reproduction:

createElement();

swc-project/swc#2492

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

Successfully merging a pull request may close this issue.

3 participants