Last post Dec 29, 2017 03:04 PM by USSKipper
Dec 27, 2017 03:25 AM|USSKipper|LINK
I am using VS 2017 Professional and would like to add ES6 Classes to an existing MVC project. From what I have read, VS 2017 is supposed to run these without the need for any addons or config files. And this does hold true if a create brand new project,
but not with any of the existing projects I have tried.
http://localhost:62343/Scripts/test.js\n\nSCRIPT1002: Syntax error.
This also happens with other code samples I have found on the web. My guess is that I am missing a nuget package or something, but am having difficulity figuring out what it is.
Can someone help point me in the right direction?
Dec 28, 2017 09:32 AM|Eric Du|LINK
According to your description, please check the following tutorial about enable it:
SETTING UP AN ES6 ENVIRONMENT FOR ASP.NET MVC 5:
About the detailed error message, i think you could check it in the Browser-F12-Console Panel.
Dec 28, 2017 05:35 PM|bruce (sqlwork.com)|LINK
while VS2017 can edit ES6 (actually its treats its typescript), it does not transpile (convert to es5) the code automatically. For this you need a build component added to the project. There are several options for this. The easiest (if you don't need true
ES6), is to add typescript support to the project, and just use the ES6 syntax in the typescript files.
I prefer using es2017, so I use babel for the transpiling via webpack
and just add a build step to run webpack. the webpack task runner extension is also handy:
you can also run the babel cli as build step:
but really unless you are ES6 coding for node.js (fully supported by vs2017), to run in a browser you will need to use typescript or babel.
note: in order to debug the es6 source, be sure to produce a map file (inline is the easiest) during the transpile step.
Dec 29, 2017 03:04 PM|USSKipper|LINK
Thanks Bruce! I will give this a try.