fix: export Netlify config separately from the serverless function#15335
fix: export Netlify config separately from the serverless function#15335
Conversation
🦋 Changeset detectedLatest commit: 03a6694 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
It's better to avoid this proxy function because it does not correctly portray how the actual build runs. This obscured the fact that we were not exporting the config object correctly.
| [build] | ||
| publish = "build" | ||
|
|
||
| # TODO: remove this after we refactor to the Netlify frameworks API |
| outfile: '.netlify/edge-functions/render.js', | ||
| ...esbuild_config | ||
| }), | ||
| builder.hasServerInstrumentationFile?.() && |
There was a problem hiding this comment.
We used optional chaining before because the peer version of SvelteKit could have been one without this feature. However, we have already bumped the peer version in a previous PR and forgot to remove this
There was a problem hiding this comment.
I was about to ask about that 👍
fixes #15329 requires #15335 to be merged first so that our test runs correctly. The Netlify dev server cannot detect the split function `config` export for routing otherwise This PR fixes an issue where our dynamic segment starts with a number instead of a letter so that it works with URLPattern which is used by the Netlify functions v2. Without this, users using the Netlify adapter with split functions configured and parameterised routes will fail to deploy their apps. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. ### Tests - [ ] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @sveltejs/adapter-cloudflare@7.2.8 ### Patch Changes - fix: skip comment lines in `_redirects` file ([#15325](#15325)) - Updated dependencies \[[`e87efba`](e87efba), [`71ddbc7`](71ddbc7), [`1bae374`](1bae374), [`20dfadf`](20dfadf), [`8c2384a`](8c2384a)]: - @sveltejs/kit@2.52.1 ## @sveltejs/adapter-netlify@6.0.1 ### Patch Changes - fix: export Netlify config directly from the instrumented serverless function ([#15335](#15335)) - Updated dependencies \[[`e87efba`](e87efba), [`71ddbc7`](71ddbc7), [`1bae374`](1bae374), [`20dfadf`](20dfadf), [`8c2384a`](8c2384a)]: - @sveltejs/kit@2.52.1 ## @sveltejs/kit@2.52.1 ### Patch Changes - fix: clear stale preflight issues on subsequent valid form submissions ([#15281](#15281)) - chore: remove dependency on `sade` ([#15272](#15272)) - fix: include `.txt` files in precompression ([#15259](#15259)) - fix: escape backticks and dollar signs when creating inlined css ([#15320](#15320)) - fix: increment `form.pending` count before preflight validation ([#15279](#15279)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…veltejs#15335) This PR ensures the Netlify `config `export can be detected by exporting it directly from the instrumented file. Previously, it was not exported at all. I've also tried adding it as an export to `builder.instrument` but the Netlify dev server could not read the `config` export when it's dynamically imported and awaited alongside the serverless function. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
fixes sveltejs#15329 requires sveltejs#15335 to be merged first so that our test runs correctly. The Netlify dev server cannot detect the split function `config` export for routing otherwise This PR fixes an issue where our dynamic segment starts with a number instead of a letter so that it works with URLPattern which is used by the Netlify functions v2. Without this, users using the Netlify adapter with split functions configured and parameterised routes will fail to deploy their apps. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. ### Tests - [ ] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @sveltejs/adapter-cloudflare@7.2.8 ### Patch Changes - fix: skip comment lines in `_redirects` file ([sveltejs#15325](sveltejs#15325)) - Updated dependencies \[[`e87efba`](sveltejs@e87efba), [`71ddbc7`](sveltejs@71ddbc7), [`1bae374`](sveltejs@1bae374), [`20dfadf`](sveltejs@20dfadf), [`8c2384a`](sveltejs@8c2384a)]: - @sveltejs/kit@2.52.1 ## @sveltejs/adapter-netlify@6.0.1 ### Patch Changes - fix: export Netlify config directly from the instrumented serverless function ([sveltejs#15335](sveltejs#15335)) - Updated dependencies \[[`e87efba`](sveltejs@e87efba), [`71ddbc7`](sveltejs@71ddbc7), [`1bae374`](sveltejs@1bae374), [`20dfadf`](sveltejs@20dfadf), [`8c2384a`](sveltejs@8c2384a)]: - @sveltejs/kit@2.52.1 ## @sveltejs/kit@2.52.1 ### Patch Changes - fix: clear stale preflight issues on subsequent valid form submissions ([sveltejs#15281](sveltejs#15281)) - chore: remove dependency on `sade` ([sveltejs#15272](sveltejs#15272)) - fix: include `.txt` files in precompression ([sveltejs#15259](sveltejs#15259)) - fix: escape backticks and dollar signs when creating inlined css ([sveltejs#15320](sveltejs#15320)) - fix: increment `form.pending` count before preflight validation ([sveltejs#15279](sveltejs#15279)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR ensures the Netlify
configexport can be detected by exporting it directly from the instrumented file. Previously, it was not exported at all. I've also tried adding it as an export tobuilder.instrumentbut the Netlify dev server could not read theconfigexport when it's dynamically imported and awaited alongside the serverless function.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits