Starting from jhipster-core version v1.2.3 JDL Studio gulp build fails with error:
events.js:160
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:1526:18)
at js_error (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:1534:11)
at parse_error (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:1647:9)
at Object.next_token [as input] (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:1912:9)
at next (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2012:25)
at eval (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2134:42)
at eval (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2073:24)
at block_ (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2353:20)
at eval (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2326:25)
at function_ (eval at <anonymous> (c:\projects\kaido-github\jdl-studio\node_modules\uglify-js\tools\node.js:22:1), <anonymous>:2331:15)
At first opened that in jhipster-core project jhipster/jhipster-core#98
Suggest a Fix
After debugging gulpfile.js with
.pipe(gulpIf('*.js', uglify().on('error', function(e){console.log(e);})))
found that error occurs in line
peg$c73 = function(head, tail) { return `${head}${tail.join('')}`; },
error is:
Unexpected character \'`\'
Seems that must add ES2015 support to JDL Studio gulpfile.js.
Googling results that Babel is suitable for that, in package.json add "gulp-babel": "6.1.2" and in gulpfile.js add babel = require('gulp-babel')
Babel can be used with babel-preset-es2015, in package.json add "babel-preset-es2015": "6.18.0" and in gulpfile.js add .pipe(babel({presets: ['es2015']})).pipe(uglify())
Babel can be used with babili like that: .pipe(babel({presets: ['babili']}))
Additional note: starting from jhipster-core version v1.2.3 JDL internal comments //..... are not parsed with pegjs_parser.js any more. These are removed before passing JDL to pegjs_parser.js. It's possible that must adapt that change separately in JDL Studio.
can you do a PR? I dont like the idea of using pre processors but if there is no choice here then I would prefer to use babel with babel-preset-es2015 (your first option)
Overview of the issue
Starting from jhipster-core version v1.2.3 JDL Studio
gulp build
fails with error:Reproduce the error
bower.json
change fromto (error occurs with versions 1.2.3 and 1.2.4)
hint: can reference to local version, for example if
jhipster-core
andjdl-studio
are cloned into same parent folder then reference is:bower install
gulp build
Related issues
At first opened that in jhipster-core project jhipster/jhipster-core#98
Suggest a Fix
After debugging
gulpfile.js
with.pipe(gulpIf('*.js', uglify().on('error', function(e){console.log(e);})))
found that error occurs in linepeg$c73 = function(head, tail) { return `${head}${tail.join('')}`; },
error is:Unexpected character \'`\'
Seems that changes from jhipster-core commit used more ES2015 features is causing this.
Seems that must add ES2015 support to JDL Studio
gulpfile.js
. Googling results that Babel is suitable for that, inpackage.json
add"gulp-babel": "6.1.2"
and ingulpfile.js
addbabel = require('gulp-babel')
package.json
add"babel-preset-es2015": "6.18.0"
and ingulpfile.js
add.pipe(babel({presets: ['es2015']})).pipe(uglify())
.pipe(babel({presets: ['babili']}))
Additional note: starting from jhipster-core version v1.2.3 JDL internal comments
//.....
are not parsed with pegjs_parser.js any more. These are removed before passing JDL to pegjs_parser.js. It's possible that must adapt that change separately in JDL Studio.