Add ES2015 runtime transpilation sample

This commit is contained in:
SteveSandersonMS
2015-11-02 11:15:34 -08:00
parent f693bd60e3
commit 60d77e7b92
19 changed files with 233 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.NodeServices;
namespace ES2015Example.Controllers
{
public class ScriptController : Controller
{
private static NodeInstance nodeInstance = new NodeInstance();
public async Task<ContentResult> Transpile(string filename)
{
// TODO: Don't hard-code wwwroot; use proper path conversions
var fileContents = System.IO.File.ReadAllText("wwwroot/" + filename);
var transpiledResult = await nodeInstance.Invoke("transpilation.js", fileContents);
return Content(transpiledResult, "application/javascript");
}
}
}