Skip to content

Commit e4256a6

Browse files
authored
Merge branch 'main' into rs/next11-isr-404
2 parents d7ea3fb + a5b8047 commit e4256a6

File tree

836 files changed

+33643
-14419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

836 files changed

+33643
-14419
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
'unicorn/filename-case': 0,
3030
'unicorn/no-array-push-push': 0,
3131
'unicorn/numeric-separators-style': 0,
32+
'max-lines': 0,
3233
},
3334
parserOptions: {
3435
sourceType: 'module',
@@ -46,6 +47,7 @@ module.exports = {
4647
// TODO: re-enable after dropping support for Node 12
4748
'n/no-unsupported-features/es-syntax': 'off',
4849
'@typescript-eslint/no-extra-semi': 'off',
50+
'n/no-missing-import': 'off',
4951
},
5052
},
5153
{

.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. -->

.github/workflows/cypress-canary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Run e2e (canary demo)
22
on:
33
pull_request:
4-
types: [opened, labeled, unlabeled, synchronize]
4+
types: [opened, synchronize]
55
push:
66
branches:
77
- main

.github/workflows/cypress-demo-nx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Run e2e (Nx monorepo)
22
on:
33
pull_request:
4-
types: [opened, labeled, unlabeled, synchronize]
4+
types: [opened, synchronize]
55
push:
66
branches:
77
- main

.github/workflows/cypress-demo-static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Run e2e (static root)
22
on:
33
pull_request:
4-
types: [opened, labeled, unlabeled, synchronize]
4+
types: [opened, synchronize]
55
push:
66
branches:
77
- main

.github/workflows/cypress-demo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Run e2e (default demo)
22
on:
33
pull_request:
4-
types: [opened, labeled, unlabeled, synchronize]
4+
types: [opened, synchronize]
55
push:
66
branches:
77
- main

.github/workflows/cypress-middleware.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Run e2e (middleware demo)
22
on:
33
pull_request:
4-
types: [opened, labeled, unlabeled, synchronize]
4+
types: [opened, synchronize]
55
push:
66
branches:
77
- main

.github/workflows/e2e-appdir.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Next.js appdir test suite
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
test-files: ${{ steps['set-test-files'].outputs['test-files'] }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: npm install
17+
- id: set-test-files
18+
name: Get test files
19+
# Extracts the list of all test files as JSON and trims to be relative to the test dir to be easier to read
20+
run:
21+
echo "test-files=$(npx jest -c test/e2e/jest.config.appdir.js --listTests --json | jq -cM 'map(.[env.PWD |
22+
length + 10:])')" >> $GITHUB_OUTPUT
23+
# echo "test-files=$(npx jest -c test/e2e/jest.config.all.js --listTests --json | jq -cM 'map(.[env.PWD | length
24+
# + 10:])')" >> $GITHUB_OUTPUT
25+
26+
test:
27+
runs-on: ubuntu-latest
28+
name: test (${{ matrix.test-file }})
29+
needs:
30+
- setup
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
# Creates a job for each chunk ID. This will be assigned one or more test files to run
35+
test-file: ${{ fromJson(needs.setup.outputs['test-files']) }}
36+
steps:
37+
- uses: actions/checkout@v3
38+
- run: npm install
39+
- name: Run tests
40+
run: npx jest --reporters=jest-junit --reporters=default -c test/e2e/jest.config.all.js ${{ matrix.test-file }}
41+
env:
42+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_BOT_AUTH_TOKEN }}
43+
NETLIFY_SITE_ID: 1d5a5c76-d445-4ae5-b694-b0d3f2e2c395
44+
NEXT_TEST_VERSION: canary
45+
- uses: actions/upload-artifact@v3
46+
if: ${{ always() }}
47+
name: Upload test results
48+
with:
49+
name: test-results
50+
path: reports/jest-*.xml
51+
report:
52+
name: Report appDir e2e test results
53+
runs-on: ubuntu-latest
54+
if: ${{ always() }}
55+
needs:
56+
- test
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: actions/download-artifact@v3
60+
with:
61+
path: reports
62+
- name: Combine reports
63+
# The test reporter can handle multiple files, but these have random filenames so the output is better when combined
64+
run: npx junit-report-merger test-results.xml reports/**/*.xml
65+
- uses: phoenix-actions/test-reporting@v10
66+
with:
67+
name: Jest Tests
68+
output-to: 'step-summary'
69+
path: 'test-results.xml'
70+
max-annotations: 49
71+
reporter: jest-junit

.github/workflows/e2e-next.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Next.js e2e test suite
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
test-files: ${{ steps['set-test-files'].outputs['test-files'] }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: npm install
17+
- id: set-test-files
18+
name: Get test files
19+
# Extracts the list of all test files as JSON and trims to be relative to the test dir to be easier to read
20+
run:
21+
echo "test-files=$(npx jest -c test/e2e/jest.config.js --listTests --json | jq -cM 'map(.[env.PWD | length +
22+
10:])')" >> $GITHUB_OUTPUT
23+
# echo "test-files=$(npx jest -c test/e2e/jest.config.all.js --listTests --json | jq -cM 'map(.[env.PWD | length
24+
# + 10:])')" >> $GITHUB_OUTPUT
25+
26+
test:
27+
runs-on: ubuntu-latest
28+
name: test (${{ matrix.test-file }})
29+
needs:
30+
- setup
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
# Creates a job for each chunk ID. This will be assigned one or more test files to run
35+
test-file: ${{ fromJson(needs.setup.outputs['test-files']) }}
36+
steps:
37+
- uses: actions/checkout@v3
38+
- run: npm install
39+
- name: Run tests
40+
run: npx jest --reporters=jest-junit --reporters=default -c test/e2e/jest.config.all.js ${{ matrix.test-file }}
41+
env:
42+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_BOT_AUTH_TOKEN }}
43+
NETLIFY_SITE_ID: 1d5a5c76-d445-4ae5-b694-b0d3f2e2c395
44+
# RUN_SKIPPED_TESTS: true
45+
46+
- uses: actions/upload-artifact@v3
47+
# upload test results
48+
if: ${{ always() }}
49+
name: Upload test results
50+
with:
51+
name: test-results
52+
path: reports/jest-*.xml
53+
report:
54+
name: Report Next.js e2e test results
55+
runs-on: ubuntu-latest
56+
if: ${{ always() }}
57+
needs:
58+
- test
59+
steps:
60+
- uses: actions/checkout@v3
61+
- uses: actions/download-artifact@v3
62+
with:
63+
path: reports
64+
- name: Combine reports
65+
# The test reporter can handle multiple files, but these have random filenames so the output is better when combined
66+
run: npx junit-report-merger test-results.xml reports/**/*.xml
67+
- uses: phoenix-actions/test-reporting@v10
68+
with:
69+
name: Jest Tests
70+
output-to: 'step-summary'
71+
path: 'test-results.xml'
72+
max-annotations: 49
73+
reporter: jest-junit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ packages/*/lib
150150

151151
# Cypress
152152
cypress/screenshots
153+
154+
# Test cases have node module fixtures
155+
!test/**/node_modules

.release-please-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packages/runtime": "4.29.1",
3-
"packages/next": "1.4.0"
2+
"packages/runtime": "4.29.3",
3+
"packages/next": "1.4.2"
44
}

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/default/dynamic-routes.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Dynamic Routing', () => {
4949
cy.request({ url: '/getStaticProps/3/', headers: { 'x-nf-debug-logging': '1' }, failOnStatusCode: false }).then(
5050
(res) => {
5151
expect(res.status).to.eq(404)
52-
expect(res.headers).to.have.property('x-nf-render-mode', 'odb')
52+
expect(res.headers).to.not.have.property('x-nf-render-mode')
5353
expect(res.body).to.contain('Custom 404')
5454
},
5555
)
@@ -102,7 +102,7 @@ describe('Dynamic Routing', () => {
102102
failOnStatusCode: false,
103103
}).then((res) => {
104104
expect(res.status).to.eq(404)
105-
expect(res.headers).to.have.property('x-nf-render-mode', 'odb')
105+
expect(res.headers).to.not.have.property('x-nf-render-mode')
106106
expect(res.body).to.contain('Custom 404')
107107
})
108108
})

cypress/integration/middleware/enhanced.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,27 @@ describe('Enhanced middleware', () => {
2525
.that.includes('This was static but has been transformed in')
2626
})
2727
})
28+
29+
it('adds geo data', () => {
30+
cy.request('/api/geo').then((response) => {
31+
expect(response.body).to.have.nested.property('headers.x-geo-country')
32+
expect(response.body).to.have.nested.property('headers.x-geo-region')
33+
expect(response.body).to.have.nested.property('headers.x-geo-city')
34+
expect(response.body).to.have.nested.property('headers.x-geo-longitude')
35+
expect(response.body).to.have.nested.property('headers.x-geo-latitude')
36+
expect(response.body).to.have.nested.property('headers.x-geo-timezone')
37+
})
38+
})
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+
})
2851
})

cypress/integration/nx/general.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ describe('Default site', () => {
1010
cy.url().should('eq', `${Cypress.config().baseUrl}/`)
1111
})
1212

13-
it('serves generated public files', async () => {
14-
cy.request('service-worker.js').then((res) => {
13+
it('serves generated public files', () => {
14+
cy.request('favicon.ico').then((res) => {
1515
expect(res.status).to.eq(200)
16-
expect(res.headers['content-type']).to.match(/javascript/)
16+
expect(res.headers['content-type']).to.match(/image/)
1717
})
1818
})
1919

0 commit comments

Comments
 (0)