Skip to content

Commit 3d93c5f

Browse files
authored
Merge branch 'main' into main
2 parents 46a307f + df2aee1 commit 3d93c5f

File tree

231 files changed

+9912
-2612
lines changed

Some content is hidden

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

231 files changed

+9912
-2612
lines changed

.eslintignore

+2-1
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

+1
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

+2
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/e2e-next.yml

+68-10
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,77 @@ on:
66
branches: [main]
77

88
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
test-files: ${{ steps['set-test-files'].outputs['test-files'] }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- run: npm install
16+
- id: set-test-files
17+
name: Get test files
18+
# Extracts the list of all test files as JSON and trims to be relative to the test dir to be easier to read
19+
run:
20+
echo "test-files=$(npx jest -c test/e2e/jest.config.js --listTests --json | jq -cM 'map(.[env.PWD | length +
21+
10:])')" >> $GITHUB_OUTPUT
22+
# echo "test-files=$(npx jest -c test/e2e/jest.config.all.js --listTests --json | jq -cM 'map(.[env.PWD | length
23+
# + 10:])')" >> $GITHUB_OUTPUT
24+
925
test:
10-
name: E2E tests
1126
runs-on: ubuntu-latest
27+
name: test (${{ matrix.test-file }})
28+
needs:
29+
- setup
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
# Creates a job for each chunk ID. This will be assigned one or more test files to run
34+
test-file: ${{ fromJson(needs.setup.outputs['test-files']) }}
1235
steps:
13-
- uses: actions/checkout@v2
14-
- name: Installing with LTS Node.js
15-
uses: actions/setup-node@v2
16-
with:
17-
node-version: 'lts/*'
18-
- name: NPM Install
19-
run: npm install
20-
- name: Run Next.js e2e test suite
21-
run: npm run test:next
36+
- uses: actions/checkout@v3
37+
- run: npm install
38+
- name: Run tests
39+
run: npx jest --reporters=jest-junit --reporters=default -c test/e2e/jest.config.all.js ${{ matrix.test-file }}
2240
env:
2341
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_BOT_AUTH_TOKEN }}
2442
NETLIFY_SITE_ID: 1d5a5c76-d445-4ae5-b694-b0d3f2e2c395
43+
# RUN_SKIPPED_TESTS: true
44+
# - uses: phoenix-actions/test-reporting@v10
45+
# if: ${{ always() }}
46+
# name: Report Test Results
47+
# # Generates annotations for the test failures
48+
# id: test-report
49+
# with:
50+
# name: E2E Test chunk ${{ matrix.chunk }}
51+
# path: 'reports/**/*.xml' # Path to test results (inside artifact .zip)
52+
# output-to: 'checks'
53+
# max-annotations: 49 # Maximum number of annotations to be created
54+
# reporter: jest-junit # Format of test results
55+
56+
- uses: actions/upload-artifact@v3
57+
# upload test results
58+
if: ${{ always() }}
59+
name: Upload test results
60+
with:
61+
name: test-results
62+
path: reports/jest-*.xml
63+
report:
64+
runs-on: ubuntu-latest
65+
if: ${{ always() }}
66+
needs:
67+
- test
68+
steps:
69+
- uses: actions/checkout@v3
70+
- uses: actions/download-artifact@v3
71+
with:
72+
path: reports
73+
- name: Combine reports
74+
# The test reporter can handle multiple files, but these have random filenames so the output is better when combined
75+
run: npx junit-report-merger test-results.xml reports/**/*.xml
76+
- uses: phoenix-actions/test-reporting@v10
77+
with:
78+
name: Jest Tests
79+
output-to: 'step-summary'
80+
path: 'test-results.xml'
81+
max-annotations: 49
82+
reporter: jest-junit

.gitignore

+3
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

CONTRIBUTING.md

+9-7
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

+15-5
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

+12
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

+1
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

-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/canary/package.json

+1
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

+1
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

+2-1
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/next.config.js

+1-1
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/next-auth/package.json

+1
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

+1
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)