Skip to content

Commit 62c624e

Browse files
committed
Implementing JavaScript compiler (transpiler) and TypeScript support
1 parent 3124c02 commit 62c624e

File tree

47 files changed

+1214
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1214
-150
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ Publish
1414
/TestResults
1515

1616
/tools/NuGet.exe
17-
/node_modules
17+
/node_modules
18+
/.output

CustomDictionary.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<Term CompoundAlternate="TableName">tableName</Term>
8383
<Term CompoundAlternate="ETag">etag</Term>
8484
<Term CompoundAlternate="ETag">eTag</Term>
85+
<Term CompoundAlternate="Typescript">TypeScript</Term>
8586
</Compound>
8687
<DiscreteExceptions>
8788
<Term>WebJobs</Term>

WebJobs.Script.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "swagger", "swagger", "{DCC9
442442
sample\.azurefunctions\swagger\swagger.json = sample\.azurefunctions\swagger\swagger.json
443443
EndProjectSection
444444
EndProject
445+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger-TypeScript", "HttpTrigger-TypeScript", "{62489417-341D-42AD-9E84-E97EB8236979}"
446+
ProjectSection(SolutionItems) = preProject
447+
sample\HttpTrigger-TypeScript\function.json = sample\HttpTrigger-TypeScript\function.json
448+
sample\HttpTrigger-TypeScript\index.ts = sample\HttpTrigger-TypeScript\index.ts
449+
EndProjectSection
450+
EndProject
445451
Global
446452
GlobalSection(SharedMSBuildProjectFiles) = preSolution
447453
test\WebJobs.Script.Tests.Shared\WebJobs.Script.Tests.Shared.projitems*{35a2025d-f68a-4b57-83a2-ed4eb9c3894d}*SharedItemsImports = 4
@@ -566,5 +572,6 @@ Global
566572
{EB76E1C8-C823-4707-BD83-20304425EFC4} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
567573
{7D50E081-A161-4E83-A6D4-F8529E518613} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
568574
{DCC9EBEB-5F60-4117-95D2-26507F9DE9A6} = {7D50E081-A161-4E83-A6D4-F8529E518613}
575+
{62489417-341D-42AD-9E84-E97EB8236979} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
569576
EndGlobalSection
570577
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"bindings": [
3+
{
4+
"type": "httpTrigger",
5+
"name": "req",
6+
"direction": "in",
7+
"methods": [ "get" ]
8+
},
9+
{
10+
"type": "http",
11+
"name": "$return",
12+
"direction": "out"
13+
}
14+
]
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export function index(context: any, req: any) {
2+
context.log('Node.js HTTP trigger function processed a request. Name=%s', req.query.name);
3+
var headerValue = req.headers['test-header'];
4+
if (headerValue) {
5+
context.log('test-header=' + headerValue);
6+
}
7+
8+
var res;
9+
if (typeof req.query.name == 'undefined') {
10+
res = {
11+
status: 400,
12+
body: "Please pass a name on the query string",
13+
headers: {
14+
'Content-Type': 'text/plain'
15+
}
16+
};
17+
}
18+
else {
19+
res = {
20+
status: 200,
21+
body: "Hello" + req.query.name,
22+
headers: {
23+
'Content-Type': 'text/plain'
24+
}
25+
};
26+
}
27+
28+
context.done(null, res);
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"keys": [
3+
{
4+
"name": "default",
5+
"value": "YdNA3eqpIMrJeYX567Lh5f2oPSQjOloCkKlnrJLzZIZZHtKcMckBiQ==",
6+
"encrypted": false
7+
}
8+
]
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Immutable;
6+
using System.Threading;
7+
using Microsoft.CodeAnalysis;
8+
9+
namespace Microsoft.Azure.WebJobs.Script.Description
10+
{
11+
public interface ICompilation
12+
{
13+
ImmutableArray<Diagnostic> GetDiagnostics();
14+
15+
object Emit(CancellationToken cancellationToken);
16+
}
17+
18+
public interface ICompilation<TOutput> : ICompilation
19+
{
20+
new TOutput Emit(CancellationToken cancellationToken);
21+
}
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Threading.Tasks;
7+
8+
namespace Microsoft.Azure.WebJobs.Script.Description
9+
{
10+
public interface ICompilationService
11+
{
12+
string Language { get; }
13+
14+
/// <summary>
15+
/// Gets a value indicating whether this compilation service persists compilation output to the common file system.
16+
/// </summary>
17+
bool PersistsOutput { get; }
18+
19+
IEnumerable<string> SupportedFileTypes { get; }
20+
21+
Task<object> GetFunctionCompilationAsync(FunctionMetadata functionMetadata);
22+
}
23+
24+
public interface ICompilationService<TCompilation> : ICompilationService where TCompilation : ICompilation
25+
{
26+
new Task<TCompilation> GetFunctionCompilationAsync(FunctionMetadata functionMetadata);
27+
}
28+
}

src/WebJobs.Script/Description/DotNet/ICompilationServiceFactory.cs renamed to src/WebJobs.Script/Description/Compilation/ICompilationServiceFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
namespace Microsoft.Azure.WebJobs.Script.Description
88
{
9-
public interface ICompilationServiceFactory
9+
public interface ICompilationServiceFactory<TCompilationService, TMetadata> where TCompilationService : ICompilationService
1010
{
1111
ImmutableArray<ScriptType> SupportedScriptTypes { get; }
1212

13-
ICompilationService CreateService(ScriptType scriptType, IFunctionMetadataResolver metadataResolver);
13+
TCompilationService CreateService(ScriptType scriptType, TMetadata metadata);
1414
}
1515
}
File renamed without changes.

0 commit comments

Comments
 (0)