Skip to content

Commit ae3412e

Browse files
authored
Merge branch 'main' into rs/transform-named-capture-groups
2 parents 450137d + 993766b commit ae3412e

File tree

40 files changed

+2159
-2493
lines changed

40 files changed

+2159
-2493
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ demos
66
packages/runtime/src/templates/edge
77
packages/runtime/src/templates/edge-shared
88
packages/runtime/lib
9-
packages/runtime/dist-types
9+
packages/runtime/dist-types
10+
jestSetup.js

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = {
4646
// TODO: re-enable after dropping support for Node 12
4747
'n/no-unsupported-features/es-syntax': 'off',
4848
'@typescript-eslint/no-extra-semi': 'off',
49+
'n/no-missing-import': 'off',
4950
},
5051
},
5152
{

.github/pull_request_template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- Before opening a pull request, ensure you've read our contributing guildines, https://github.com/netlify/next-runtime/blob/main/CONTRIBUTING.md. -->
2+
13
### Summary
24

35
<!-- Provide a brief summary of the change. -->

CONTRIBUTING.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
🎉 Thanks for considering contributing to this project! 🎉
44

5-
These guidelines will help you send a pull request.
5+
When contributing to this repository, please first discuss the change you wish to make via an
6+
[issue](https://github.com/netlify/next-runtime/issues/new/choose). Please use the issue templates. They are there to
7+
help you and to help the maintainers gather information.
68

7-
If you're submitting an issue instead, please skip this document.
9+
Before working on an issue, ask to be assigned to it. This makes it clear to other potential contributors that someone
10+
is working on the issue.
811

9-
If your pull request is related to a typo or the documentation being unclear, please click on the relevant page's `Edit`
10-
button (pencil icon) and directly suggest a correction instead.
12+
When creating a PR, please use the template. The information in the template helps maintainers review your pull request.```
1113

1214
This project was made with ❤️. The simplest way to give back is by starring and sharing it online.
1315

@@ -37,9 +39,9 @@ We use [Conventional Commit messages](https://www.conventionalcommits.org/) to a
3739

3840
Most common commit message prefixes are:
3941

40-
* `fix:` which represents bug fixes, and generate a patch release.
41-
* `feat:` which represents a new feature, and generate a minor release.
42-
* `feat!:`, `fix!:` or `refactor!:` and generate a major release.
42+
- `fix:` which represents bug fixes, and generate a patch release.
43+
- `feat:` which represents a new feature, and generate a minor release.
44+
- `feat!:`, `fix!:` or `refactor!:` and generate a major release.
4345

4446
## Releasing
4547

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ by targeting the `/_next/image/*` route:
4444

4545
## Disabling included image loader
4646

47-
If you wish to disable the use of the image loader which is bundled into the runtime by default, set the `DISABLE_IPX` environment variable to `true`.
47+
If you wish to disable the use of the image loader which is bundled into the runtime by default, set the `DISABLE_IPX` environment variable to `true`.
4848

4949
This should only be done if the site is not using `next/image` or is using a different loader (such as Cloudinary or Imgix).
5050

@@ -60,7 +60,7 @@ For more details on Next.js Middleware with Netlify, see the [middleware docs](h
6060

6161
### Limitations
6262

63-
Due to how the site configuration is handled when it's run using Netlify Edge Functions, data such as `locale` and `defaultLocale` will be missing on the `req.nextUrl` object when running `netlify dev`.
63+
Due to how the site configuration is handled when it's run using Netlify Edge Functions, data such as `locale` and `defaultLocale` will be missing on the `req.nextUrl` object when running `netlify dev`.
6464

6565
However, this data is available on `req.nextUrl` in a production environment.
6666

@@ -107,7 +107,15 @@ Edge runtime or middleware is enabled it will also generate edge functions for m
107107

108108
## Manually installing the Next.js Runtime
109109

110-
The Next.js Runtime installs automatically for new Next.js sites on Netlify. You can also install it manually like this:
110+
The Next.js Runtime installs automatically for new Next.js sites on Netlify. You can also install it manually in the
111+
following ways:
112+
113+
### From the UI (Recommended):
114+
115+
You can go to the [UI](https://app.netlify.com/plugins/@netlify/plugin-nextjs/install) and choose the site to install the Next.js Runtime on. This method
116+
is recommended because you will benefit from auto-upgrades to important fixes and feature updates.
117+
118+
### From `npm`:
111119

112120
```shell
113121
npm install -D @netlify/plugin-nextjs
@@ -117,9 +125,11 @@ npm install -D @netlify/plugin-nextjs
117125

118126
```toml
119127
[[plugins]]
120-
package = "@netlify/plugin-nextjs"
128+
package = "@netlify/plugin-nextjs"
121129
```
122130

131+
This method is recommended if you wish to pin the Next.js Runtime to a specific version.
132+
123133
## Manually upgrading from an older version of the Next.js Runtime
124134

125135
If you previously set these values, they're no longer needed and should be removed:
@@ -139,7 +149,7 @@ information on changes to how they are handled in this version. In particular, n
139149
files must be placed in `public`, not in the root of the site.
140150

141151
## Using with pnpm
142-
If your site uses pnpm to manage dependencies, currently you must [enable public hoisting](https://pnpm.io/npmrc#public-hoist-pattern).
152+
If your site uses pnpm to manage dependencies, currently you must [enable public hoisting](https://pnpm.io/npmrc#public-hoist-pattern).
143153
The simplest way to do this is to create a `.npmrc` file in the root of your project with the content:
144154

145155
```ini

cypress/integration/middleware/enhanced.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ describe('Enhanced middleware', () => {
3636
expect(response.body).to.have.nested.property('headers.x-geo-timezone')
3737
})
3838
})
39+
40+
it('handles uppercase i18n redirects properly ', () => {
41+
cy.visit('/de-DE/static')
42+
cy.get('#message').contains('This was static but has been transformed in')
43+
cy.contains("This is an ad that isn't shown by default")
44+
})
45+
46+
it('handles lowercase i18n redirects properly ', () => {
47+
cy.visit('/de-de/static')
48+
cy.get('#message').contains('This was static but has been transformed in')
49+
cy.contains("This is an ad that isn't shown by default")
50+
})
3951
})

demos/base-path/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"devDependencies": {
6+
"@netlify/next": "*",
67
"@netlify/plugin-nextjs": "*",
78
"@types/fs-extra": "^9.0.13",
89
"@types/jest": "^27.4.1",

demos/canary/package-lock.json

Lines changed: 0 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/canary/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"react-dom": "^18.2.0"
1515
},
1616
"devDependencies": {
17+
"@netlify/next": "*",
1718
"@netlify/plugin-nextjs": "*",
1819
"@types/fs-extra": "^9.0.13",
1920
"@types/jest": "^27.4.1",

demos/custom-routes/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"devDependencies": {
6+
"@netlify/next": "*",
67
"@netlify/plugin-nextjs": "*",
78
"@types/fs-extra": "^9.0.13",
89
"@types/jest": "^27.4.1",

demos/default/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
"@netlify/next": "*",
2222
"@reach/dialog": "^0.16.2",
2323
"@reach/visually-hidden": "^0.16.0",
24-
"@vercel/og": "^0.0.20",
24+
"@vercel/og": "^0.0.21",
2525
"next": "^13.0.3",
2626
"react": "^18.2.0",
2727
"react-dom": "^18.2.0"
2828
},
2929
"devDependencies": {
30+
"@netlify/next": "*",
3031
"@netlify/plugin-nextjs": "*",
3132
"@types/fs-extra": "^9.0.13",
3233
"@types/jest": "^27.4.1",

demos/middleware/middleware.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { NextResponse } from 'next/server'
22
import { MiddlewareRequest, NextRequest } from '@netlify/next'
33

4+
// Next.js replaces this with a stub polyfill. This import is just to test that stub.
5+
import pointlessFetch from 'isomorphic-unfetch'
6+
47
export async function middleware(req: NextRequest) {
58
let response
69
const { pathname } = req.nextUrl
@@ -58,6 +61,12 @@ export async function middleware(req: NextRequest) {
5861
}
5962

6063
if (pathname.startsWith('/shows')) {
64+
if (pathname.startsWith('/shows/222')) {
65+
response = NextResponse.next()
66+
const res = await pointlessFetch('http://www.example.com/')
67+
response.headers.set('x-example-server', res.headers.get('server'))
68+
}
69+
6170
if (pathname.startsWith('/shows/rewrite-absolute')) {
6271
response = NextResponse.rewrite(new URL('/shows/100', req.url))
6372
response.headers.set('x-modified-in-rewrite', 'true')

demos/middleware/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const nextConfig = {
99
generateBuildId: () => 'build-id',
1010
i18n: {
1111
defaultLocale: 'en',
12-
locales: ['en'],
12+
locales: ['en', 'de-DE'],
1313
},
1414
}
1515

demos/middleware/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@netlify/next": "*",
1313
"@netlify/plugin-nextjs": "*",
14+
"isomorphic-unfetch": "^3.1.0",
1415
"next": "^13.0.3",
1516
"react": "^18.2.0",
1617
"react-dom": "^18.2.0"
@@ -24,4 +25,4 @@
2425
"npm-run-all": "^4.1.5",
2526
"typescript": "^4.6.3"
2627
}
27-
}
28+
}

demos/next-auth/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"react-dom": "^18.2.0"
3131
},
3232
"devDependencies": {
33+
"@netlify/next": "*",
3334
"@netlify/plugin-nextjs": "*",
3435
"@types/fs-extra": "^9.0.13",
3536
"@types/jest": "^27.4.1",

demos/next-export/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"next": "^13.0.3"
77
},
88
"devDependencies": {
9+
"@netlify/next": "*",
910
"@netlify/plugin-nextjs": "*",
1011
"@types/fs-extra": "^9.0.13",
1112
"@types/jest": "^27.4.1",

0 commit comments

Comments
 (0)