Skip to content

Commit 8dbd143

Browse files
Move ES2015 example into a subpage of the NodeServicesExamples sample
1 parent facc2c6 commit 8dbd143

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

samples/misc/NodeServicesExamples/Controllers/HomeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public IActionResult Index(int pageIndex)
1010
return View();
1111
}
1212

13+
public IActionResult ES2015Transpilation()
14+
{
15+
return View();
16+
}
17+
1318
public IActionResult Error()
1419
{
1520
return View("~/Views/Shared/Error.cshtml");
File renamed without changes.

samples/misc/NodeServicesExamples/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHo
3030
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
3131
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
3232
if (fileInfo.Exists) {
33-
var transpiled = await nodeServices.Invoke<string>("transpilation.js", fileInfo.PhysicalPath, requestPath);
33+
var transpiled = await nodeServices.Invoke<string>("./Node/transpilation.js", fileInfo.PhysicalPath, requestPath);
3434
await context.Response.WriteAsync(transpiled);
3535
return;
3636
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h1>ES2015 Transpilation</h1>
2+
3+
<p>
4+
This sample demonstrates a way of intercepting requests for .js files and dynamically transpiling them
5+
from ES2015 code to browser-compatible ES5 code using the Babel library.
6+
</p>
7+
8+
<p>
9+
To see that it's working, open your browser's 'Debug' console and look for the log message. This is
10+
produced by the file <a href='/js/main.js'>/js/main.js</a>, which is transpiled from ES2015 dynamically
11+
when requested.
12+
</p>
13+
14+
@section scripts {
15+
<script src='/js/main.js'></script>
16+
}

samples/misc/NodeServicesExamples/Views/Home/Index.cshtml

100755100644
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
Hello
1+
<h1>NodeServices examples</h1>
2+
3+
<p>
4+
These examples demonstrate the direct use of the NodeServices package, independently of the usual SPA scenarios.
5+
In general, NodeServices offers an efficient way to use Node-provided functionality (e.g., NPM modules) from inside
6+
a .NET application.
7+
</p>
8+
9+
<ul>
10+
<li><a asp-action="ES2015Transpilation">ES2015 transpilation</a>
11+
</li>
212

3-
@section scripts {
4-
<script src='js/main.js'></script>
5-
}

0 commit comments

Comments
 (0)