-
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
Drop some amount of corejs also the file in git tree #1772
Conversation
Reasons for doing it this way: 1. this lets us easily see what is actually included in the fina core-js build by looking at k6-shim.js. The format there is probably going to change as it is copied from the core-js repo's shim.js, but the idea will stay 2. There is no need to have the shim.min.js in the git tree as it is already in lib/rice-box.go. Maybe after the golang embed proposal is available we can switch around, but this will likely take more then a year before we don't need to support a version of golang without it 3. go generate is awesome, but in this case it has way too many things that need to happen which makes it IMO a bad fit. This plus the fact that this will not be changed regularly means it is probably better this way.
Some performance running
with
The first is ( the current ) master, 0e6c0ab is this PR and |
Comment on the still available core-js modules:
|
js/bundle_test.go
Outdated
compatibilityTestSrc := ` | ||
module.exports.default = function() {}; | ||
if ([[1,2],[3,4]].flatten()[4] == 4) { | ||
throw Error("Array.flatten doesn't work") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would never fail, no? It would always be undefined, even if flatten()
works, unless you meant [3] === 4
. Ah, nevermind, the index doesn't actually matter. :)
But this would be better checked with if (typeof Array.prototype.flatten !== 'function') ...
.
Also maybe we should use a different object to test this, since flatten
was renamed to flat
in corejs v3, and it would avoid us having to update this when we update to v3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this would be better checked with
if (typeof Array.prototype.flatten !== 'function') ....
We should have both of these. First check if it's actually a function, and fast fail if it's no, then whether the behavior is at least somewhat along the lines of what one could expect.
Also maybe we should use a different object to test this, since flatten was renamed to flat in corejs v3, and it would avoid us having to update this when we update to v3.
Array.prototype.flat
is the actual name according to the specification. We should probably use that name as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some minor suggestions.
I like that we can easily see and change what's included in corejs 👍
The idea is that we would run build.sh
manually whenever we want to upgrade, right?
js/lib/corejs-build.sh
Outdated
@@ -0,0 +1,5 @@ | |||
#!/bin/sh | |||
|
|||
npm i . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is failing for me when I run build.sh
. grunt
fails to install because of:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/grunt
npm ERR! dev grunt@"1.0.x" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer grunt@"~0.4" from [email protected]
npm ERR! node_modules/grunt-livescript
npm ERR! dev grunt-livescript@"0.6.x" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm i --force
works, but maybe there's a better workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm ... that seems to be because I don't specify a version for node and it works with mine (14.x something) while it doesn't work with 15.4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14.x is still the LTS, so as long as it works with that, I wouldn't bother. Usually, current
, contains weird kinks until it reaches lts.
Also, that's an impressive performance gain! 👏 🎉 How did you know what to remove and what to keep? Can we assure that we're not removing something a script was relying on? |
@imiric mostly the discussion here dop251/goja#180 and talking with @simskij ... a long time ago. Plus obviously going through the things in the list from core-js v2.5.1 and looking at them, the test262 also helps ;) Some of the drops might be used but also aren't standard at all ... just core-js used to (and probably still does) stuff that are still in the proposal process 🤦 - see the comments in |
#!/bin/sh | ||
|
||
npm i --force . | ||
modules="$(cat shim.js | grep ^require | sed "s|require('\./modules/||g" | sed "s/');//g" | tr "\n" ",")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, you could simplify this to:
modules="$(cat shim.js | grep ^require | sed "s|require('\./modules/||g" | sed "s/');//g" | tr "\n" ",")" | |
modules="$(sed -n "s:^require('\./modules/\(.*\)');:\1:p" shim.js | paste -sd',')" |
Also see useless use of cat
;)
Errm I messed up the quoting there so you'll need to escape it properly, but the command should work. Nevermind, it works fine with /bin/sh
, just tested it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not going to this for now, as if we remove more from the shim.js
or change its format, I will need to redo it.
For example, if we are finally left with 5-10 items I am probably just going to hard them inside the script instead of having a file with an explanation on what is what and why ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, though I don't see a reason why not to simplify this anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once @imiric's comments have been resolved. :)
Yeah, we should drop this, once it's in goja. Couldn't find any mention of it in dop251/goja#180 or by lazily searching the codebase from the GH UI.
Yeah, if we ever get into any issues because of this, we can add it back or publish an article on how to polyfill it. My bet is that it won't ever happen.
Agreed. To sum it up, with some quite minor additions to goja, we should be able to drop the core-js shim layer altogether. 🎉 |
As @simskij eluded we have agreed to drop the last two points of #1772 (comment) :
Everything else has now been implemented in goja and as such we are dropping the whole corejs in #1824, which should land in v0.31.0. And as such, I am closing this PR as it superseded. |
Reasons for doing it this way:
build by looking at k6-shim.js. The format there is probably going to
change as it is copied from the core-js repo's shim.js, but the idea
will stay
already in lib/rice-box.go. Maybe after the golang embed proposal is
available we can switch around, but this will likely take more then a
year before we don't need to support a version of golang without it
that need to happen which makes it IMO a bad fit. This plus the fact
that this will not be changed regularly means it is probably better
this way.