Move ES2015 example into a subpage of the NodeServicesExamples sample
This commit is contained in:
parent
facc2c6d08
commit
8dbd143857
|
|
@ -10,6 +10,11 @@ namespace NodeServicesExamples.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ES2015Transpilation()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View("~/Views/Shared/Error.cshtml");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
}
|
||||
|
|
@ -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>
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue