Move ES2015 example into a subpage of the NodeServicesExamples sample

This commit is contained in:
SteveSandersonMS
2016-06-07 14:31:23 +01:00
parent facc2c6d08
commit 8dbd143857
5 changed files with 33 additions and 5 deletions

View File

@@ -10,6 +10,11 @@ namespace NodeServicesExamples.Controllers
return View();
}
public IActionResult ES2015Transpilation()
{
return View();
}
public IActionResult Error()
{
return View("~/Views/Shared/Error.cshtml");

View File

@@ -30,7 +30,7 @@ namespace NodeServicesExamples
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
if (fileInfo.Exists) {
var transpiled = await nodeServices.Invoke<string>("transpilation.js", fileInfo.PhysicalPath, requestPath);
var transpiled = await nodeServices.Invoke<string>("./Node/transpilation.js", fileInfo.PhysicalPath, requestPath);
await context.Response.WriteAsync(transpiled);
return;
}

View File

@@ -0,0 +1,16 @@
<h1>ES2015 Transpilation</h1>
<p>
This sample demonstrates a way of intercepting requests for .js files and dynamically transpiling them
from ES2015 code to browser-compatible ES5 code using the Babel library.
</p>
<p>
To see that it's working, open your browser's 'Debug' console and look for the log message. This is
produced by the file <a href='/js/main.js'>/js/main.js</a>, which is transpiled from ES2015 dynamically
when requested.
</p>
@section scripts {
<script src='/js/main.js'></script>
}

View File

@@ -1,5 +1,12 @@
Hello
<h1>NodeServices examples</h1>
<p>
These examples demonstrate the direct use of the NodeServices package, independently of the usual SPA scenarios.
In general, NodeServices offers an efficient way to use Node-provided functionality (e.g., NPM modules) from inside
a .NET application.
</p>
<ul>
<li><a asp-action="ES2015Transpilation">ES2015 transpilation</a>
</li>
@section scripts {
<script src='js/main.js'></script>
}