JavaScript stub for a native console object. Checks if there is a native window.console or console object and if not, assigns an object with empty functions to it. The module returns whatever is set to window.console (native object or stub). Useful to silence possible errors that might happen on different environments (where global window.console object is not available).
npm install glide-console-adapter --save
Minimal configuration for RequireJS is needed. RequireJS paths
config variable
has to include property console-adapter
with given path to script.
Following code should be used in development and build.
require.config({
paths: {
'console-adapter': 'node_modules/glide-console-adapter/adapter'
}
});
define([
'console-adapter'
], function (console) {
console.log('abc');
});
define([
'console-adapter'
], function () {
window.console.log('abc');
});