- Reduce jest retries to 2 for a total of 3 attempts
- Disable retries in `invalid-href` test. I noticed jest retries don't help when this test fails (see log output of https://github.com/vercel/next.js/runs/904147534).
* Add with-sitemap Example
* Update README
* Update examples/with-sitemap/scripts/generate-sitemap.js
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-sitemap/package.json
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-sitemap/public/sitemap.xml
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update README
* Add .env Info to README
* Update examples/with-sitemap/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-sitemap/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-sitemap/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-sitemap/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* More helpful README
Updated to include more details about Next.js, link to the interactive tutorial, showcase, etc. Content mostly based on the official Next.js site.
* create-next-app readme
An updated readme with more details on options, benefits, etc.
* Apply edits from code review
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Remove redundant intro
* Update packages/create-next-app/README.md
* Remove introduction and list in showcase
* Apply suggestions from code review
* Update packages/next/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* Update Sentry example for use with Sentry/Vercel integration
* update linting
* Update link in readme
* Update readme, add comment
* Add step about commit SHA
* Updated readme
* Use if
* dont call sentry webpack plugin w/o a commit sha present
* Update examples/with-sentry/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* update release value
* prettier readme
* Updated note
Co-authored-by: Luis Alvarez <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* MongoDB Example
* Apply suggestions from code review
* Add changes based on feedback.
* clean up code with more descriptive props
* Use MongoDB in ServerSideProps instead of separate API route
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
Co-authored-by: Luis Alvarez D <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Fixes https://github.com/vercel/next.js/issues/15188
`parseRelativeUrl` was used on urls that weren't always relative. It was used to generate a cache key, but we actually don't need these cache keys to be relative if the urls aren't relative.
Also took a look at the overall static data fetching logic and found a few things:
- [x] cache key is unnecessarily transformed through `prepareRoute`, we can just cache by resolved `dataHref` and remove that function. Pretty sure that `prepareRoute` was also introducing edge cases with `assetPath` and `delBasePath`
- [x] there is [a bug in the caching logic](ebdfa2e7a3/packages/next/next-server/lib/router/router.ts (L898)) that made it fail on the second visit: it should be `Promise.resolve(this.sdc[pathname])` instead of `Promise.resolve(this.sdc[dataHref])`. Also added a test for this
- [x] ~converted to async await to improve stacktraces and readability.~ I assumed this was fine since I saw some async/awaits in that file already but it seems to just blow up the size of the non-modern bundle.
- [x] extracted nested `getResponse` function and define it top level. this should improve runtime performance
- [x] convert `_getStaticData` and `_getServerData` to class methods instead of properties. Not sure why they were defined as properties but I think they belong on the prototype instead.
- [x] remove `cb` property from `fetchNextData`, it's unnecessary and makes the async flow hard to understand. The exact same logic can go in the `.then` instead.
- [ ] data fetching logic [retries on 5xx errors](ebdfa2e7a3/packages/next/next-server/lib/router/router.ts (L157)), but not on network level errors. It should also retry on those. It should also not retry on every 5xx, probably only makes sense on 502, 503 and 504. (e.g. 500 is a server error that I wouldn't expect to succeed on a retry)
The overall result also is a few bytes smaller in size
- Introduces a lint rule which points towards the unwanted polyfill.io features.
- Aim here is to make the user aware that which of the requested features are actually required vs which are already covered under `next-polyfills`
Next step: If the remaining required polyfills amounts to a only a few KBs then its better to include them in 1P javascript and remove the third party render blocking script tag.
Fixes a broken link on https://nextjs.org/docs/routing/dynamic-routes
This path was updated from `pages/docs/[...slug].js` to `pages/docs/[[...slug]].js`, so I've updated the link and moved that example down to the "Optional catch all routes" section.
Next.js forcibly setting `module: 'esnext'` in `tsconfig.json` is necessary to prevent TypeScript from erroring on the following code:
```tsx
import dynamic from 'next/dynamic';
const A = dynamic(() => import('../A'));
```
```
ERROR in /Users/joe/Desktop/scratch/test-cjs/pages/index.tsx(5,25):
5:25 Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
> 5 | const A = dynamic(() => import("../test"));
```
However, users may want to use one of the many other targets for better interoperability with projects that co-exist with their Next.js project (like `commonjs`).
When cross referenced with:
```
Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.ts
```
That means we can permit any of these values:
```json5
parsedValues: [
ts.ModuleKind.ES2020,
ts.ModuleKind.ESNext,
ts.ModuleKind.CommonJS,
ts.ModuleKind.AMD,
],
```
This PR updates Next.js to allow those!
---
Fixes#15275