Skip to content
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

Transpile source files in the main process #577

Closed
novemberborn opened this issue Feb 29, 2016 · 9 comments
Closed

Transpile source files in the main process #577

novemberborn opened this issue Feb 29, 2016 · 9 comments
Labels

Comments

@novemberborn
Copy link
Member

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.

  • --require hooks won't do, we should support plugins and wrap them like how caching-precompiler wraps Babel
  • The watcher needs to recompile changed source files before tests are rerun
  • The test worker won't know which cache misses should have been precompiled, so tests may blow up. This would probably be due to insufficient --source patterns so would require useful error messaging somehow
@vadimdemedes
Copy link
Contributor

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

@novemberborn
Copy link
Member Author

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

@vadimdemedes
Copy link
Contributor

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

@novemberborn
Copy link
Member Author

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Member Author

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

@sliekens
Copy link

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

@novemberborn
Copy link
Member Author

Yea, I pulled the RFC recently. #1908 is probably the best issue to track for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants