-
Notifications
You must be signed in to change notification settings - Fork 28
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
Very high CPU usage using pnpm #63
Comments
Hey @flayks! If no error is being thrown in the terminal, it means that the bundle should be accessible. What happens if you open CPU usage is very concerning. My initial guess is that there's potentially an infinite loop happening when parsing the files. Is there anything note-worthy or unusual in the code like circular dependencies or any big libraries that you're using? |
I made some tweaks to follow pretty much exactly what the examples are (public folder with an This way, the page loads and I have a result but the fans of my laptop are not happy about it haha "scripts": {
"dev": "cross-env NODE_ENV=development nollup -c nollup.config.js --content-base public --port 3000 --hot"
} I also changed my rollup config to minimum in order to track issues but that's pretty much the best I could do I'm afraid import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
// Rollup config
export default {
input: './src/main.js',
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].js'
},
// Plugins
plugins: [
// Javascript
resolve({
browser: true
})
]
} Terminal output: > npm run dev
> test-nollup@1.0.0 dev /Users/user/Desktop/Rollup
> cross-env NODE_ENV=development nollup -c nollup.config.js --content-base public --port 3000 --hot
Listening on http://localhost:3000
Compiled in 2ms.
Compiled in 1ms.
Compiled in 0ms.
Compiled in 1ms.
Compiled in 0ms.
Compiled in 0ms.
^C% |
Do the examples also cause the CPU to spike to 440% or just the project you're trying to use Nollup in? Would it be possible to send a minimal reproducible example that triggers the high CPU usage? |
It seems that, at least the |
I'm not seeing anything obvious that would be the culprit. As for package versions, it seems unlikely. Are there directories (excluding node_modules) that contain a huge number of files? If you replace the plugins with the ones that the example uses, does that solve the problem? |
Alright, so I did some other tests.
I don't really know what could be the issue here but there is apparently one. Maybe my node environment? I use node v13.7.0 via |
Thanks for the update! I tried to replicate by copying the example and installing Nollup from the package using Node 13.7.0, but still not able to reproduce. Dependencies should be all of their latest as well. I'm using Windows so I can't confirm if it's a Mac specific thing. I'm not sure what else it could be. Are they running in the same directory on your system both the copy and the repo? |
Hm that is strange! I do, they are both in my |
There shouldn't be any performance drop based on where it is, but it could affect chokidar potentially if there's a lot of files being watched, but it doesn't sound like that is the case if they're both in the same location. The npm package doesn't go through any compilation, and would be the same as running the code directly from the repo which makes the whole thing even weirder. Can you try comment out lines 117 to 143 in |
I think I found the bad guy, it's pnpm. I use it over I think Chokidar/some library doesn't really like that boy, it worked smoothly without CPU usage with |
That said I haven't found any issue mentioning pnpm on the Chokidar github project, so it might be something else? |
There's definitely something wrong with paulmillr/chokidar#773 Can you try this change directly in your node_modules in the dev middleware:
|
Yoohoo! I think we have a winner here 🎉 I still have some issues with BrowserSync but this is something else 🙈 WebSocket connection to 'ws://localhost:3000/__hmr' failed: Connection closed before receiving a handshake response
> (anonymous) | @ | main.[hash].js:174
> (anonymous) | @ | main.[hash].js:316
> (anonymous) | @ | main.[hash].js:322 const nollup = process.env.NOLLUP
const port = (process.argv[process.argv.indexOf('--port') + 1]) || 3000
...
// BrowerSync
nollup && browsersync({
port: 3000,
proxy: 'http://localhost:' + port,
open: false,
notify: false
}), |
Thanks for testing! I'll have a look into this in more detail later this evening, just to make sure there's no consequences in terms of general performance and no oversights that might break compatibility with existing projects. Not sure I understand why browsersync is being used. That could cause a conflict because Nollup is already running a web server. Is there a use case I'm missing? |
You're welcome, thanks for your ideas! It's purely to get some sync of style, navigation and scroll on all my devices (mobile, tablet, desktop) when developing for responsive and stuff, it's very handy. I used to have it along the webpack-dev-server and worked like a charm. |
Ah I see, first I'm hearing about it. 😅 Sounds interesting! From your config, it looks like they're running on the same port? |
It is very cool yea. No actually, I run nollup on port 3100 (3000 by default), and then proxy that server on the BrowerSync one. I'd say it's more of a proxy issue maybe? But could be related to nollup, no idea. |
Okay, this sounds like fixing the issue with BrowserSync (so def not nollup related): // BrowserSync
nollup && browsersync({
port: bsPort,
proxy: {
target: 'http://localhost:' + port,
ws: true
},
open: false,
notify: false
}), |
Great! I should hopefully have a fix for the first issue by tomorrow. :) |
Released |
Looks good to me! Thanks for the fix. |
Maybe I've done something wrong but even with the dumbest config ever I feel like I have an error while running nollup in order to get HMR working for my CSS and Javascript.
I always get this output in the terminal whatever config I'm using (tried many, from some other repos, etc). The only way for me to get it working is by using the examples as it from the
examples
folder of this repo, which calls the cli from a javascript file. When I try to use thenollup -c
command, that's when issues are coming by.Also the
node
process in my Activity monitor goes off the roof with at least 300% CPU.This is my
package.json
and my
rollup.config.js
Am I missing something ? 🤪
The text was updated successfully, but these errors were encountered: