avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.72k stars 1.41k forks source link

Transpile source files in the main process #577

Closed novemberborn closed 7 years ago

novemberborn commented 8 years ago

To improve startup time (#78) we could provide a framework where source files are optimistically transpiled and cached in the main process. No require hooks would be required in the test files avoiding the Babel startup penalty. Thanks @tomazzaman for the suggestion.

vadimdemedes commented 8 years ago

Am I confused or we already do this via #390?

novemberborn commented 8 years ago

390 transpiles tests files. This is suggesting infrastructure to transpile source files in the main process as well.

vadimdemedes commented 8 years ago

Yeah, but we don't transpile source files at all now. So we may start with that.

novemberborn commented 8 years ago

Yes, that's the point of this issue. We'd have to use the approach from caching-precompiler to get the compiled sources into the child processes, and we have to use glob patterns to match all potential sources before tests run so they're available synchronously.

jamestalmage commented 8 years ago

we have to use glob patterns to match all potential sources ...

Or use babel-detective which is probably more performant (the AST is being scanned already, so it should be faster than a regexp). I created it with this idea in mind.

Either way this won't do much good for dynamic requires. I did experiment with this, which could be used as a fallback for dynamic require calls.

I think a first step should be supporting transpilation of helper files (files in the test directory prefixed with _, or in test/helpers). Sources would get a different Babel transform without power-assert, so helpers seems like an easier place to start.

jamestalmage commented 8 years ago

For "non-Babel" transpilers (typescript, etc), we would have to create a plugin ecosystem. We would still need to finish up with Babel for powerAssert support.

Conceivably, users may want to chain custom transforms.

See transform-chain. It could help with all this.

novemberborn commented 7 years ago

This will be tackled through RFC 001. See the project here: https://github.com/avajs/ava/projects/1.

sliekens commented 5 years ago

@novemberborn link is dead so I'm not sure where to look

novemberborn commented 5 years ago

Yea, I pulled the RFC recently. https://github.com/avajs/ava/issues/1908 is probably the best issue to track for now.