-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🏗 Replace browserify
in tests with esbuild
#32891
Conversation
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 pushed a few fixes.
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.
Looks great ⭐
All green! Ready for full review from @jridgewell, @samouri, @erwinmombay. |
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.
First round of comments, stil working through the last few files
|
||
if (argv.coverage) { | ||
config.reporters.push('coverage-istanbul'); | ||
const isJsGlob = (glob) => typeof glob === 'string' && glob.endsWith('.js'); |
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 dependent on us using .js
as the only ending token, but any change to use more advanced globby features could break that. Eg, future support for TS and changing the glob to .{js,ts}
. I'd rather this be explicit about fixing esbuild generation by looking for keys with values of ['esbuild', ...]
.
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.
Maintaining two lists, one for which files to include in the Karma server, and one for which files to run transforms on is unnecessary, because we transform every JS file with esbuild
(that was the original intent). However, I see your point that not every JS glob must end with JS. One way to deal with this is to expand all the globs before processing. Will do this.
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.
Aha, I now see why we needed two lists. There are JS files in examples/
that shouldn't be transformed. I stand corrected. I've modified the logic to expand globs, but still automatically detect which files we want to transform with esbuild
and which ones we don't. Lemme know what you think.
Edit: That didn't work because expanding the globs and passing them in to Karma has bad side effects. And the previous hacky version was brilliant reverse engineering, but was very hard to read / maintain, so I'd like to avoid it if possible. What if we just make it a requirement (via a comment) that Karma globs use extension-specific tokens? So if you want 'foo/bar/**/*.{js,ts}'
, you must specify 'foo/bar/**/*.js', 'foo/bar/**/*.ts'
. It will greatly simplify the transform logic, and we can expand it in future to perform different transforms for different extensions.
@jridgewell This needs one last look from you to decide how we should handle #32891 (comment). |
karma-esbuild creates a new binary for **every** file, whereas karma-browserify collects all tests into a single binary. Our tests depend on this behavior, so we must collect all of the esbuild-files, create a single target to import all of them, and feed that file to esbuild.
Co-authored-by: Justin Ridgewell <[email protected]>
This reverts commit d495489.
This reverts commit b819b34.
I believe we lost cache invalidation in this PR, since it is only path based. I.e. it breaks watch mode for gulp dev server. Fix incoming as part of #32744 |
This is another in a series of PRs that modernize our development tasks.
PR highlights:
karma-browserify
withkarma-esbuild
for test transformsbrowserify
andbabelify
in tests withesbuild
andbabel
babelify
,browserify
,browserify-persist-fs
,karma-browserify
frompackage.json
--new_server
flag and always build transforms before server start upesbuild
transforms for JS files in one go on a unified JS test filetest-3p.js
(because Karma now serves the unified file instead of individual test files)import
instead ofrequire
global
object with its platform-specific equivalentesbuild
output to ES5 on Windows so tests can run on IE 11browserify
cache (to be replaced later by one foresbuild
)karma.conf.js
and move dynamic config toruntime-test-base.js
esbuild
config computation for all tasks into one helper functionintegration.js
await
calls to racy test status reportingthird_party/
that were usingbrowserify
, etc. to invoke vianpx
Partial fix for #32585