-
Notifications
You must be signed in to change notification settings - Fork 53
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 Browser out of the box #97
Labels
Comments
This was planned but never got around to adding it. If someone can take it up, it should be a relatively simple change. |
thecodrr
added
help wanted
Extra attention is needed
good first issue
Good for newcomers
labels
Jul 11, 2024
I've been desperately trying to get on this but I can't for the life of me find the time for it, summer's been a little crazy for me. Just FYI for transparency, it might be best if someone else pick this up😅 sorry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I'm looking to perhaps migrate from glob to fdir and one big blocker for me is that glob allows you to inject a custom "fs" implementation like so:
It would be cool if the node builtin modules could be optionally substituted, e.g.
path-unified
is an NPM package which is just anode:path
clone that works in the browser out of the box, andmemfs
would be a goodnode:fs
replacement.The path replacement is basically always a good idea because that module has no reason not to work in a browser env, the fs module is slightly harder because browser doesn't have filesystem access by default, you either need to use an in-memory replacement or an adapter which makes it interact with the browser's filesystem access API (bit more complicated). memfs allows doing both, fortunately.
You can use package entrypoints for example to internally do this in your package:
using:
so when not in a Node env, this lib would require the user to pass "fs" as an option to any fdir calls, similar to how you do it in glob, since there isn't a default fallback. You could also set a default fallback ->
memfs
instead of "empty variable", up to you.If you're at all interested in this approach to make this lib work in browser out of the box without any bundler shenanigans, I'd be happy to investigate this and open a PR
The text was updated successfully, but these errors were encountered: