jhipster / jdl-studio

JDL Studio is an online JHipster Domain Language visual editor
https://start.jhipster.tech/jdl-studio/
Apache License 2.0
405 stars 114 forks source link

gulp build starting from jhipster-core V1.2.3 fails #27

Closed kaidohallik closed 7 years ago

kaidohallik commented 7 years ago

Overview of the issue

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)

Reproduce the error

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 line peg$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, in package.json add "gulp-babel": "6.1.2" and in gulpfile.js add babel = require('gulp-babel')

  1. 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())
  2. 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.

deepu105 commented 7 years ago

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)