Open wbyoung opened 7 years ago
I was looking into deasync
too to solve an equivalent problem. https://github.com/gajus/babel-plugin-react-css-modules/issues/83
I'd be curious to know what are the performance implications. As you said, this is a built-time only tool, though I wouldn't like my build tool to consume 100% CPU when idle (which, correct me if I am wrong, would be the result of consumingdeasync
).
@gajus no, it wouldn't consume 100% CPU while idle. First, deasync
is a busy loop only in the sense that it while (!done)
loops, but it's running the event loop during each check, so it's actually really only busy waiting while other things are going on. Second, and more relevant to your question, this would only run when the plugin is processing an import statement — only when you're compiling your code w/ Babel.
What is blocking this PR? I hope to see this change implemented because the plugin seems unnecessarily bulky with the server-client set up.
@chrisngobanh discussion & testing really. I'm a little nervous about it because I'm not crazy about hacking at Node.js the way that deasync
is doing in order to get things working. It's not the most future-proof solution, and requires deep understanding of v8/Node.js in order to write those few little lines of C++ code.
Honestly, the fluctuations in how events work between recent versions of Node (with some focus on Promise
related features) has been decently large. Even using NaN
doesn't future-proof it because it's running the event loop manually.
Things like abbr/deasync#82 concern me as well… just having that in the dependency chain and having to ensure that the project re-builds as required for Node.js releases.
I'm just struggling with how worthwhile it'd be.
Honestly, abstracting the client/server piece into a standalone project may simplify the code base nice enough.
Thoughts?
This addresses the client-server concerns from #1 by using
deasync
to completely remove the client-server setup. I'm a little wary about howdeasync
achieves its goal, but have looked a fair amount into possible improvements including replacing use of some privateprocess
APIs. To that end, I've opened https://github.com/abbr/deasync/pull/75.This is, however, a build-only tool & should never really be used in production. So if for some reason something goes wrong because of this private API use, it's far less devastating in during a build than in production.