-
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
Node/FS wrapper for nanotar #14
Comments
For additional reference, we're talking about replacing I have a branch to replace it in Though I understand the APIs are completely different so it naturally won't be easy to migrate. |
Hi, and thanks for your interest in this project. If you have suggestions to make API of nanotar more DX friendly (without adding to it's complexity, bundle size hugely and runtime dependency) please feel free to open discussions i am certainly willing to hear them 👍🏼 Depending on runtime-specific APIs and mimicking the bigger alternatives is not a goal of this project. (otherwise we will eventually be them). What I would suggest, is that you might find it useful to make a wrapper library that adds functionalities such as file-system support by export conditions to make it a more obvious replacement for (i have some future plans re fs support but it can take time) |
From @bluwy:
|
@benmccann @bluwy Can you perhaps submit some examples (more useful, tools, libs that generate inconsistent paths). We can either export tree-shakable normalization plugins or do it built-in for some common patterns (like force-relative them). On other hard thing to handle is platform-specific types such as hard-links, which I expect fs-wrapper to handle but also nanotar should convert them from their (inconsistent) numeric format, which is in my plan. |
My tests were from installing the astro repo tarball from github, but any large-sized repos should also cause the same issue with the file names. @43081j mentioned that he's working on the fs implementation too though, maybe he has some findings to share here. |
i think we should have a we could also have an im not sure ill get time to do this myself yet, but here's the rough usage i thought: interface ExtractOptions {
fs: typeof fs; // if you want to bring your own FS API
// the various options that `tar` supports. see the man page:
// https://man7.org/linux/man-pages/man1/tar.1.html
keepOldFiles: boolean;
keepNewerFiles: boolean;
// ...
}
declare function extract(
path: string,
options?: ExtractOptions
): Promise<void>; i wouldn't expect us to implement every possible tar option though when extracting files, you should strip leading if you set |
thanks for the ideas @43081j. I believe fs-integration should be out of this lib's scope to keep it agnostic. We can make a wrapper lib that can use export conditions for platform-specific fs implementations and possibly add the additional set of options related to filesystem write behavior for |
Describe the feature
There are a group of folks from https://e18e.dev that are going around the ecosystem and swapping out heavy libraries for lighter ones. It seems like it'd be great to switch some libraries to use
nanotar
to reduce their dependencies. However, the two APIs are fairly different making it somewhat difficult to do it in a bunch of places and get people to quickly adoptnanotar
.E.g. the first instance I went to look at was
tar.extract({ file: tarball, cwd: to, strip: 1, onentry: filter_func })
and it's not super obvious how to swap it fornanotar.parseTar(data)
.A few things that might help here to accelerate that:
node
condition in theexports
map ofpackage.json
that provides some node-specific functionality to do things like reading the contents given a filenametar
. If you think it doesn't make sense to add here, a page could be added in https://github.com/es-tooling/module-replacements/tree/main/docs/modules with some detailsAdditional information
The text was updated successfully, but these errors were encountered: