Node-fs-extra: Support ESM

Created on 31 Jan 2020  路  7Comments  路  Source: jprichardson/node-fs-extra

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.

enhancement meta

Most helpful comment

Node v15.3.0 makes ESM stable, so we should get on with this.

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

monolithed picture monolithed  路  5Comments

EsTharian picture EsTharian  路  3Comments

Proladon picture Proladon  路  6Comments

solutionstack picture solutionstack  路  3Comments

laurent22 picture laurent22  路  8Comments