Commit b31aa6a
authored
feat(build,config)!: rework extension development workflow (#6571)
This changeset makes a light breaking change to the way local extension build plugins work. This fixes an issue where functions injected using the `functions.generate` API silently fail to include `node_modules` required for the function to work.
Currently, during `netlify build` and `netlify dev`, build will automatically build your extension and include any build plugins produced by that extension in the build process if you specify this configuration in your `netlify.toml` (documented [here](https://developers.netlify.com/sdk/build-event-handlers/debug-and-test/)):
```toml
# netlify.toml
[[integrations]]
name = "my-local-extension"
[[integrations.dev]]
path = "../some-local-path-to-integration"
force_run_in_build = true
```
To make it short(ish): This process makes a lot of assumptions about the default file structure of a Netlify Extension. It also installs dev-mode extension build plugins using a different code path than for production extension build plugins: In production, we do an `npm install` against a tarball; in development, we point build at a directory and no installation is performed. (This is the crux of the `functions.generate` problem: the directory we point build at is a temporary build directory and does not contain `node_modules`.) We use dev-mode extensions in SDK/build integration tests, so this problem breaks our existing tests and generally makes it difficult to trust that SDK tests will catch real-world, user-facing build plugin problems.
With these changes, build no longer automatically builds extensions. Instead, it assumes that you've already built your extension, and will now install extension build plugins from a local tarball. This makes dev mode behave very similarly to production mode builds.
You can now point build at a tarball:
```toml
# netlify.toml
[[integrations]]
name = "my-local-extension"
[[integrations.dev]]
path = "../some-local-path-to-integration/buildhooks.tgz"
# Note: force_run_in_build is no longer required
```
To make the transition on this change easier, you can instead point build at a directory, and the historical default extension build hooks tarball path will be inferred:
```toml
# netlify.toml
[[integrations]]
name = "my-local-extension"
[[integrations.dev]]
# Expands to "../some-local-path-to-integration/.ntli/site/static/packages/buildhooks.tgz"
path = "../some-local-path-to-integration"
```
There's part of me that thinks, "This behaves slightly differently than local build plugins, and that asymmetry sucks." But: Local build plugins are meant to work when developed in the same tree as the site they're modifying. For better or for worse, developing extensions in the same tree as a site is not supported. So, this asymmetry actually feels appropriate to me.
---
Footnote: This corner of the code had a lot of dead code, code that was untyped, code that was added to avoid updating test fixtures, code that was unnecessarily complex, etc. etc. I did some refactoring along the way to make this functionality easier to implement, and those refactors are included in this PR. Most of the substantial stuff is concentrated in 5-6 files and is fairly well split out into separate commits. To weed out refactors from feature work, though, you might find this easier to review commit by commit.1 parent 56b91ce commit b31aa6a
File tree
37 files changed
+660
-406
lines changed- packages
- build
- src
- install
- plugins
- tests
- install
- fixtures
- local_missing_integration_directory_path
- integration/.ntli/site/static/packages
- local_missing_integration_tarball_path
- local_missing_integration/integration
- .ntli/build
- snapshots
- plugins_list
- config
- src
- api
- env
- log
- types
- utils/extensions
- tests
- api
- fixtures
- dev_extension_with_force_build
- dev_extension
- dev_integration_with_force_build
- dev_integration
- snapshots
- env
- extensions
37 files changed
+660
-406
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 39 | | |
51 | 40 | | |
52 | 41 | | |
53 | 42 | | |
54 | 43 | | |
55 | 44 | | |
56 | 45 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 46 | + | |
63 | 47 | | |
64 | 48 | | |
65 | 49 | | |
66 | 50 | | |
67 | 51 | | |
68 | 52 | | |
69 | | - | |
70 | 53 | | |
71 | 54 | | |
72 | 55 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 56 | + | |
| 57 | + | |
101 | 58 | | |
102 | 59 | | |
103 | 60 | | |
104 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
105 | 71 | | |
106 | 72 | | |
107 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
| |||
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
178 | | - | |
| 176 | + | |
179 | 177 | | |
180 | | - | |
| 178 | + | |
181 | 179 | | |
182 | 180 | | |
183 | 181 | | |
| |||
186 | 184 | | |
187 | 185 | | |
188 | 186 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | 187 | | |
195 | | - | |
196 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
197 | 200 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | 210 | | |
222 | 211 | | |
223 | 212 | | |
| |||
Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 0 additions & 15 deletions
This file was deleted.
0 commit comments