jprichardson / node-fs-extra

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

Regression in 10.0.1: `copySync` is nolonger accessible in ESM mode #943

Closed akphi closed 2 years ago

akphi commented 2 years ago

I think the change in https://github.com/jprichardson/node-fs-extra/pull/922 broke the importing of copySync in ESM mode a bit. The error is below

import { mkdirs, copySync } from 'fs-extra';
                 ^^^^^^^^
SyntaxError: Named export 'copySync' not found. The requested module 'fs-extra' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'fs-extra';
const { mkdirs, copySync } = pkg;

This did not happen in 10.0.0.

akphi commented 2 years ago

@RyanZim Reading https://github.com/jprichardson/node-fs-extra/issues/746 and it seems like I was lucky to be able to use fs-extra in this ESM-like fashion so far... Let me know what you think, I'm happy to close this if you confirm this is totally by accident and we should avoid using this ESM-like approach till #746 is resolved. Thanks!

RyanZim commented 2 years ago

Yeah, we've never supported ESM; I surprised that ever worked.