-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Version
2.2.4
Reproduction link
joma74/vuejs-one-starter@ddae1b7
Steps to reproduce
npm run build
npm run dist-test
What is expected?
GUI is coming up
What is actually happening?
GUI is not coming up, console displays
TypeError: t.formatZeroPadded is not a function(…)
On "npm run build" webpack and it's UglifyPlugin mangles the js files. "npm run dist-test" opens a browser and should display some GUI - but can not by cause of given "TypeError: t.formatZeroPadded is not a function".
The mentioned formatZeroPadded function is a method of a self-written Mixin. formatZeroPadded is used in my App.vue template interpolation <span ... >{{ formatZeroPadded(this.projectsLength) }}.
My conclusion of the cause of this error is that the template interpolation "does not take part" in the mangleing of the js files. Next i will show the js output of the mis-mangled version. The function definition get's mangled to var r=function(t) while the template interpolation still is un-mangled t.i. still formatZeroPadded. See section the formatZeroPadded function call.
Proof 1 - if i keep_fnames in webpack.optimize.UglifyJsPlugin t.i. formatZeroPadded is not mangled and keeps defined as function formatZeroPadded, everything runs fine.
Proof 2 - if i substitute formatZeroPadded with var r in the mis-mangled js file, everything runs fine.
MIS-MANGLED VERSION
the formatZeroPadded function definition
function(t,e,n){"use strict";/* harmony export (binding) /
n.d(e,"a",function(){return r});/*
- Left pads the given number with '0'.
- @method formatZeroPadded
- @param {Number} number to format
- @param {Number} [toDigits=2] supports only positive numbers
- @return {String} formatted value
/
var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return(Array(e).fill("0").join("") t).slice(-e)}},/ 54 /
/*/
function(t,e,n){"use strict";/ harmony import /
var r=n(53),o={};o[r.a.name]=r.a,/ harmony default export /
e.a={methods:o}},/ 55 */
the formatZeroPadded function call
//
function(t,e,n){var r=n(29)(/ script /
n(52),/ template /
n(79),/ scopeId /
null,/ cssModules /
null);t.exports=r.exports},/ 79 /
//
function(t,e){t.exports={
...
staticStyle:{"vertical-align":"super"}},[t._v(t._s(t.formatZeroPadded(this.projectsLength)))])])])]),t._v(" "),n
...
/***/
function(t,e,n){n(31),t.exports=n(32)}],[81]);