Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Upgrading to Chalk 5.0.0 results in an ESM related runtime error #68

Open
Olian04 opened this issue Feb 21, 2022 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Olian04
Copy link
Owner

Olian04 commented Feb 21, 2022

Upgrading Chalk to the next major version (v5) results in the following ES module error during runtime.

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/olian04/Documents/Projects/better-logging/node_modules/chalk/source/index.js from /home/olian04/Documents/Projects/better-logging/dist/themes/dark.js not supported.
Instead change the require of index.js in /home/olian04/Documents/Projects/better-logging/dist/themes/dark.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/olian04/Documents/Projects/better-logging/dist/themes/dark.js:7:33)
    at Object.<anonymous> (/home/olian04/Documents/Projects/better-logging/dist/lib/config.js:6:16)
    at Object.<anonymous> (/home/olian04/Documents/Projects/better-logging/dist/lib/logger.js:5:18)
    at Object.<anonymous> (/home/olian04/Documents/Projects/better-logging/dist/api.js:27:18)
    at Object.<anonymous> (/home/olian04/Documents/Projects/better-logging/test/integration-tests/custom-formatting.test.js:3:28)
    at async Promise.all (index 0)
    at async formattedImport (/home/olian04/Documents/Projects/better-logging/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
    at async Object.exports.requireOrImport (/home/olian04/Documents/Projects/better-logging/node_modules/mocha/lib/nodejs/esm-utils.js:48:32)
    at async Object.exports.loadFilesAsync (/home/olian04/Documents/Projects/better-logging/node_modules/mocha/lib/nodejs/esm-utils.js:103:20)
    at async singleRun (/home/olian04/Documents/Projects/better-logging/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/home/olian04/Documents/Projects/better-logging/node_modules/mocha/lib/cli/run.js:374:5)

@Olian04 Olian04 added the help wanted Extra attention is needed label Feb 21, 2022
@Olian04 Olian04 added the bug Something isn't working label Feb 21, 2022
@Olian04 Olian04 changed the title Upgrading to Chalk 5.0.0 results in an ESM related runtime error [Bug Report] Upgrading to Chalk 5.0.0 results in an ESM related runtime error Mar 22, 2022
@smonist
Copy link

smonist commented Jan 30, 2023

Hey, I just found your package and really like it!
My shot at this would be to use https://github.com/doowb/ansi-colors instead of chalk and see if it fits. Since this is a drop-in replacement, effort should be pretty low.

@Olian04
Copy link
Owner Author

Olian04 commented Feb 1, 2023

Hi @smonist!
Originally I wanted better-logging to be dependency free. However due to the growth of the library I started to shift my priorities away from "size" and more towards "maintainability". Because of this it seemed like a good idea to move as much logic out of the library as possible. My reasoning for picking Chalk over the alternatives was simply based on its popularity.
I'll need to take a deeper look into doowb/ansi-colors before I can make a real decision, but unless it grows in popularity dramatically or chalk drops in popularity dramatically, I'm likely to stick with chalk for the time being 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants