dialogflow-javascript-client icon indicating copy to clipboard operation
dialogflow-javascript-client copied to clipboard

Breaks any build process w/ UglifyJS because main export is not ES2015

Open DroopyTersen opened this issue 6 years ago • 6 comments

Most developers exclude node_modules packages from their build process (typescript or es6). Therefore if you provide an ES6 module, that ES6 is getting injected straight into the bundle as is and won't work in many browsers. It also breaks many build processes that utilize Uglify JS to minify because uglify requires ES5 code.

Typically, packages transpile to a lib folder that contains es5 code or package as an ES5 UMD module.

DroopyTersen avatar Nov 05 '17 17:11 DroopyTersen

Installed using

npm install [email protected]

DroopyTersen avatar Nov 05 '17 17:11 DroopyTersen

I am also having this issue.

The common way of supporting Typescript is to provide a typings (.d.ts) file alongside compiled es5 JavaScript. I've had to relax the settings on my Typescript compilation due to this project not adhering to the same Typescript standards. And now UglifyJs is erroring out on code from this package.

Installed using

 npm install [email protected]

EmandM avatar Nov 09 '17 22:11 EmandM

The problem is not only with UglifyJS, But with CRA and Angular, too. - #69 Actually I built my app, and fixed this for me. You can go to node_modules/api-ai-javascript/es6 and compile all files using Babel - https://babeljs.io/repl If someone want to build an app I can help. But hopefully the Dialogflow team will fix this for everyone.

radi-cho avatar Nov 11 '17 06:11 radi-cho

@radi-cho Can you please tell how exactly you complied the files , I am also having the same issue with CRA and Dialogflow team hasn't fixed it yet as there is V2 now.

athJ avatar Jun 18 '18 14:06 athJ

@athJ You can simply copy-paste the code to the babel repl and then overwrite the files in es6. Or you can use babel cli following these instructions: https://babeljs.io/docs/en/babel-cli

radi-cho avatar Jun 19 '18 18:06 radi-cho

@radi-cho Thanks but I figured it out a while after I posted that comment.What I actually did was make a copy of the module outside node_modules and then I complied the whole directory directly into the module folder inside node_modules using "-d" argument with bable-cli

athJ avatar Jun 21 '18 13:06 athJ