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 hangs and uses 100% CPU #1631

Closed
lachenmayer opened this issue Jun 27, 2018 · 5 comments
Closed

Parcel hangs and uses 100% CPU #1631

lachenmayer opened this issue Jun 27, 2018 · 5 comments

Comments

@lachenmayer
Copy link

lachenmayer commented Jun 27, 2018

🐛 bug report

Hi there, I'm trying to use Parcel to build a simple website. When I add the nanocomponent package to my dependencies and try to require it, parcel hangs and uses 100% CPU instead of building. When I remove this dependency, everything works fine. Please check out the repro here: https://github.com/lachenmayer/parcel-bundler-hang-repro

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

  • No babelrc.
{
  "name": "parcel-bundler-hang-repro",
  "main": "index.js",
  "scripts": {
    "start": "parcel --no-cache index.html"
  },
  "dependencies": {
    "nanocomponent": "^6.5.2",
    "parcel-bundler": "^1.9.3"
  }
}

🤔 Expected Behavior

  • Parcel bundles the project, serves it at localhost:1234
  • When you open it in a browser, it prints "it works" and the contents of nanocomponent.

😯 Current Behavior

Parcel hangs:

$ yarn start
yarn run v1.6.0
(node:5033) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ parcel --no-cache index.html
Server running at http://localhost:1234 
⏳  Building events.js...

💁 Possible Solution

I am aware of #1331 and #637 which seem similar.

I have tried downgrading Parcel to 1.7.1, but that did not help.

💻 Code Sample

https://github.com/lachenmayer/parcel-bundler-hang-repro

🌍 Your Environment

Software Version(s)
Parcel 1.9.3
Node 10.5.0
Yarn 1.6.0
Operating System macOS 10.12.6

Thanks a lot, Parcel is awesome!

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jun 27, 2018

I've tried out the reproducable repo and I can confirm this bug, not sure what is causing it yet though.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jun 27, 2018

For some reason this line resolves to index.js, I'll dig deeper into why this is happening and try to find a fix

var onload = require('on-load'); // resolves to /index.js

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jun 27, 2018

So I've found the bug and I'm not sure it should be fixed.

So the package on-load has an implicit relative path in it's browser field in pkg.json. We could check if it has an extension and treat those as files. Although this would give issues as some packages end with .js... So I suggest you open up an issue with the maintainer asking for a more explicit relative path as explained below.

This:

"browser": {
    "assert": "nanoassert",
    "./server.js": "index.js"
  }

Should be this:

"browser": {
    "assert": "nanoassert",
    "./server.js": "./index.js"
  }

We could also change Resolver.getAlias to handle this behaviour but like explained above, this could cause other issues for packages that end with a known extension in their name (for example something.js). So I think it's best to leave it up to the package maintainers to properly use explicit filenames in package.json

DeMoorJasper added a commit to DeMoorJasper/on-load that referenced this issue Jun 27, 2018
Related to an issue encountered, by a user of parcel: parcel-bundler/parcel#1631
@DeMoorJasper
Copy link
Member

I've opened up a PR in the pkg.

@lachenmayer
Copy link
Author

Thanks so much for your speedy response and for opening the PR, much appreciated!

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

No branches or pull requests

2 participants