rc-config-loader icon indicating copy to clipboard operation
rc-config-loader copied to clipboard

Support ESM `"module":true` projects

Open josh-hemphill opened this issue 3 years ago • 1 comments

When loading *rc.js files that contain export const or export default results in failing with errors.

josh-hemphill avatar Dec 21 '22 20:12 josh-hemphill

rc-config-loader treat JS as CommonJS. https://github.com/azu/rc-config-loader/blob/c4e335c2c02d347ef06f8cde9eb6efd216c0537a/src/rc-config-loader.ts#L171-L172C16

I have a feeling that if JS is to be treated as an ECMAScript Module, Dynamic Import will probably be required. It means that require Async API. Also, It looks like VM APIs require async api.

Seems difficult to support right away. rc-config-loader aim to get Sync APIs.

FYI: cosmiconfig will support ESM. https://github.com/davidtheclark/cosmiconfig/pull/283

azu avatar Dec 22 '22 04:12 azu