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

Cache transformed files #189

Closed
wants to merge 1 commit into from
Closed

Conversation

floatdrop
Copy link
Contributor

I have some tests hanging with cache, but implementation will look something like this. Opening to gather suggestions.

@floatdrop floatdrop force-pushed the babel-cache branch 2 times, most recently from eb44db8 to f9ecfda Compare November 11, 2015 10:55
@@ -2,6 +2,8 @@
var resolveFrom = require('resolve-from');
var createEspowerPlugin = require('babel-plugin-espower/create');
var requireFromString = require('require-from-string');
var hasha = require('hasha');
var cache = require('cacha')('.ava/cache');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure it follows XDG?

https://github.com/sindresorhus/xdg-basedir#cache

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to need a way to include the settings for the transform in the hash as well.

Perhaps it is:

  MD5(MD5(source_file_contents) + MD5(
    ava_version + '\n' +
    settings_file_contents + '\n' +
    ...???...
  ));

How do we handle changing dependency versions? What happens when the babel-plugin-transform-runtime has a patch level bump (meaning the output of the transform may have changed some for the same input). Are we going to have to scan all the plugin version numbers and make those part of the hash? I can't think of an other way.

However we do it, we should compute the part of the hash that is consistent across the test run once (the ava_version + plugin_hash part), and pass that to the forked processes so they only need to compute the hash of the file being required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus done.

@jamestalmage you are perfectly right. Until #202 is resolved we can hash with ava version.

@sindresorhus
Copy link
Member

And I dig the module name ;)

@floatdrop floatdrop force-pushed the babel-cache branch 2 times, most recently from 94da0d0 to eb53eab Compare November 15, 2015 08:13
@jamestalmage
Copy link
Contributor

https://github.com/jamestalmage/babel-plugin-detective

It is based on Browserify's algorithm for finding dependencies.

Once we make the move to Babel 6, we can use this to precompile dependencies before ever launching the test. We will need other strategies for dynamic requires (possibly the server / client option I discussed earlier), but initially we can demand static requires if they want them transpiled (should cover 90% of use cases anyways).

@sindresorhus
Copy link
Member

Closing in favor of #352.

@floatdrop floatdrop deleted the babel-cache branch December 26, 2015 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants