-
Notifications
You must be signed in to change notification settings - Fork 417
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 #1959 from serverless-heaven/feat/serverless-v4
Add support for Serverless v4
- Loading branch information
Showing
20 changed files
with
2,742 additions
and
31 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
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
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
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
2 changes: 2 additions & 0 deletions
2
examples/include-external-npm-packages-with-yarn-workspaces/_setup.js
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
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
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,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "20" | ||
} | ||
} | ||
] | ||
] | ||
} |
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,3 @@ | ||
node_modules | ||
.webpack | ||
.webpackCache |
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,5 @@ | ||
You can try to invoke the function locally (be sure to `yarn install` before): | ||
|
||
``` | ||
yarn serverless invoke local --function=hello --path=./event.json | ||
``` |
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,25 @@ | ||
'use strict'; | ||
|
||
// That file is only used by the e2e tests | ||
|
||
const path = require('path'); | ||
|
||
module.exports = async (originalFixturePath, fixturePath, utils) => { | ||
const pluginPath = path.resolve(originalFixturePath, '..', '..'); | ||
|
||
const SLS_CONFIG_PATH = path.join(fixturePath, 'serverless.yml'); | ||
const WEBPACK_CONFIG_PATH = path.join(fixturePath, 'webpack.config.js'); | ||
const PACKAGE_JSON_PATH = path.join(fixturePath, 'package.json'); | ||
const LOCK_PATH = path.join(fixturePath, 'yarn.lock'); | ||
|
||
await Promise.all([ | ||
utils.replaceInFile(SLS_CONFIG_PATH, '- serverless-webpack', `- ${pluginPath}`), | ||
utils.replaceInFile(WEBPACK_CONFIG_PATH, "'serverless-webpack'", `'${pluginPath}'`), | ||
utils.replaceInFile(PACKAGE_JSON_PATH, 'file:../..', `file:${pluginPath}`), | ||
utils.replaceInFile(LOCK_PATH, 'file:../..', `file:${pluginPath}`) | ||
]); | ||
|
||
const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn'; | ||
|
||
return utils.spawnProcess(command, ['install'], { cwd: __dirname }); | ||
}; |
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,5 @@ | ||
{ | ||
"key3": "value3", | ||
"key2": "value2", | ||
"key1": "value1" | ||
} |
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,8 @@ | ||
import cookie from 'cookie' | ||
|
||
export const hello = (event, context, cb) => cb(null, | ||
{ | ||
message: 'Go Serverless Webpack (Serverless v4) v1.0! Your function executed successfully!', | ||
event, | ||
} | ||
); |
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,23 @@ | ||
{ | ||
"name": "serverless-webpack-serverless-v4", | ||
"version": "1.0.0", | ||
"description": "Serverless webpack example using Serverless v4", | ||
"main": "handler.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "^7.25.8", | ||
"@babel/preset-env": "^7.25.8", | ||
"@babel/preset-typescript": "^7.25.7", | ||
"babel-loader": "^9.2.1", | ||
"serverless": "^4.4.6", | ||
"serverless-webpack": "file:../..", | ||
"webpack": "^5.95.0", | ||
"webpack-node-externals": "^3.0.0" | ||
}, | ||
"dependencies": { | ||
"cookie": "^0.7.0" | ||
} | ||
} |
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,32 @@ | ||
frameworkVersion: "^4.4.0" | ||
|
||
service: serverless-webpack-serverless-v4 | ||
|
||
package: | ||
individually: true | ||
|
||
# Add the serverless-webpack plugin | ||
plugins: | ||
- serverless-webpack | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs20.x | ||
|
||
build: | ||
esbuild: false | ||
|
||
functions: | ||
hello: | ||
handler: handler.hello | ||
events: | ||
- http: | ||
method: get | ||
path: hello | ||
integration: lambda | ||
|
||
custom: | ||
webpack: | ||
webpackConfig: 'webpack.config.js' | ||
packager: 'yarn' | ||
includeModules: true |
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 @@ | ||
const path = require('path'); | ||
const slsw = require('serverless-webpack'); | ||
const nodeExternals = require('webpack-node-externals'); | ||
|
||
module.exports = { | ||
entry: slsw.lib.entries, | ||
target: 'node', | ||
mode: slsw.lib.webpack.isLocal ? 'development' : 'production', | ||
optimization: { | ||
// We no not want to minimize our code. | ||
minimize: false | ||
}, | ||
performance: { | ||
// Turn off size warnings for entry points | ||
hints: false | ||
}, | ||
devtool: 'nosources-source-map', | ||
externals: [nodeExternals()], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader' | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
output: { | ||
libraryTarget: 'commonjs2', | ||
path: path.join(__dirname, '.webpack'), | ||
filename: '[name].js', | ||
sourceMapFilename: '[file].map' | ||
} | ||
}; |
Oops, something went wrong.