Learn, Share, Build

32
October 12, 2017, at 5:25 PM

This is the part in my gulpfile:

gulp.task('compile-js', function () {
    // app.js is your main JS file with all your module inclusions
  return browserify({
    extensions: ['.js', '.jsx'],
    entries: 'javascripts/app.js',
    debug: true
  })
  .transform('babelify', { presets: ['es2015', 'react'] })
  .bundle()
  .pipe(source('bundle.min.js'))
  .pipe(buffer())
  .pipe(sourcemaps.init())
  .pipe(uglify())
  .pipe(sourcemaps.write('./maps'))
  .pipe(gulp.dest('dist'))
  .pipe(livereload())
})

in my javascripts/app.js:

I have, for an example:

async function write () {
    var txt = await read();
    console.log(txt);
  }

I get this error:

GulpUglifyError: unable to minify JavaScript

This is part of my package.json:

  "dependencies": {
    "animate.css": "^3.5.2",
    "aos": "^2.2.0",
    "autosize": "^4.0.0",
    "axios": "^0.16.2",
    "es6-docready": "^1.0.0",
    "foundation-icon-fonts": "^0.1.1",
    "foundation-sites": "^6.4.3",
    "gulp-clean-css": "^3.9.0",
    "gulp-cssimport": "^5.1.1",
    "jquery": "^3.1.1",
    "jquery-ui-bundle": "^1.12.1",
    "material-design-icons": "^3.0.1",
    "swiper": "^3.4.2",
    "vue": "^2.4.4"
  },
  "repository": {
    "type": "git",
    "url": "[git-url-of-your-project]"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babelify": "^7.3.0",
    "browserify": "^14.3.0",
    "browserify-shim": "^3.8.12",
    "gulp": "^3.9.1",
    "gulp-clean-css": "^3.0.4",
    "gulp-clone": "^1.0.0",
    "gulp-concat": "^2.6.0",
    "gulp-concat-css": "^2.3.0",
    "gulp-cssimport": "^5.0.0",
    "gulp-foreach": "^0.1.0",
    "gulp-htmlmin": "^3.0.0",
    "gulp-less": "^3.3.2",
    "gulp-livereload": "^3.8.1",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-uglify": "^2.1.2",
    "streamqueue": "^1.1.1",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0"
  },

What else should I add to my gulp process for ES6?

EDIT:

so following the babel doc for es2017:

I have installed:

npm install --save-dev babel-preset-es2017

And changed my gulpfile:

...
.transform('babelify', {
    presets: ['es2015', 'es2017', 'react'],

I don't get any error during the compilation, but I get this error on the browser console when I run my code on my browser:

Uncaught ReferenceError: regeneratorRuntime is not defined
Answer 1

Had similar issue with gulp-uglify, and as I find out it seems that minifying async/await is not supported with base gulp-uglify, so I switched to babel-minify, and it worked for me.

EDIT: For regeneratorRuntime is not defined error, I think that regenerator-runtime could be helpful.

READ ALSO
Learn, Share, Build

Learn, Share, Build

I need to make some changes to my app but only for iPhone X

22
Learn, Share, Build

Learn, Share, Build

I have a call in a method that i want to test like this:

21
Learn, Share, Build

Learn, Share, Build

How to identify which PHP script that executed the exec or shell_exec command

26
Learn, Share, Build

Learn, Share, Build

i want to compare two values in one php array but the code stops when i compare even when the conditions is true i want to know how can i compare the two values here is my code :

34