How to use ECMAScript 6 syntax with Visual Studio 2013

后端 未结 3 1030
小鲜肉
小鲜肉 2020-12-06 04:13

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 c

相关标签:
3条回答
  • 2020-12-06 04:18

    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.

    0 讨论(0)
  • 2020-12-06 04:20

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

    enter image description here

    0 讨论(0)
  • 2020-12-06 04:22

    Seems like the best we can do is to vote for es6 support. It's strange for me but Web Essentials also doesn't povide ES6 support yet.

    As for me I've disabled syntax errors for js files in my VS. Not ideal but at least less eye distracting.

    0 讨论(0)
提交回复
热议问题