Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<h2 align="center">Background</h2>

This plugin will build your [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) project using Webpack. You can use it to replace the `sam build` step if every function in your SAM template uses the `nodejs12.x`, `nodejs14.x` or `nodejs16.x` runtime. If your project uses other runtimes then look at [Building Apps with SAM, TypeScript and VS Code Debugging](http://www.goingserverless.com/blog/building-apps-with-sam-typescript-and-vscode-debugging).
This plugin will build your [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) project using Webpack. You can use it to replace the `sam build` step if every function in your SAM template uses the `nodejs14.x` or `nodejs16.x` runtime. If your project uses other runtimes then look at [Building Apps with SAM, TypeScript and VS Code Debugging](http://www.goingserverless.com/blog/building-apps-with-sam-typescript-and-vscode-debugging).

I started this project for two reasons:

Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/__snapshots__/entryFor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Object {
}
`;

exports[`Function Runtime can be set at the function to nodejs12.x 1`] = `
exports[`Function Runtime can be set at the function to nodejs14.x 1`] = `
Object {
"entryPoints": Object {
"MyLambda": "./src/my-lambda/app",
Expand Down Expand Up @@ -371,7 +371,7 @@ Object {
"Properties": Object {
"CodeUri": "MyLambda",
"Handler": "app.handler",
"Runtime": "nodejs12.x",
"Runtime": "nodejs14.x",
},
"Type": "AWS::Serverless::Function",
},
Expand Down Expand Up @@ -597,7 +597,7 @@ Object {
}
`;

exports[`Function Runtime can be set globally to nodejs12.x 1`] = `
exports[`Function Runtime can be set globally to nodejs14.x 1`] = `
Object {
"entryPoints": Object {
"MyLambda": "./src/my-lambda/app",
Expand Down Expand Up @@ -633,7 +633,7 @@ Object {
"AWSTemplateFormatVersion": "2010-09-09",
"Globals": Object {
"Function": Object {
"Runtime": "nodejs12.x",
"Runtime": "nodejs14.x",
},
},
"Resources": Object {
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/entryFor.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import SamPlugin from "../index";

describe("Function Runtime", () => {
test("can be set globally to nodejs12.x", () => {
test("can be set globally to nodejs14.x", () => {
const plugin = new SamPlugin();
const template = `
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Globals:
Function:
Runtime: nodejs12.x
Runtime: nodejs14.x

Resources:
MyLambda:
Expand Down Expand Up @@ -64,7 +64,7 @@ Resources:
expect(entries).toMatchSnapshot();
});

test("can be set at the function to nodejs12.x", () => {
test("can be set at the function to nodejs14.x", () => {
const plugin = new SamPlugin();
const template = `
AWSTemplateFormatVersion: "2010-09-09"
Expand All @@ -76,7 +76,7 @@ Resources:
Properties:
CodeUri: src/my-lambda
Handler: app.handler
Runtime: nodejs12.x
Runtime: nodejs14.x
`;
const entries = plugin.entryFor("default", "", "template.yaml", template, "app");
expect(entries).toMatchSnapshot();
Expand Down Expand Up @@ -132,7 +132,7 @@ Resources:
Handler: app.handler
`;
expect(() => plugin.entryFor("default", "", "template.yaml", template, "app")).toThrowError(
"MyLambda has an unsupport Runtime. Must be nodejs12.x, nodejs14.x or nodejs16.x"
"MyLambda has an unsupport Runtime. Must be nodejs14.x or nodejs16.x"
);
});

Expand All @@ -154,7 +154,7 @@ Resources:
Handler: app.handler
`;
expect(() => plugin.entryFor("default", "", "template.yaml", template, "app")).toThrowError(
"MyLambda has an unsupport Runtime. Must be nodejs12.x, nodejs14.x or nodejs16.x"
"MyLambda has an unsupport Runtime. Must be nodejs14.x or nodejs16.x"
);
});

Expand All @@ -173,7 +173,7 @@ Resources:
Runtime: nodejs10.x
`;
expect(() => plugin.entryFor("default", "", "template.yaml", template, "app")).toThrowError(
"MyLambda has an unsupport Runtime. Must be nodejs12.x, nodejs14.x or nodejs16.x"
"MyLambda has an unsupport Runtime. Must be nodejs14.x or nodejs16.x"
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class AwsSamPlugin {
}

// Check the runtime is supported
if (!["nodejs12.x", "nodejs14.x", "nodejs16.x"].includes(properties.Runtime ?? defaultRuntime)) {
throw new Error(`${resourceKey} has an unsupport Runtime. Must be nodejs12.x, nodejs14.x or nodejs16.x`);
if (!["nodejs14.x", "nodejs16.x"].includes(properties.Runtime ?? defaultRuntime)) {
throw new Error(`${resourceKey} has an unsupport Runtime. Must be nodejs14.x or nodejs16.x`);
}

// Continue with a warning if they're using inline code
Expand Down