-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Move Babel transforms to the main process. #349
Move Babel transforms to the main process. #349
Conversation
09c8308
to
2ba0686
Compare
Rebase went wrong here. |
It wasn't like that last night. |
60c0cbf
to
c738c78
Compare
"test": "xo && tap --coverage --reporter=spec --timeout=150 test/*.js", | ||
"test-win": "tap --reporter=spec --timeout=150 test/*.js", | ||
"coverage": "tap --coverage-report=lcov" | ||
"pretest": "rm -rf ./node_modules/.cache", |
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.
Use https://github.com/sindresorhus/del-cli to make it work on Windwos too.
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.
OK, I tried trash-cli
first but it fails if the directory doesn't exist. Was just about to push rimraf
, does del-cli
accept missing directories?
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.
@jamestalmage Re trash-cli
, that's a bug sindresorhus/trash#43, but no point in having the overhead of moving it to the trash, not something you'd ever care about restoring.
235e320
to
21a98a4
Compare
@sindresorhus I used |
Hmm, it seems implementing caching fixed my Windows errors. I previously saw some errors that made me suspicious the problem was in |
@jamestalmage |
OK, cool. |
There are many failing tests, but it basically works.
The latest `nyc` uses `append-transform`, which means multiple require extensions can be installed on top of the one `nyc` installs. Previous versions of nyc only allowed one additional transform before breaking. This allows us to use `require-precompiled` and users can still add `babel/register` (whenever we get those working).
`tap` automatically uploads coverage to coveralls for branches, but not PR's. That required an ugly workaround in .travis.yml to manually upload only for PR's. Since we now use `nyc` directly, and pass the the `--no-cov` flag in our `tap` commands, this is no longer a problem.
9c7072e
to
4970e6b
Compare
Does not yet handle missing `package.json`
This implements the `--no-cache` flag, but in this commit it's always set. I want to see how well `--no-cache` works on Windows...
I need to decide on a good testing strategy for this.
I have updated it to use `write-file-atomic` to avoid race conditions
OK, This is ready for review. // @vdemedes @sindresorhus |
@@ -77,7 +78,8 @@ if (cli.flags.tap) { | |||
var api = new Api(cli.input, { | |||
failFast: cli.flags.failFast, | |||
serial: cli.flags.serial, | |||
require: arrify(cli.flags.require) | |||
require: arrify(cli.flags.require), | |||
noCache: cli.flags.cache === false |
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.
noCache
=> cache
. I don't like double negatives.
.update(code, 'utf8') | ||
.update(filename || 'unknown file', 'utf8') | ||
.update(salt || '', 'utf8') | ||
.digest('hex'); |
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 could use https://github.com/sindresorhus/md5-hex now.
closed in favor of #390 |
This moves Babel transforms to the main process, and caches the transpiled results.
It uses
caching-transform
to provide caching. Expensive requires (likebabel
) are placed inside thefactory
function, whichcaching-transform
only calls when it determines it needs to transform a file.The path to each precompiled test is passed in the options object to
fork
:It uses
require-precompiled
to install a require hook that pulls the transformed file from the cache.The caching directory is used by the users
package.json
, and installing innode_modules/.cache/ava
.If the cache directory cannot be found (i.e. if they have no
package.json
), or the user provides a--no-cache
flag, pre-compilation still happens on the main thread - but results are published to a temp directory.Speedup is dramatic.
Using the
6.0.0
branch of got:ava master branch
this branch using
--no-cache
This branch with caching enabled
A couple points of interest here:
npm 2
even on your first run.npm 3
for the best performance.