-
Notifications
You must be signed in to change notification settings - Fork 1.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
Transforming libraries takes a long time #212
Comments
Yeah... I wanted to give another compiler a shot, but I think we may be hitting the limit of what goja can do here. Maybe we could cache compiled scripts somehow...? |
Definitively cache compiled scripts. 3 minutes is already there borderline. Add a couple of them and you can quickly get 15 minutes of startup time just waiting for your 30 second test to run... |
@liclac Random thoughts on this issue. I find Based on the output, it looks the Babel compilation takes a lot of time when including a large library. I have only a basic idea about |
After a conversation with @liclac, we came to the conclusion that we could support a different API for ES5 modules.
|
That's not a conclusion as much as it is one possible way to solve it. I don't like it, because it means you need to know if the file you're importing is written in ES5 or ES6. |
With proper documentation, I don't find having two syntaxes for the different type of modules to be a big issue. This may not be the ideal solution, but it solves this problem at this moment. Later when we found a better way, we can deprecate the ES5 require API and migrate to |
Here's a wild idea: what if we tried parsing the file as ES5, then if there are syntax errors, we run Babel on it and try again. |
And... it works! Anything that isn't valid ES5 is now run through Babel and retried. Negligible slowdown for ES6 sources, near-instant loading of arbitrarily large ES5 modules. |
@liclac 👏 🥇 Looking forward testing it |
@liclac I tested it, and this works perfectly. Please, could you build a new release including this fix? After the new release, I will upgrade the Modules doc and promote it again aiming to find new feature testers. |
So, am I right to say k6 supports both ES5 and ES6, but ES5 will compile much faster as it wont need to go through the Babel transpiler and now is a second option? |
No, this is purely a performance increase when loading third-party libraries. ES6 is compiled down to ES5 under the hood, but we don't support writing scripts in ES5 directly and do not guarantee API stability for anything but ES6. |
this behavior is not mentioned in docs. after reading this issue, I manually transform it to es5 and got good result. |
Transforming a library takes a long time; making the development flow when using libraries to become unproductive.
Running k6 in verbose mode shows the following result:
The text was updated successfully, but these errors were encountered: