hughsk / disc

:chart_with_upwards_trend: Visualise the module tree of browserify project bundles and track down bloat.
http://hughsk.io/disc
Other
1.33k stars 83 forks source link

Not working with browserify+vue? #58

Open nocksock opened 7 years ago

nocksock commented 7 years ago

When I add this to my package.json to make Vue compatible with browserify:

  "browser": {
    "vue": "vue/dist/vue.common"
  },

I get this error:

/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:6268
            throw e;
            ^

Error: Line 6472: Invalid regular expression
    at throwError (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2159:21)
    at scanRegExp (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:1343:13)
    at parsePrimaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2665:43)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at trackLeftHandSideExpressionAllowCall (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5732:61)
    at parsePostfixExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2795:20)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at parseUnaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2859:16)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at parseBinaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2947:16)

This is the relevant gulp-part:

function bundle(bundler) {
    return bundler
        .on('error', gutil.log)
        .transform("babelify", {presets: ["es2015"]})
        .bundle()
        .pipe(exorcist('./assets/js/dist/bundle.js.map'))
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('assets/js/dist'))
        .pipe(browserSync.stream())
}

gulp.task('js', function (done) {
    bundle(browserify({
        entries: config.js.entry,
        fullPaths: true,
        debug: config.debug
    }));
    return done();
});

gulp.task('js:disc', function() {
    return plugins.run('discify assets/js/dist/bundle.js --open > disc.html').exec();
})

And this is the Vue-Code:

import Vue from 'vue';

const app = new Vue({
    el: '.list',
    data: {
        items: ['123', '123', '333']
    }
});

However, when I remove the first mentioned lines from package.json, disc works (but vue.js does not).