8000 fix: remove console.log override (#627) · designemail/nativescript-vue@226e108 · GitHub
[go: up one dir, main page]

Skip to content

Commit 226e108

Browse files
authored
fix: remove console.log override (nativescript-vue#627)
BREAKING CHANGE: Our `console.log` override using `util-inspect` has been removed due to performance concerns. If you were using `Vue.config.debug = true` to get colorful console.logs, this will no longer work. We have documented how you may add this feature back to your app if you relied on this behavior. See [CONSOLE_LOG_OVERRIDE.md](https://github.com/nativescript-vue/nativescript-vue/blob/master/CONSOLE_LOG_OVERRIDE.md) for details.
1 parent 307658d commit 226e108

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

CONSOLE_LOG_OVERRIDE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
In previous versions of `nativescript-vue` the `console.log` was overriden to bring colors to your console.
2+
It was remove to improve perfomances and reduce the size of the plugin.
3+
You can however bring it back at an application level.
4+
Keep in mind that this override should not be present in production. It could make your app slower.
5+
```
6+
npm install --save-dev util-inspect
7+
```
8+
9+
Then in your main app file
10 8000 +
```js
11+
import Vue from 'nativescript-vue'
12+
13+
if (TNS_ENV !== 'production') {
14+
const inspect require('util-inspect');
15+
const newLineRegExp = /\\n/g
16+
console.log = (function(log, inspect, Vue) {
17+
return function(...args) {
18+
return log.call(
19+
this,
20+
...Array.prototype.map.call(args, function(arg) {
21+
return inspect(arg, {
22+
depth: 2,
23+
colors: Vue.config.debug,
24+
showHidden: true
25+
}).replace(newLineRegExp, '\n')
26+
})
27+
)
28+
}
29+
})(console.log, inspect, Vue)
30+
}
31+
```

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"semver": "6.3.0",
9797
"set-value": "3.0.1",
9898
"tns-core-modules": "6.0.7",
99-
"util-inspect": "0.1.8",
10099
"vue": "2.6.10"
101100
},
102101
"jest": {

platform/nativescript/framework.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import inspect from 'util-inspect'
21
import Vue from './runtime/index'
32
import ModalPlugin from './plugins/modal-plugin'
43
import NavigatorPlugin from './plugins/navigator-plugin'
@@ -13,23 +12,6 @@ setVue(Vue)
1312
Vue.use(ModalPlugin)
1413
Vue.use(NavigatorPlugin)
1514

16-
const newLineRegExp = /\\n/g
17-
18-
console.log = (function(log, inspect, Vue) {
19-
return function(...args) {
20-
return log.call(
21-
this,
22-
...Array.prototype.map.call(args, function(arg) {
23-
return inspect(arg, {
24-
depth: 2,
25-
colors: Vue.config.debug,
26-
showHidden: true
27-
}).replace(newLineRegExp, '\n')
28-
})
29-
)
30-
}
31-
})(console.log, inspect, Vue)
32-
3315
global.__onLiveSyncCore = () => {
3416
const frame = require('@nativescript/core/ui/frame').Frame.topmost()
3517
if (frame) {

0 commit comments

Comments
 (0)
0