AppAuth-JS
AppAuth-JS copied to clipboard
Can logging be disabled?
Expected Behavior
Ideally it would not log steps to the console by default, or logging could be disabled. I see the IS_LOG value in the "flags" module, but it's defined as a const
and I'm not sure how I can affect that value at run time in a way to prevent logging. Thanks!
Describe the problem
Actual Behavior
Currently the library prints messages to the console as it's executing, such as:
Checking to see if there is an authorization response to be delivered.
(here)
Steps to reproduce the behavior
Invoking the library functions as demonstrated in the Electron sample application
Environment
- AppAuth-JS version: 0.3.5
- AppAuth-JS Environment (Node, Browser (UserAgent), ...): node 10.9
I will add some documentation on how this can be done.
I remember asking this a while back as well - the code can't be optimized away (due to the const IS_LOG
value) with default build configs such as with webpack4.
Even in a production build where the logging may be discarded, the code is still in the optimized bundles since it can't be detected as unused/dead code by UglifyJS2. I think when I asked before you mentioned there was a way with the "Closure compiler" but I'm still not clear on that.
Other optimization questions (sorry, I don't mean to hijack this issue) - is this package sideEffect
free? Can we add the setting to the package.json? Will the target build be able to be tree shaken properly and such (doesn't the tsc compiler target ES3 by default)? I like the idea of hybrid deployments with ES2015+ as described in this article - it's a little beyond me so excuse me if this project is already setup for it but it would be nice to see this package updated as such.
My apologies. I lost track of this. I am going to document this. Stay tuned.
Hey @tikurahul Any update on how logging could be disabled? Thanks.
I have not started on this one yet. TBH.
Will try a few things with closure compiler flags. As @someone1 said the const
on the flag is probably going to be problematic, and I am going to fix it to make it a configurable value at build time.
Whatever method is used, can you ensure it also works for those of us using Webpack + UglifyJS?
Yes. Will make sure I try that as well.
Are there any updates on this ?
Bump
For now one can manually edit node_modules/@openid/appauth/built/flags.js
file to set IS_LOG = false
and then use patch-package
to persist these changes.