-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support one-to-many transforms #3
Comments
Maybe |
@sindresorhus |
It'd be nice though if we could store text data in the archive so you can still hack it a little. But at that point perhaps storing multiple files on disk is a better approach. |
And of course if we use |
I doubt What if we just use file extensions, and enforce keys to be valid extensions:
This is what we do in AVA now, but we could formalize it here.
Or just examine it. I actually do that pretty frequently when debugging AVA - just to make sure something hasn't gone haywire in a transform. |
Protections?
I'd like to remove the |
|
I like the plan, maybe change |
I assumed
I'm not sure why it should be configurable. If we're concerned about operating systems not knowing what to do with a |
If that is the case, then I don't get the appeal. We want random access to individual components. |
Sure, but you mentioned Anyway asar doesn't currently have a synchronous implementation so it'll be easier for us to lay out multiple files on disk. |
Currently transforms are one-to-one. It'd be useful if the transform implementation could return multiple values. For instance with AVA we'll want to cache static analysis of the test files.
There should also be an interface for accessing cached values, given the cache directory and the hash. Again in AVA the transform implementation writes source maps to disk, coordinating their location with the test worker which needs to read them. This could be done through
caching-transform
itself.(Source maps should still be written to disk in order to play nice with
source-map-support
, but the precompiler could do that without having to coordinate with the worker.)My proposal is to allow the
transform()
implementation to return an object. Keys can be used to access particular results, values must be strings or buffers. When called for an input that has already been cached a similar object can be returned.Currently
caching-transform
is a factory for atransform
function. We could add aget(hash, key?)
method. Without thekey
the default result (string / buffer / object) is returned. With thekey
a specific value is returned. If there is no value for thehash
orkey
,null
is returned.We could write a JSON object to disk, though that'd be tricky with binary data. It also means that getting a particular value would require the entire cache entry to be read into memory. Alternatively we could write a simple packing implementation that allows random access. (Tar would be an obvious solution, but existing implementations seem to be asynchronous, and as far as I can tell tar requires you to seek for individual files.) A final option is to write a "header" and individual results as separate files.
The text was updated successfully, but these errors were encountered: