mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Add ES2015 runtime transpilation sample
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user