Skip to content

Move debug to devDependencies #125

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

Closed

Conversation

kylekatarnls
Copy link

debug code should not be loaded in production builds

@CacheControl
Copy link
Owner

@kylekatarnls the original intention of including debug was to allow consumers to turn on debugging and understand why their rules were being processed in a particular way. It gives insight into what is going on under the hood, and makes the rules engine less of a "black box". See README.

That said, I'm definitely open to hear more about why you targeted this specifically and felt strongly enough to open a PR - do let me know your perspective!

@kylekatarnls
Copy link
Author

kylekatarnls commented Apr 23, 2019

debug goes into our production vendor script. First it's dead code (until you enable the debugging) and so wasted bandwidth, second, debug^4 introduces const, it's no longer es2015 compatible, so it will need to be proceeded with babel or something else to be compatible again.

In our case, the consequence of this update was simple: our webpack production build just started to fail (during the uglification step) and it was a lot of pain to find out which sub-sub-sub-dependency introduced the const keyword. So we also discovered debug package embed a lot of code we don't need in our production package.

@CacheControl
Copy link
Owner

@kylekatarnls I hear you, and this is not the first time debug has caused transpiling issues. @knalbandianbrightgrove was dealing with a similar issue.

Let me think on this for a few hours.

@hartzis
Copy link
Contributor

hartzis commented Apr 23, 2019

what about putting it behind a NODE_ENV === 'production' check?

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./cjs/react-art.production.min.js');
} else {
  module.exports = require('./cjs/react-art.development.js');
}

https://github.com/facebook/react/blob/master/packages/react-art/npm/index.js#L3-L7

@hartzis
Copy link
Contributor

hartzis commented Apr 25, 2019

💡 should/could also bump "selectn": "^1.1.2" to 1.2.0 which removed debug from that dep too.

https://github.com/wilmoore/selectn.js/blob/master/changelog.md

@knalbandianbrightgrove
Copy link
Contributor

@CacheControl finally :) thank you

@CacheControl
Copy link
Owner

Thanks for your patience. I've decided to remove this dependency altogether in #130; the pain it is creating has exceeded the value it provides. The DEBUG=json-rules-engine feature remains, albeit as a vanilla, less colorful implementation that uses console.log()

This has been published in v2.3.5

@hartzis thanks for identifying the additional sub-dependency of debug@2.6.X through selectn. Unfortunately it looks like selectn@1.2.0 was never published to npm. Luckily, debug 2.X works well with transpilers (it was v3 or v4 when issues started being reported), so we should be good. cc @wilmoore - not sure if publishing the latest selectn to npm was an oversight or intentional (also hi!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants