You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Use Typescript or non-standard JavaScript features](#use-typescript-or-non-standard-javascript-features)
7
+
-[Bundle with Webpack](#bundle-with-webpack)
8
+
-[Install function dependencies](#install-function-dependencies)
6
9
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
10
9
-
If you had `netlify-lambda` in you npm scripts you can simply migrate by changing to the Netlify CLIs `dev` command.
11
+
## Run Netlify Functions locally
12
+
13
+
The tooling to run functions locally has been completely integrated into the Netlify CLI, which offers even more functionality like local debugging.
14
+
15
+
If you had `netlify-lambda` in your npm scripts, you can migrate by changing to the Netlify CLI `dev` command.
10
16
11
17
For example in a theoretical Gatsby project you can migrate with the following changes:
12
18
19
+
> package.json
20
+
21
+
13
22
```diff
14
23
{
15
24
"scripts": {
@@ -26,19 +35,17 @@ For example in a theoretical Gatsby project you can migrate with the following c
26
35
}
27
36
```
28
37
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
38
+
## Use TypeScript or non-standard JavaScript features
34
39
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.
40
+
Netlify now supports TypeScript and non-standard JavaScript features.
41
+
For TypeScript there is no configuration needed and it will work out of the box. The same is true if you use ESM modules in your functions. The bundling logic will automatically detect these and use `esbuild` to bundle the functions.
42
+
In any other case you can 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
36
43
37
-
## Webpack bundling
44
+
Should `esbuild` not work for your use case then please report this to us or use webpack directly as described in the next section.
38
45
39
-
You might want to give our automated bundling a try (see above).
46
+
## Bundle with Webpack
40
47
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.
48
+
If after trying our [automated bundling](#use-typescript-or-non-standard-javascript-features)you still want to use webpack to bundle your functions, you can use webpack directly and adjust the config to your needs. The following example is for webpack 4, which is the version that netlify-lambda used.
42
49
43
50
> package.json
44
51
@@ -111,9 +118,9 @@ module.exports = {
111
118
112
119
## Install function dependencies
113
120
114
-
Consider moving the dependencies of your functions into your main `package.json`. If this is not possible you can use the following change.
121
+
Consider moving the dependencies of your functions into your main `package.json` for automatic installation during local development. If this is not possible you can use the following change.
115
122
116
-
Note that, this is only needed for local development, the Netlify Build System will detect and install dependencies of your functions.
123
+
Note that this is needed for local development only. The Netlify build system will detect and install dependencies of your functions.
0 commit comments