-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from olup/feat/optimize-package-individually
feat(package): optimize bundle for package individually
- Loading branch information
Showing
13 changed files
with
5,622 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as _ from 'lodash'; | ||
|
||
// modern module syntax | ||
export async function handler(event, context, callback) { | ||
|
||
// dependencies work as expected | ||
console.log(_.VERSION); | ||
|
||
// async/await also works out of the box | ||
await new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
||
const response = { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: 'Go Serverless v1.0! Your function executed successfully!', | ||
input: event, | ||
}), | ||
}; | ||
|
||
callback(null, response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
// modern module syntax | ||
export async function handler(event, context, callback) { | ||
// async/await also works out of the box | ||
await new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
||
const response = { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: 'Go Serverless v1.0! Your function executed successfully!', | ||
input: event, | ||
}), | ||
}; | ||
|
||
callback(null, response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"main": "handler.js", | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "4.14.91", | ||
"@types/node": "^11.13.0", | ||
"serverless": "2.3.0", | ||
"serverless-esbuild": "^1.5.1", | ||
"serverless-offline": "^6.4.0" | ||
}, | ||
"scripts": { | ||
"start": "sls offline" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
service: serverless-example | ||
|
||
plugins: | ||
- serverless-esbuild | ||
- serverless-offline | ||
|
||
package: | ||
individually: true | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs12.x | ||
|
||
custom: | ||
esbuild: | ||
packager: yarn | ||
bundle: true | ||
minify: true | ||
sourcemap: false | ||
keepNames: true | ||
external: | ||
- lodash | ||
|
||
|
||
functions: | ||
hello1: | ||
handler: hello1.handler | ||
events: | ||
- http: | ||
path: hello | ||
method: get | ||
|
||
hello2: | ||
handler: hello2.handler | ||
events: | ||
- http: | ||
path: hello | ||
method: get |
Oops, something went wrong.