Skip to content

Commit 89b04c4

Browse files
committed
chore: bye bye
1 parent 19abfb0 commit 89b04c4

File tree

7 files changed

+8254
-2664
lines changed

7 files changed

+8254
-2664
lines changed

.github/workflows/fossa.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/labeler.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

MIGRATE.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Migration Guide
2+
3+
This guide covers some use cases of netlify-lambda and how to accomplish them without it.
4+
5+
## Running Netlify functions locally
6+
7+
The functionality to have functions run locally has been completely integrated into the Netlify CLI and offers even more functionality like local debugging.
8+
9+
If you had `netlify-lambda` in you npm scripts you can simply migrate by changing to the Netlify CLIs `dev` command.
10+
11+
For example in a theoretical Gatsby project you can migrate with the following changes:
12+
13+
```diff
14+
{
15+
"scripts": {
16+
- "start:app": "npm run develop",
17+
- "start:lambda": "netlify-lambda serve src/lambda",
18+
- "start": "concurrently \"yarn start:lambda\" \"yarn develop\"",
19+
- "develop": "gatsby develop",
20+
+ "start": "netlify dev",
21+
},
22+
"devDependencies": {
23+
- "netlify-lambda": "^1.4.3",
24+
+ "netlify-cli": "^10.14.0",
25+
}
26+
}
27+
```
28+
29+
## Using Typescript or non-standard JavaScript features
30+
31+
Netlify now also supports Typescript and non-standard JavaScript features.
32+
For Typescript there is no configuration needed and tit will work out of the box. The same is true if you use ESM modules in your functions. The bundling logic will automatically detect this and use `esbuild` to bundle the function.
33+
In any other case you can enable set the `node_bundler` to `esbuild` yourself for the functions in your `netlify.toml` file. https://docs.netlify.com/configure-builds/file-based-configuration/#functions
34+
35+
Should `esbuild` not work for you usecase then please report this to us or use webpack directly. You can check how this works in the next section.
36+
37+
## Webpack bundling
38+
39+
You might want to give our automated bundling a try (see above).
40+
41+
If you still want to use webpack to bundle your functions, you can simply use webpack yourself and adjust the following config to your needs. This example is for webpack 4, which is the version that netlify-lambda also used.
42+
43+
> package.json
44+
45+
```json
46+
{
47+
"scripts":{
48+
"build":"webpack --config ./webpack.config.js"
49+
}
50+
"devDependencies": {
51+
"webpack": "^4.46.0",
52+
"webpack-cli": "^4.10.0",
53+
"babel-loader": "^8.2.5",
54+
"@babel/preset-env": "^7.18.9",
55+
}
56+
}
57+
```
58+
59+
> webpack.config.js
60+
61+
```js
62+
const webpack = require('webpack');
63+
64+
module.exports = {
65+
mode: 'production',
66+
resolve: {
67+
extensions: ['.wasm', '.mjs', '.js', '.json', '.ts'],
68+
mainFields: ['module', 'main'],
69+
},
70+
module: {
71+
rules: [
72+
{
73+
test: /\.(m?js|ts)?$/,
74+
exclude: new RegExp(
75+
`(node_modules|bower_components|\\.(test|spec)\\.?)`,
76+
),
77+
use: {
78+
loader: require.resolve('babel-loader'),
79+
options: {
80+
cacheDirectory: true,
81+
presets: [
82+
[
83+
require.resolve('@babel/preset-env'),
84+
{ targets: { node: '16.6.0' } },
85+
],
86+
],
87+
},
88+
},
89+
},
90+
],
91+
},
92+
context: './src/functions',
93+
entry: {},
94+
target: 'node',
95+
plugins: [new webpack.IgnorePlugin(/vertx/)],
96+
output: {
97+
path: './netlify/functions',
98+
filename: '[name].js',
99+
libraryTarget: 'commonjs',
100+
},
101+
optimization: {
102+
nodeEnv: process.env.NODE_ENV || 'production',
103+
},
104+
bail: true,
105+
devtool: false,
106+
stats: {
107+
colors: true,
108+
},
109+
};
110+
```
111+
112+
## Install function dependencies
113+
114+
Consider moving the dependencies of your functions into your main `package.json`. If this is not possible you can use the following change.
115+
116+
Note that, this is only needed for local development, the Netlify Build System will detect and install dependencies of your functions.
117+
118+
```diff
119+
{
120+
"scripts": {
121+
- "postinstall": "netlify-lambda install",
122+
+ "postinstall": "npm --prefix ./functions/my-function i && npm --prefix ./functions/other-function i",
123+
},
124+
"devDependencies": {
125+
- "netlify-lambda": "^1.4.3",
126+
}
127+
}
128+
```

0 commit comments

Comments
 (0)