Dependency edges out of module land should be explicit, because those aren't going to work on the web, and the web matters more than node.
They should have left requiring for CJS modules and let things be crappy for a while as requires and CJS are phased out. Eventually only ESM would remain except for in some abandoned packages, which could still be required.
But now CJS is going to live forever because it's the default and ESM is opt in.
[0]: https://github.com/nodejs/node/pull/14369#issuecomment-32903...
There are trade offs to be sure, but I prefer the languages (and in this case platforms) that have batteries included.
Yes, this means that if your project depends on ten other projects, and all ten projects implement their own copy-file routine, your project will end up with ten copy-file routines.
When working on a project and you need to copy something for the first time, you shouldn't have to do:
* Ok I need to copy... What npm package does that again?
* search NPM for copy
* figure out which package is "best"
* npm i some-copy-package
* require("some-copy-packge")
* do thing
The first 4 steps should be unnecessary.fs.createReadStream('file.txt').pipe(fs.createWriteStream('new-file.txt'))
Streams are too slow you say?
fs.writeFileSync('new-file.txt', fs.readFileSync('file.txt'))
I've never had a problem with no explicit copy, but I am very happy it has been added...
In macOS libc there's a copyfile(3) function: https://developer.apple.com/legacy/library/documentation/Dar...
I read that a lot. Why do people don't like the new extensions?
Seems like the most elegant and programmatically more performant and less hassle free, solution to the issue.
Everything else looks like a terrible kludge.
Changing from js to ts is an inconvenience sufficiently big enough to adopt flowtype instead.
Probably because you'll end up with .mts, .mjsx, .mts, .mtsx.
Or mpeg transport stream:
I've chanced upon the "same extension for the same thing" as a problem maybe 2-3 times in 30+ years.
.mts is unheard of.
There's gotta be a very good reason to bog down the core with more stuff, since that equals less other stuff and more bugs. Some of the few valid reasons are ubiquity (which HTTP is, but Windows and sending files are not), or things that were impossible before (like no overhead file copy).
So, dogma?
Because copying a file fits right in any kind of "small core" -- and helps create a more dependable and usable "rich userspace" which doesn't need to reinvent the wheel 200 times for basic stuff.
FINALLY. I don;t know how long we could have come with this still being a thing you need a module for, or you have to code yourself.
Hopefully we get `fs.mkdirp` and `fs.remrf` somewhere down the line.
> Add support for ESM. This is currently behind the `--experimental-modules` flag and requires the `.mjs` extension.
I don't like the `.mjs` extension, but I understand the need for it, and I'm just glad that modules are finally here.