-
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
Native ESM support #3456
Native ESM support #3456
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3456 +/- ##
==========================================
+ Coverage 71.92% 71.93% +0.01%
==========================================
Files 291 290 -1
Lines 21277 21336 +59
==========================================
+ Hits 15303 15349 +46
- Misses 4915 4921 +6
- Partials 1059 1066 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
a77be99
to
27973ce
Compare
2ae2678
to
64053e8
Compare
bececd4
to
f083187
Compare
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 did an initial round of review and it looks good 🚀 I left mostly minors. Great work! 💪
This is still very hackish and tries to preserve every observable behavior possible. This also specifically skips adding support for: 1. dynamic import 2. Top level await - this is possible, but will require more changes 3. anything around the internal go modules having more functionality, which will likely require breaking changes Which will be added later. Also let us concentrate on making this change as not breaking as possible.
maxSrcLenForBabelSourceMapVarName = "K6_DEBUG_SOURCEMAP_FILESIZE_LIMIT" | ||
sourceMapURLFromBabel = "k6://internal-should-not-leak/file.map" | ||
) | ||
// A Compiler compiles JavaScript source code (ES5.1 or ES6) into a sobek.Program |
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.
// A Compiler compiles JavaScript source code (ES5.1 or ES6) into a sobek.Program |
Looks like this comment is duplicated from the one below.
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 already have a branch that goes and fixes this and other comments, I would prefer to not block this PR on this.
There is going to quite a lot of cleanup either way.
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.
🚀
What?
Native support for ESM in k6
Why?
Having native ESM support both allows us to use more goja features and drops our internal babel.
This also closes a number of js-compat issues as we no longer are blocked by babel not supporting something. As well as freeing up the ability for Sobek to add support for even newer things.
The
breaking change
label is there as this both breaks oldrequire
behavior as part of #3534, but also now makes combining CommonJS and ESM syntax in one file a syntax error. The latter has been found to be a lot more common than the first, unfortunately. But there isn't any sane way to support that, and it also makes no sense to be mixed.Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)
Closes #3265