Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Error when using vueify transformation in gulp #138

Open
yugen opened this issue Oct 3, 2016 · 5 comments
Open

Error when using vueify transformation in gulp #138

yugen opened this issue Oct 3, 2016 · 5 comments

Comments

@yugen
Copy link

yugen commented Oct 3, 2016

When trying to run vueify as a transformation using gulp-browserify or running a command via gulp-shell I get the error:

17:28:42] Finished 'vueify' after 9.03 ms
/Users/jward3/tutorials/cordova/surveys/node_modules/vueify/index.js:11
    sourceMap: options._flags.debug
                             ^

TypeError: Cannot read property 'debug' of undefined
    at vueify (/Users/jward3/tutorials/cordova/surveys/node_modules/vueify/index.js:12:30)
    at /Users/jward3/tutorials/cordova/surveys/node_modules/browserify/index.js:423:43
    at makeTransform (/Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:209:21)
    at /Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:186:9
    at Deps.getTransforms (/Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:191:7)
    at Deps.readFile (/Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:164:25)
    at /Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:280:14
    at onresolve (/Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:150:14)
    at /Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:145:17
    at /Users/jward3/tutorials/cordova/surveys/node_modules/module-deps/index.js:426:39

I get the same error when I try to run the browserify command via gulp-shell

browserify -t vueify -e www/js/index.js -o www/build/main.js --debug=true

The command works when run directly on the command line.

I'm a noob to node, gulp, and vue/vueify so it's possible (likely?) that I've made some kind of mistake here.

Here's the relevant portion of my gulpfile in case that is useful:

var gulp = require('gulp'),
    browserify = require('gulp-browserify'),
    shell = require('gulp-shell');

gulp.task('js', function(){
    // attempt to bypass gulp-browserify
    // gulp.src('./www/js/index.js')
    //     .pipe(shell([
    //         'browserify -t vueify -e www/js/index.js -o www/build/main.js --debug=true'
    //     ]));

    gulp.src('components/**/*.vue',{ read: false })
        .pipe(browserify({
            debug: true,
            transform: [ 'vueify'],
        }))
        .pipe(gulp.dest('./dist/components'));
});
...
@nayzawoo
Copy link

module.exports = function() {
  var gulp = require('gulp')
  var utils = require('./utils')
  var browserify = require('gulp-browserify')
  var vueify = require('vueify')
  var babelify = require('babelify')

  gulp.task('browserify', function() {
    gulp.src([
        './client/js/backend/main.js'
      ], {base: './client/js'})
      .pipe(browserify({
        transform: [babelify, vueify],
        debug: !utils.isProduction()
      }))
      .pipe(gulp.dest('./public/js'))
    })
}

gulp browserify

[23:39:11] Using gulpfile ~/php-works/laravel-starter/gulpfile.js
[23:39:11] Starting 'browserify'...
[23:39:11] Finished 'browserify' after 14 ms
/home/nay/php-works/laravel-starter/node_modules/vueify/index.js:11
    sourceMap: options._flags.debug
                             ^

TypeError: Cannot read property 'debug' of undefined
    at vueify (/home/nay/php-works/laravel-starter/node_modules/vueify/index.js:11:30)
    at /home/nay/php-works/laravel-starter/node_modules/browserify/index.js:423:43
    at makeTransform (/home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:209:21)
    at /home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:186:9
    at Deps.getTransforms (/home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:191:7)
    at Deps.readFile (/home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:164:25)
    at /home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:280:14
    at onresolve (/home/nay/php-works/laravel-starter/node_modules/module-deps/index.js:150:14)
    at result (/home/nay/php-works/laravel-starter/node_modules/browserify/index.js:715:13)
    at /home/nay/php-works/laravel-starter/node_modules/browserify/index.js:761:9

@robbash
Copy link

robbash commented Oct 30, 2016

Same here.

Workaround without changing the index.js:

...
transform: [babelify, [{_flags: {debug: true}}, vueify]],
...

but preferably getting this fixed. Thanks!

@ryanrca
Copy link

ryanrca commented Nov 7, 2016

+3 for me.
@robbash : your workaround doesn't work in my setup. Relevant code:

 gulp.task('scripts:accepter', function () {

    var accepterBundle = browserify('resources/assets/js/accepter/accepter-app.js')
      .transform("babelify")
      .transform(vueify, {_flags: {debug: true}})
      .bundle()
      .pipe(source('accepter.js'))
      .pipe(buffer())
      .pipe(gulpif(production, uglify()))
      .pipe(gulp.dest('./public/js/curate'));

});   

Halp!

@mackerson
Copy link

@robbash Worked for me as well, thanks. I'll be +4.

thomas07vt added a commit to thomas07vt/vueify that referenced this issue Feb 23, 2017
options._flags is not always set when using browserify transformations

- version affected: "vueify": "^9.4.0"

Example of failure in gulp file

```javascript
// package.json
gulp.task('all', function() {
    process.env.NODE_ENV = 'production';
    return browserify('./source/js/all.js')
        .transform(babelify.configure({ presets: ["es2015"]}))
        .transform(vueify)
        .bundle()
        .pipe(source('./js/all.js'))
        .pipe(buffer())
        .pipe(rev())
        .pipe(gulp.dest(pub))
        .pipe(rev.manifest('./build/rev-manifest.json', {
          base: '',
          merge: true
        }))
        .pipe(gulp.dest('.'));
});

```

```bash
$ gulp all

[19:15:56] Using gulpfile ~/gulpfile.js
[19:15:56] Starting 'all'...
code/node_modules/vueify/index.js:12
    sourceMap: options._flags.debug
                             ^

TypeError: Cannot read property 'debug' of undefined
    at vueify (code/node_modules/vueify/index.js:12:30)

```
@ashep
Copy link

ashep commented Apr 18, 2017

+1

DougBeney pushed a commit to DougBeney/vueify that referenced this issue Apr 11, 2018
This fixes the error that throws "sourceMap: options._flags.debug TypeError: Cannot read property 'debug' of undefined"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants