jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.43k stars 775 forks source link

support `file://` url string path #1022

Closed jimmywarting closed 9 months ago

jimmywarting commented 10 months ago

NodeJS dose not really support file://<path> url strings, they need to be converted into URL instances first and formost to be supported.

in the lights of new ESM modules, ppl turn more towards the help of import.meta.url and also the new import.meta.resolve('./worker.js') but this two dose only return file-url-string,

not a url instance. the lack of file:// strings support in NodeJS is problematic and annoying for many developers.

it leads to unconventional inovation that makes the NodeJS creator inventing even more non standard import.meta properties that i do not think should be added.

Pushing for a import.meta property that is specific to modules loaded from disk is bad, because it discourages and prevents portability in cases where that is not warranted.

https://github.com/wintercg/proposal-common-minimum-api/issues/50

Here is a quick and dirty solution that i propose: fsURL

RyanZim commented 10 months ago

Sorry, just trying to make sure I understand correctly. You're proposing that fs-extra wraps all fs methods to provide file:// string to URL conversion?

jimmywarting commented 10 months ago

Yes

RyanZim commented 10 months ago

I don't particularly like the fact that we currently wrap fs, and I'm unsure if I want to add another complexity to that wrapper. Given that the primary source of file:// URLs is import.meta, wouldn't it make sense to instead have a library that wraps that functionality and returns URL instances?

RyanZim commented 10 months ago

Also cc @jprichardson @manidlou @JPeer264 for thoughts here.

manidlou commented 9 months ago

I agree with @RyanZim, I don't see an absolute necessity for it right now.