dialogflow-javascript-client
dialogflow-javascript-client copied to clipboard
Breaks any build process w/ UglifyJS because main export is not ES2015
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.
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]
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 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 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 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