Performance improvement: avoid useless call to esbuild to re-transpile TS files #3636
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, thank you for developping & maintaining this great tool 👍
Description
I'm using
artilleryin a TypeScript projet, and I noticed repeated log lines like this:I checked the source code in
prepare-test-execution-plan.jsand realized that repeated transpilation of the same TS file where occuring.First, a function named
transpileTypeScript()has been introduced at some point, and it could be used inreplaceProcessorIfTypescript()to avoid repeating code, so this light refactoring is included in this PR.Second and more importantly, given that
transpileTypeScript()is already called beforehand inprepareTestExecutionPlan()at the beggining of a test execution, invoking it again inreplaceProcessorIfTypescript()does not seem necessery.In this MR I added a test so that the transpiling step is skipped if the JS output file already exists in the
dist/directory.But maybe this transpiling step is simply never needed, you probably know better than me 🙂
Anyway, this PR provides a very substantial performance improvement when using
artillerywith TS hooks.Pre-merge checklist
This is for use by the Artillery team. Please leave this in if you're contributing to Artillery.