Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2afe782
auto setup dummy adapter
pieh Sep 22, 2025
cee330c
use modifyConfig to set standalone output
pieh Sep 22, 2025
0fe7e9a
setup loaderFile for next/image and avoid a rewrite
pieh Sep 22, 2025
ebf1407
test: run canary tests to use most recent adapters API
pieh Sep 22, 2025
15e64f2
fixup! setup loaderFile for next/image and avoid a rewrite
pieh Sep 22, 2025
ce070d6
move setting up remote images config to adapter
pieh Sep 22, 2025
273fd1c
refactor adapter a bit and start creating modules per concern
pieh Sep 23, 2025
a698e1b
move legacy ipx redirect to adapter as well
pieh Sep 23, 2025
c4bf5e3
skip retries in CI for now
pieh Sep 23, 2025
4df59c1
type frameworks api config
pieh Sep 23, 2025
66cd37f
only set standalone if output is not export
pieh Sep 23, 2025
6c46c9d
migrate immutable headers for next/static
pieh Sep 23, 2025
0c24a46
testing out static file copying
mrstork Sep 23, 2025
9f371fd
remove no longer used
pieh Sep 23, 2025
4816bc3
maybe fix __vite_ssr_import_meta__ problems
pieh Sep 23, 2025
303ff66
link to vitest issue
pieh Sep 23, 2025
650e534
move edge middleware setup to adapter
pieh Sep 23, 2025
0e4bee3
remove unit test for deleted copyStaticAssets
pieh Sep 23, 2025
f369128
fix lint
pieh Sep 23, 2025
204cb66
update notes
pieh Sep 23, 2025
1799786
test: adjust tests to look for .netlify/images and not _next/image
pieh Sep 24, 2025
242d71f
lets try to annotate some tests to see if it helps with finding commo…
pieh Sep 24, 2025
bffff19
add missing name and generator to middleware EF
pieh Sep 24, 2025
3bf80ae
handle node middleware
pieh Sep 24, 2025
1a7e93d
remove no longer used build plugin middleware handling
pieh Sep 24, 2025
36dc9db
rename step
mrstork Sep 24, 2025
a42a9b8
move static content step to adapter pattern
mrstork Sep 24, 2025
5b436e2
actually static-content step is not needed
mrstork Sep 24, 2025
e140441
mark middleware handling as done
pieh Sep 24, 2025
3f76a9f
add note/question about export output
pieh Sep 24, 2025
2341079
preserve html extension for static files
pieh Sep 24, 2025
98c8e76
add links to repro for i18n problems
pieh Sep 24, 2025
17e5f50
split feedback and notes for us
pieh Sep 24, 2025
0305db3
add note about static files and trailingSlash config
pieh Sep 25, 2025
a298b3b
remove next patching as we don't use that for newer next versions
pieh Sep 25, 2025
5215cf8
static assets trailing slashes, public and some constants moving
pieh Sep 25, 2025
b19d48e
fix lint
pieh Sep 25, 2025
cc9eaab
workaround: create empty static json for fully static pages
pieh Sep 25, 2025
8365f8c
ignore some files
pieh Sep 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ steps.check-labels.outputs.result }}" = "true" ]; then
echo "matrix=[\"latest\", \"canary\", \"14.2.15\", \"13.5.1\"]" >> $GITHUB_OUTPUT
else
echo "matrix=[\"latest\"]" >> $GITHUB_OUTPUT
echo "matrix=[\"canary\"]" >> $GITHUB_OUTPUT
fi

e2e:
Expand Down
53 changes: 53 additions & 0 deletions adapters-feedback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Feedback

- Files from `public` directory not listed in `outputs.staticFiles`. Should they be?
- `routes.headers` does not contain immutable cache-control headers for `_next/static`. Should those
be included?
- In `onBuildComplete` - `config.images.remotePatterns` type is `(RemotePattern | URL)[]` but in
reality `URL` inputs are converted to `RemotePattern` so type should be just `RemotePattern[]` in
`onBuildComplete` (this would require different config type for `modifyConfig` (allow inputs
here?) and `onBuildComplete` (final, normalized config shape)?)
- `outputs.middleware.config.matchers` can be undefined per types - can that ever happen? Can we
just have empty array instead to simplify handling (possibly similar as above point where type is
for the input, while "output" will have a default matcher if not defined by user).
- `outputs.middleware` does not contain `env` that exist in `middleware-manifest.json` (i.e.
`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`, `NEXT_PREVIEW_MODE_ID`, `NEXT_PREVIEW_MODE_SIGNING_KEY` etc)
or `wasm` (tho wasm files are included in assets, so I think I have a way to support those as-is,
but need to to make some assumption about using extension-less file name of wasm file as
identifier)
- `outputs.staticFiles` (i18n enabled) custom fully static (no `getStaticProps`) `/pages/*`
`filePath` point to not existing file - see repro at https://github.com/pieh/i18n-adapters
- `outputs.staticFiles` (i18n enabled) custom `/pages/*` with `getStaticProps` result in fatal
`Error: Invariant: failed to find source route /en(/*) for prerender /en(/*)` directly from
Next.js:

```
⨯ Failed to run onBuildComplete from Netlify

> Build error occurred
Error: Invariant: failed to find source route /en/404 for prerender /en/404
```

(additionally - invariant is reported as failing to run `onBuildComplete` from adapter, but it
happens before adapter's `onBuildComplete` runs, would be good to clear this up a bit so users
could report issues in correct place in such cases. Not that important for nearest future / not
blocking).

See repro at https://github.com/pieh/i18n-adapters (it's same as for point above, need to
uncomment `getStaticProps` in one of the pages in repro to see this case)

- `output: 'export'` case seems to produce outputs as if it was not export mode (for example having
non-empty `outputs.appPages` or `outputs.prerenders`). To not have special handling for that in
adapters, only non-empty outputs should be `staticFiles` pointing to what's being written to `out`
(or custom `distDir`) directory?
- `output.staticFiles` entries for fully static pages router pages don't have `trailingSlash: true`
option applied to `pathname`. For example:
```json
{
"id": "/link/rewrite-target-fullystatic",
"//": "Should pathname below have trailing slash, if `trailingSlash: true` is set in next.config.js?",
"pathname": "/link/rewrite-target-fullystatic",
"type": "STATIC_FILE",
"filePath": "/Users/misiek/dev/next-runtime-adapter/tests/fixtures/middleware-pages/.next/server/pages/link/rewrite-target-fullystatic.html"
}
```
32 changes: 32 additions & 0 deletions adapters-running-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Plan

1. There are some operations that are easier to do in a build plugin context due to helpers, so some
handling will remain in build plugin (cache save/restore, moving static assets dirs for
publishing them etc).

2. We will use adapters API where it's most helpful:

- adjusting next config:
- [done] set standalone mode instead of using "private" env var (for now at least we will continue
with standalone mode as using outputs other than middleware require bigger changes which will be
explored in later phases)
- [done] set image loader (url generator) to use Netlify Image CDN directly (no need for
\_next/image rewrite then)
- (maybe/explore) set build time cache handler to avoid having to read output of default cache
handler and convert those files into blobs to upload later
- [done] use middleware output to generate middleware edge function
- [done] don't glob for static files and use `outputs.staticFiles` instead
- [checked, did not apply changes yet, due to question about this in feedback section] check
`output: 'export'` case
- note any remaining manual manifest files reading in build plugin once everything that could be
adjusted was handled

## To figure out

- Can we export build time otel spans from adapter similarly how we do that now in a build plugin?
- Expose some constants from build plugin to adapter - what's best way to do that? (things like
packagePath, publishDir etc)
- Looking forward - Platform change to accept a list of files to upload to cdn (avoids file system
operations such as `cp`)
- Looking forward - allow using regexes for static headers matcher (needed to apply next.config.js
defined headers to apply to static assets)
2 changes: 1 addition & 1 deletion edge-runtime/shim/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'
import { createRequire } from 'node:module' // used in dynamically generated part
import process from 'node:process'

import { registerCJSModules } from '../edge-runtime/lib/cjs.ts' // used in dynamically generated part
import { registerCJSModules } from './edge-runtime/lib/cjs.ts' // used in dynamically generated part

globalThis.process = process

Expand Down
Loading
Loading