question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decouple eslint from debug

See original GitHub issue

The version of ESLint you are using. Latest

The problem you want to solve. Eliminate high coupling to debug

Your take on the correct solution to problem. Implement logging via a facade

Are you willing to submit a pull request to implement this change? Yes

Subject of the feature

Reduce coupling and footprint of minified file by using anylogger i.s.o debug

Problem

Currently, this library has a dependency on debug. Though that is an excellent library, this dependency has 2 major drawbacks:

  • This library is now forcing debug onto all developers that use this library (high coupling)
  • debug is 3.1kB minified and gzipped, directly adding 3.1kB to the minimum footprint of this library

Alternatives

Please have a look at anylogger. It’s a logging facade specifically designed for libraries. It achieves these goals:

  • Decouple the library from the underlying logging framework
  • Reduce the minimal bundle footprint. Anylogger is only 370 bytes.

The decoupling is achieved by only including the minimal facade to allow client code to do logging and using adapters to back that facade with an actual logging framework. The minimal footprint follows naturally from this decoupling as the bulk of the code lives in the adapter or logging library.

There are already adapters for some popular logging frameworks and more adapters can easily be created:

If this library were to switch to anylogger, you could still install debug as a dev-dependency and then require('anylogger-debug') in your tests to have your tests work exactly as they always did, with debug as the logging framework, while still decoupling it from debug for all clients.

Disclaimer: anylogger was written by me so I’m self-advertising here. However I do honestly believe it is the best solution in this situation and anylogger was written specifically to decrease coupling between libraries and logging frameworks because for any large application, devs typically end up with multiple loggers in their application because some libraries depend on debug, others on loglevel, yet others on log4js and so on. This hurts bundle size badly as we add multiple kB of logging libraries to it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Dec 11, 2020

Thanks for the discussion. We won’t be moving forward with this, so closing.

0reactions
Downloadcommented, Dec 9, 2020

@btmills Thank you, much appreciated! And yes I see why you don’t want to fix something that isn’t broken 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-debugger - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint/eslint - Gitter
I'm trying to eslint a browserifyied bundle of 6MB, and I get errors until line ~70k on 200k lines. The last error is...
Read more >
Configure Eslint and Prettier for your React project like a pro
Create react app and enter your app in the terminal. (my-app is the name of your app you can use anything you want)...
Read more >
Upgrading to a stricter ESLint config - Thibaud's blog
Updating a codebase from one ESLint config to another can be daunting ... keep track of since they are decoupled from the code...
Read more >
remix run github
Full-stack Decoupled Backend - Frontend MONOREPO. HOWTO: Debug your server-side Remix code using VSCode New in Remix v1. This will add the required...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found