-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Bug report: requiring the node module is incredibly slow #1016
Comments
I dug into this just a tiny bit (and was looking at #284) and I'm wondering if there are plans to move to a more standard approach to modules? What I mean by that is that this looks like a mix of Grunt, webpack and esm (which seems unmaintained and unnecessary?). I don't even know where to start making sense of everything. I understand that this was historically a Browser-only application and has then been refactored to also support Node.js. Which explains where this is coming from. But when I'm consuming a package in Node.js, I expect it to use the built-in module system. Right now even the Node.js build relies on webpack and then at runtime it uses a module loader (esm.js), written in JavaScript. I will look into this again in the future, as I'm at least looking for a workaround to compile a Node.js version that loads in the ms range, preferably single-digit. I will report back once I'm happy with the results. |
Hello, thanks for your issue. This had prompted me to have a dig through NodeJS docs around ESM/CJS interoperability and hopefully the PR above will help improve things. As you say CyberChef was written for the web. It's written entirely in ES Modules, which are historically incompatible with CommonJS modules, Node.js's module ecosystem. Later versions of node are improving interoperability between ESM and CJS, but its not perfect. Using the Take a look at the above PR, see if it helps your cause. I would recommend trying the I'd be interested to know if this helps with your performance issues. |
@Prinzhorn based on the conversation in the PR linked above, I'm going to close this issue. Feel free to re-open it or raise more specific issues if you find any. |
Describe the bug
require('cyberchef')
takes roughly 3s to 4s. Tested on both Node.js 10 and 12. Might be much worse without a fast SSD.To Reproduce
Expected behaviour
A couple of ms
Desktop (if relevant, please complete the following information):
Screenshots
Additional context
3s might be somewhat acceptable in a long-running server process, but unfortunately it's beyond acceptable in an Electron app where startup time without cyberchef is otherwise instant.
It appears that a lot of time is spent by "esm.js". I tried compiling a wrapper script using ncc but it fails. It seems like it tries to load some of the web stuff, even if I explicitly
require('cyberchef/src/node/index.mjs')
Using
import
with--experimental-modules
doesn't make it fast at all. Edit: correction, explicitly doingimport chef from "cyberchef/src/node/index.mjs";
brings it down to like 2s.Would it be possible to compile a single bundle for node just like it's done for the web version?
The text was updated successfully, but these errors were encountered: