Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ECMAScript 6 syntax with Visual Studio 2013

I am interested in using ECMAScript 6 features in my web application which I am developing using Visual Studio 2013. Currently the syntax does not seems to be working, How can I configure VS to make it work?

like image 301
Ammar Khan Avatar asked Jun 04 '14 10:06

Ammar Khan


People also ask

How do I enable ECMAScript 6?

You can enable experimental ECMAScript features in your browser by going to chrome://flags/#enable-javascript-harmony and enabling the JavaScript Harmony flag. For some features, you may have to use Chrome Canary with the JavaScript Harmony flag enabled.

Can I code JavaScript in Visual Studio?

You can write JavaScript or TypeScript code in Visual Studio for many application types and services.

What is JavaScript ECMAScript 6?

JavaScript ES6 (also known as ECMAScript 2015 or ECMAScript 6) is the newer version of JavaScript that was introduced in 2015. ECMAScript is the standard that JavaScript programming language uses. ECMAScript provides the specification on how JavaScript programming language should work.


2 Answers

If you have Resharper installed in your VS 2013 - from today on you can switch to using ES6:

enter image description here

like image 109
Oleksii Aza Avatar answered Oct 11 '22 03:10

Oleksii Aza


What I've done for the past few years for my VS solutions is to have the latest version of node.js installed.

From there, I whould create an _buildscripts directory with a package.json file. (NOTE: make sure to set private:true in your package.json)

With that in place I will have a prebuild.cmd (setup as a pre-build script for my project) with something similar to the following...

:CHANGE_TO_CURRENT_DIRECTORY rem Change to this batch file's drive/directory CD /D "%~dp0"  :INSTALL NODE DEPENDENCIES AND INSTALL - use call, since it's a batch/cmd file call npm install  :SET YOUR "start" SCRIPT IN package.json TO BE YOUR BUILD :   such as .... "start":"gulp" call npm start 

From here, you can setup gulp, traceur, browserify and/or another tools targeting newer javascript concepts.

I'm using git, so detecting new/updated files is far easier than with TFS, but you can script at least the checkout of your output directory for transpiled JavaScript.

You can also use something like watchify or gulp-watchify for hanling live edits (via a terminal window).

I realize this answer takes you well outside of VS's integrated tooling, there are some integrated tools, like chirpy and others that do these sorts of things, but my experience is they have be sub-par for my needs, and I've been doing more node development lately.

like image 27
Tracker1 Avatar answered Oct 11 '22 01:10

Tracker1