Cocos Creator TypeScript Build GulpUglifyError

Cocos Creator TypeScript Build GulpUglifyError
0.0 0

#1
[8828] Error: Build Failed: GulpUglifyError: unable to minify JavaScript
Caused by:     SyntaxError: Unexpected token: keyword (const)
File: /Users/.../Projects/.../project.js
Line: 619
at createError (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/lib/create-error.js:6:14)
    at apply (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/lodash/_apply.js:16:25)
    at wrapper (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/lodash/_createCurry.js:41:12)
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/lib/minify.js:54:15
    at DestroyableTransform._transform (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/composer.js:10:23)
    at DestroyableTransform.Transform._read (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/readable-stream/lib/_stream_transform.js:182:10)
    at DestroyableTransform.Transform._write (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/readable-stream/lib/_stream_transform.js:170:83)
    at doWrite (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at DestroyableTransform.Writable.write (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at Async.series.t (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/builder.js:1:3024)
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:726:13
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:52:16
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:264:21
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:44:16
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:723:17
    at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:167:37
    at Gulp.doneCallback (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/gulp-build.js:1:17321)
    at Gulp.Orchestrator.stop (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/orchestrator/index.js:150:9)

I understand that it’s the JS uglifier that finds a const (I obviously have a lot of them in my TypeScript project). Why doesn’t it first transpile the code to ES5 and then uglify it? How can I get this error all of a sudden?

I’ve tried with both Cocos Creator 1.8.0 and 1.7.2.

How can I fix this?


#2

Figured out the issue. My project included third party library that was in ES6. I guess you can only use ES5 transpiled third party libraries with CC build?