Node v13.2.0+ has experimental ESM (native module) support without any kind of flag. This means that you can now do:
import { readFile } from 'fs'
However, if you try:
import { readFile } from 'fs-extra'
You get an error, because fs-extra is CJS-only. (You cannot export named exports from a CJS file) If we are going to remain a drop-in replacement for fs, we need to support this.
Discussed with @jprichardson and agreed to postpone until ESM support is no longer consider experimental in Node; due to the challenges of implementing this.
ESM will soon be lts according to the release schedule, node 14 will be released on October 20.
I think the release date got postponed to October 27.
@RyanZim @jprichardson Node 14 is now LTS. That means that esmodules are no longer experimental.
@ChocolateLoverRaj ESM is still listed experimental in the docs: https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_modules_ecmascript_modules
See also https://www.skypack.dev/view/fs-extra for hints/ideas.
(Of all the packages I have in my app, fs-extra was the only one that didn't work with snowpack dev due to what I presume is rollup/plugin-commonjs not supporting the rather dynamic require/import/export syntax.)
Node v15.3.0 makes ESM stable, so we should get on with this.
Most helpful comment
Node v15.3.0 makes ESM stable, so we should get on with this.