Closed ffremont closed 1 year ago
Hello!
Unfortunately I don't think we're going to support CommonJS anymore. It'd not only be time consuming to configure and debug (it's a pain, I've done it a lot :sweat_smile:), but at the moment it's primarily just me maintaining the majority of Buttercup.. so I don't have the time to setup dual build configurations.
That, and I honestly think it's time that we all just migrate to ESM. It's been out a long time. Yes there are teething issues (our react native project still doesn't support ESM, but we're going to find a way to use it regardless), but the more we resist it the longer CJS will be the default.
I digress, however, as you may have your own reasons for using CJS and that's fine.. but Buttercup's core libraries are primarily designed to be consumed by Buttercup's projects and as such their concerns need to come first.
V6 is of course still fine for most things, though there are known bugs for Format B as well as some merging problems (potentially) in Format A. For the most part most of our users are still on V6 so I don't think it's too risky.
Apologies for the wall of text! I don't mean to lecture - I'll be using such a response, potentially, for any other comments on our ESM-only approach. I hope you understand - it's primarily from a maintenance standpoint despite my publishing preferences.
I just checked.. doesn't oclif support ESM?
With new version 7+, it's not possible to compile with oclif with default config :
import { Credentials, FileDatasource, Vault, init } from 'buttercup';
See more details with DEBUG=* (Use
node --trace-warnings ...to show where the warning was created) (node:14304) [ERR_REQUIRE_ESM] Error Plugin: chlog [ERR_REQUIRE_ESM]: require() of ES Module node_modules/buttercup/dist/node/index.js from ..../src/features/Vault/vault.ts not supported. Instead change the require of index.js in chlog/src/features/Vault/vault.ts to a dynamic import() which is available in all CommonJS modules. module: @oclif/core@2.6.4
Can you generate commonjs dist in order to keep compatibility, in addition esmodules ? Suggestion, package.json > main or modules to export ?
For the time being, I stayed on the v6. Thanks in advance 🙏