I have written a bunch of Javascript code. I was never aware of the fact that there are multiple JS 'versions', like ES5 and ES6.
I now have this project hosted on Github, and somebody pointed out that because i'm using ES6 code, I might need to convert it to ES5 with Babel.
However, I have no idea which parts of my code use ES6. I could read all of the ES6 specifications, but is there some kind of tool/checker which marks all of the ES6 code in my project?
http://jshint.com/ or http://www.jslint.com/ - will detect ES6 specific specifications by just adding your code in the console
Add it into the Babel repl and see if it changes:
https://babeljs.io/repl/
:-) Hope that helps
Other than that it might be best to setup es6 with babel using webpack, gulp, rollup etc
So that if you write es6 or es5 it will automatically get converted and you can learn some new features on the way while still supporting es5 only browsers
Related
As you all know, now we have 100% support for ES6 in most of the browsers. I am trying to split my bundles into two ES5 and ES6 and get smaller bundle with ES6.
I tried and I was able to see 2 different bundles. But I did not see much of a difference in size. Because, Babel is trying not converting ES5 code into ES6 which is not giving much gain in the bundle size.
Is there any feature in Babel to transpile ES5 code into ES6?
How can I obfuscate my Browserify bundle.js as it is generated?
I have tried a couple of obfuscators but they are out dated and do not work anymore.
I searched and search for a solution to this problem. In the end I simply used babel to "translate" my ES6 code into ES5 and worked from there. I couldn't manage to get to enforce a newer version of webkit.
If we write script using the plain javascript syntax and use babel to compile it, Are babel able to read it and compile it to plain javascript normally, or would that cause an error ?
Babel can transpile ES6.
ES6 is a superset of ES5 (which is what I assume you mean by "plain JavaScript").
Therefore, yes it can (there just isn't much point in converting ES5 to ES5).
My one website is into requirement gathering stage. I know that JavaScript new version ES6 is introduced.
On googling, I found some good tools to work with ES6 like:-
Bable
Traceur
Is there any Nuget package available or any alternate that will convert ES6 to ES5 parallely.
or How do I get started with ES6 in ASP.Net MVC site.
I am using VS 2015 & ASP.Net(4.5.2)
You can try Webpack with visual Studio here is a useful package. Just dont forget you require the Babel module.
Can't quite figure out why I'm not getting intellisense for ES6 features in a TypeScript file.
I'm fairly certain it is related to the lib.d.ts file that is used in the typescript source files. For reference this is located in:
C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib
I noticed that the same folder contains lib.es6.d.ts. When going to definition on a method that is defined by the base interface definition files, it points you to lib.d.ts and not the es6 version. The es6 version has all of the interfaces that I need.
That said, even if I include some ES6 methods and force the task runner(which under the hood uses the typescript compiler installed), it doesn't transpile to ES5 like I expected it to.
Maybe my TypeScript compiler version is dated? Primarily I want these features:
Symbol
Array.prototype.includes
String.prototype.includes
I see these interfaces defined in the es6 typing definition file. Is there a way to get VSCode to recognize this? I'm thinking a hacky approach of just including that lib file in my project but I'm trying to avoid that and in the end it still doesn't solve my problem when I transpile to ES5 and get garbage.
Thanks and much love :)