Commit graph

71 commits

Author SHA1 Message Date
Tim Neutkens
08a7f7f31a
Enable SWC by default when there is no custom Babel config (#29811)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
Co-authored-by: padmaia <padmaia@users.noreply.github.com>
2021-10-23 10:21:44 +02:00
Javi Velasco
a815ba9f79
Implement Middleware RFC (#30081)
This PR adds support for [Middleware as per RFC ](https://github.com/vercel/next.js/discussions/29750). 

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-10-20 17:52:11 +00:00
JJ Kasper
a92a5caec2
Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00
Hunter Tunnicliff
877f982924
Use recommended pattern in testing example (#28404)
* Use recommended pattern in testing example

Since the official linter for testing library, `eslint-plugin-testing-library` recommends using `screen` to write queries, this MR updates the testing library example to follow the pattern recommended by the linter.

> DOM Testing Library (and other Testing Library frameworks built on top of it) exports a screen object which has every query (and a debug method). This works better with autocomplete and makes each test a little simpler to write and maintain.

> This rule aims to force writing tests using built-in queries directly from screen object rather than destructuring them from render result. Given the screen component does not expose utility methods such as rerender() or the container property, it is correct to use the render returned value in those scenarios.

See the `prefer-screen-queries` rules docs for more info: https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md

* Update devDependencies

* Install and configure test linting

* Use recommended pattern in test

* Update test names for consistency

* Update docs

* Set jest environment in each file

* Use root true in `with-jest` eslint config

* Ensure nested .eslintrcs are not loaded for repo lint

Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
2021-08-25 12:33:57 -05:00
Houssein Djirdeh
6645248d41
[ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-16 20:19:08 +02:00
Jiachi Liu
c51598268a
Leverage blocked page for _error (#26748)
## Enhance

simplify detection for visiting `_error`

x-ref: #26610
2021-07-01 00:08:36 +00:00
JJ Kasper
c2f0653bd3
Correct statusCode when visiting _error directly (#26610)
This fixes non-stop reloading when visiting `_error` directly in development caused by the `statusCode` being 200 unexpectedly while HMR returns the page as `invalid` which triggers `on-demand-entries` to reload the page. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

Fixes: https://github.com/vercel/next.js/issues/8036
x-ref: https://github.com/vercel/next.js/pull/8033
2021-06-28 12:50:53 +00:00
Chris Neven
d820542a15
fix(21606): consider scroll option when using shallow routing (#24888)
## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added

fixes [#21606](https://github.com/vercel/next.js/issues/21606)

### Description
When using shallow routing and wanting to scroll to top by setting the `scroll` option to `true` it didn't work. This PR fixes this issue.
2021-06-08 16:48:15 +00:00
Tim Neutkens
ed3e8f7125
Remove deprecated features (#25446)
* Remove deprecated features

In the next major version we'll want to merge this PR that removes some of the long-time deprecated features, it'll have a positive effect on bundle size.

* Update tests

* Update tests

* Change unsized to layout=fill in test

* Update sizes

* Update rotation test

* Update size limit test

* Update test

* Update test

* Update test
2021-06-02 10:11:03 -05:00
Tobias Koppers
08baf526ff
improve react-loadable-plugin (#24281)
Co-authored-by: JJ Kasper <jj@jjsweb.site>



## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added


Closes: https://github.com/vercel/next.js/issues/22741
2021-04-21 11:18:05 +00:00
Tim Neutkens
b34a0c98fa
Update err.sh links to use nextjs.org/docs/messages instead (#23353) 2021-03-29 10:25:00 +02:00
Rafael Bonalume Lebre
60e699555d
Fix #top anchor link scroll (#16638)
According to [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href) the page must scroll to the top with both "#" and "#top" anchors.

<img width="675" alt="Screen Shot 2020-08-27 at 7 20 19 PM" src="https://user-images.githubusercontent.com/13899924/91500693-582a5b80-e89a-11ea-803f-4592d458baba.png">
2021-01-30 04:32:00 +00:00
kaykdm
a5b0094677
Fix shallow routing scroll (#21437)
This ensures that Next.js will not scroll to the top of the page in shallow routing.

Fixes: https://github.com/vercel/next.js/issues/21386
Fixes: https://github.com/vercel/next.js/issues/21366
2021-01-22 18:03:29 +00:00
kaykdm
699a7aeaaa
Move hydration mis-match test suite (#21264)
In this [PR](https://github.com/vercel/next.js/pull/21065), it was suggested to move the test suite, but it was merged before fixing.
This is the fix for that, moving link-with-hash test suite to client-navigation suite

detail: https://github.com/vercel/next.js/pull/21065/files#r558425551
2021-01-18 04:05:41 +00:00
JJ Kasper
8bdff57b15
Update redbox tests (#20866)
This adds retrying for getting redbox content and ensures the `next.config.js` file is cleaned up for the dynamic-routing test suite.

x-ref: https://github.com/vercel/next.js/pull/20786#issuecomment-755929891
2021-01-07 18:06:40 +00:00
Joe Haddad
cb50b040ea
fix(next/head): assign bool attrs to match server (#20748)
This pull request correctly assigns boolean attributes for `<script />` to match the element as it is created by a server-side render.

Prior to this pull request, we'd double-execute `<script>` tags with the `async`, `defer`, or `nomodule` property.

---

Fixes #9070
2021-01-04 19:57:52 +00:00
Zach Bialecki
f412547248
Don't dedupe meta tags with the same name but unique keys (#17099)
Currently there is no way to add multiple meta tags with the same name attribute to the head of a page. This PR modifies the Head component to allow multiple meta tags with the same name if they have unique keys. 

This is important for integrating with certain services like Google Scholar and Swiftype.

Fixes #10183
2021-01-03 10:35:51 +00:00
Joe Haddad
7646921911
fix(router): consistent scroll behavior for Link/Router#push (#20606)
This pull request makes `Router#push` and `Router#replace` function identically to `<Link />`, i.e. reset scroll when the new render is complete.

Users can opt out of this new behavior via:
```tsx
const path = '/my-page'
router.push(path, path, { scroll: false })
```

---

Fixes #3249
2020-12-30 16:10:59 +00:00
Joe Haddad
8bab640ef6
fix(next/link): reset scroll before lifecycles (#20595)
This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes.

This is necessary for components that read scroll state on mount.

---

Fixes #6462
2020-12-30 04:33:08 +00:00
Joe Haddad
ab0e2744ee
Upgrade styled-jsx (#19241)
This fixes compatibility with React 17 and `styled-jsx`.

Fixes #19242
2020-11-17 16:53:35 +00:00
JJ Kasper
489b13d00e
Fix empty title in head (#17430)
This handles the case where the children on a head element are undefined and not a string or an array of strings. This doesn't currently handle sub-children on head elements so additional handling will be needed if this is a feature we would like to support although can be discussed/investigated separately from this fix. 

Fixes: https://github.com/vercel/next.js/issues/17364  
Fixes: https://github.com/vercel/next.js/issues/6388
Closes: https://github.com/vercel/next.js/pull/16751
2020-09-28 23:12:07 +00:00
JJ Kasper
8ecc359b6d
Update to check for overlay in client nav tests (#17002)
Closes: https://github.com/vercel/next.js/issues/14433
2020-09-11 08:37:19 +00:00
Jan Potoms
5aed1d2e35
Correct query behavior for falsey values to pre 9.5.1 behavior (#16608)
Fixes https://github.com/vercel/next.js/issues/16147
2020-09-10 15:12:37 +00:00
Tom Dohnal
eb4be226fd
notify component when route hash changes (#13894)
This resolves https://github.com/vercel/next.js/issues/13659
2020-08-06 22:04:47 +00:00
Jan Potoms
17716d1499
Add tests for querystring-relative urls (#15911) 2020-08-05 14:23:08 -04:00
Jan Potoms
5dbe0d0215
Allow absolute urls in router and Link (#15792)
Fixes https://github.com/vercel/next.js/issues/15639
Fixes https://github.com/vercel/next.js/issues/15820

To Do:
- [x] Doesn't work with `basePath` yet
2020-08-05 18:12:17 +00:00
Jan Potoms
91242ca6d7
Ignore history state not created by next.js (#15379)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-07-28 12:02:00 +02:00
Jan Potoms
574fe0b582
Make dynamic routes case-sensitive (#15444)
Fixes https://github.com/vercel/next.js/issues/15377
Closes https://github.com/vercel/next.js/pull/15394
2020-07-25 05:11:42 +00:00
Jan Potoms
2142b76e6b
Normalize trailing slashes (#13333)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-06-23 13:38:49 +02:00
Tim Neutkens
6c2ce70608
Remove buildId from server-side files (#14413)
Gets rid of the custom function for naming files by removing buildId from the file paths.
2020-06-22 21:12:36 +00:00
Tim Neutkens
bef9b56109
Update filename generation for client-side compilation (#14279)
Updates the way filenames are generated for browser compilation.
Notably:
- All entry bundles now have hashes in production, this includes pages (previously pages used a buildId in the path)
- The AmpFiles no longer depends on hardcoded bundle names, it uses the buildManifest instead (internals)
- All cases where we match the page name from the chunk/entrypoint name now use the same function `getRouteFromEntrypoint` (internals)
- In development we no longer include the "faked" `buildId` set to `development` for page files, instead we just use the `/_next/static/pages` path (was `/_next/static/development/pages`). This was changed as it caused unneeded complexity and makes generating the bundles easier (internals)
- Updated tons of tests to be more resilient to these changes by relying on the buildManifest instead of hardcoded paths (internals)

Follow up of these PRs:
https://github.com/vercel/next.js/pull/13759
https://github.com/vercel/next.js/pull/13870
https://github.com/vercel/next.js/pull/13937
https://github.com/vercel/next.js/pull/14130
https://github.com/vercel/next.js/pull/14176
https://github.com/vercel/next.js/pull/14268


Fixes #6303
Fixes #12087 
Fixes #1948
Fixes #4368
Fixes #4255
Fixes #2548
2020-06-20 19:59:47 +00:00
Tim Neutkens
76fddcd7ef
Use chunkhash instead of buildId for pages (#13937)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-06-11 10:57:24 +02:00
Tim Neutkens
e125d905a0
Clean up render.tsx options (#13759)
Went through and removed a bunch of internal options which are just pass-through values of buildManifest

Closes #13851
2020-06-06 23:00:03 +00:00
Jan Potoms
1b36f0c029
Fix pages/index.js and pages/index/index.js behavior (#13699)
Disambiguate between pages/index.js and pages/index/index.js so that they resolve differently.
It all started with a bug in pagesmanifest that propagated throughout the codebase. After fixing pagesmanifest I was able to remove a few hacks here and there and more logic is shared now. especially the logic that resolves an entrypoint back into a route path. To sum up what happened:

- `getRouteFromEntrypoint` is the inverse operation of `getPageFile` that's under `pages/_document.tsx`
- `denormalizePagePath` is the inverse operation of `normalizePagePath`.

Everything is refactored in terms of these operations, that makes their behavior uniform and easier to update/patch in a central place. Before there were subtle differences between those that made `index/index.js` hard to handle.

Some potential follow up on this PR:
- [`hot-reloader`](https://github.com/vercel/next.js/pull/13699/files#diff-6161346d2c5f4b7abc87059d8768c44bR207) still has one place that does very similar behavior to `getRouteFromEntrypoint`. It can probably be rewritten in terms of `getRouteFromEntrypoint`.
- There are a few places where `denormalizePagePath(normalizePagePath(...))` is happening. This is a sign that `normalizePagePath` is doing some validation that is independent of its rewriting logic. That should probably be factored out in its own function. after that I should probably investigate whether `normalizePagePath` is even still needed at all.
- a lot of code is doing `.replace(/\\/g, '')`. If wanted, that could be replaced with `normalizePathSep`.
- It looks to me like some logic that's spread across the project can be centralized in 4 functions 
  - `getRouteFromEntrypoint` (part of this PR)
  - its inverse `getEntrypointFromRoute` (already exists in `_document.tsx` as `getPageFile`)
  - `getRouteFromPageFile` 
  - its inverse `getPageFileFromRoute` (already exists as `findPageFile ` in `server/lib/find-page-file.ts`)

  It could be beneficial to structure the code to keep these fuctionalities close together and name them similarly.
 - revise `index.amp` handling in pagesmanifest. I left it alone in this PR to keep it scoped, but it may be broken wrt nested index files as well. It might even make sense to reshape the pagesmanifest altogether to handle html/json/amp/... better
2020-06-04 17:32:45 +00:00
Joe Haddad
30fbd9adc9
Speedup tests (#13461)
This PR checks if our tests can be ran faster by disabling source maps unless they're used for the purpose of testing.
2020-05-29 07:57:51 +00:00
Joe Haddad
b7e17e09e5
Update references to zeit/next.js (#13463) 2020-05-27 17:51:11 -04:00
Jan Potoms
cefbcadf45
Make page path case sensitive in dev (#8848)
URL paths are case sensitive, MacOS file system is case insensitive. This PR makes sure development mode doesn't find pages that don't have the casing as specified in the URL.

Will clean up and write a test when agreed on this approach.

Fixes https://github.com/zeit/next.js/issues/8825
Fixes https://github.com/zeit/next.js/issues/8847
Fixes https://github.com/zeit/next.js/issues/9080
2020-05-26 12:50:28 +00:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Jan Potoms
32057c849d
Use the jest-circus test runner (#12974) 2020-05-16 16:56:06 -04:00
Joe Haddad
0d49f22e11
Remove react-error-overlay (#12942) 2020-05-15 14:14:44 -04:00
Joe Haddad
ae1daea355
Enable Fast Refresh by Default (#12640) 2020-05-10 19:25:57 -04:00
Shu Uesugi
cc139b8d89
More renaming ZEIT → Vercel (#12649) 2020-05-09 17:21:53 +02:00
JJ Kasper
cc9678056e
Fix inconsistent handling for /index (#11643)
* Fix inconsistent handling for /index

* Add more test cases

* Add pages/index/index.js test

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-07 13:24:53 -04:00
Tim Neutkens
1e505e860f
Ensure an accessible default viewport meta tag (#10823)
* fix: remove minimum-scale from default viewport

* update test

* remove extra comma

* drop initial-scale
2020-03-05 11:03:15 +01:00
JJ Kasper
b2624012ea
Remove old eslint-ignores from unstable_ prefix (#10740) 2020-02-28 12:40:27 -05:00
Lachlan Campbell
c480c37c8e
Skip undefined attribute in Head (#9856)
* Fix #8655, skip rendering meta tags with undefined props

* Filter all tags, not just meta

* Only render defined props

* Remove filtering of undefined strings

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Replace Object.entries

* Remove filtering code

* Simplify code

* Add test

* Add tests for undefined head prop value and tweak check

* Update to strip undefined prop values to match react

* Update head.js

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-02-03 14:55:14 -05:00
Richard Scotten
33b22796c7 Add option arg to changeState when onlyAHashChange (#10003)
* added option to changeState when onlyAHashChange

* added integration tests

* segregated tests because they caused other tests to fail

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-18 20:35:12 -06:00
JJ Kasper
f89d55f10d Add selenium-webdriver and testing cross-browser in PRs (#9821)
* Migrate from wd to selenium-webdriver

* Add chaining for next-webdriver

* Re-add browserStackLocal global for teardown

* Add additional element methods

* Use freshWindow helper for chrome

* Add selenium-server

* Add cross-env for windows compat

* Fix single quote windows

* Update production preload tests

* Update preload tests count

* Update CircleCi for testing other browsers

* Update CI configs

* Update config

* Add browser.url command

* Add more methods

* Update xcode version

* Make sure to add chromedriver to path

* Add forceExit flag

* Update config

* Update config

* Disable safari

* Fix bug in test

* Add teardown logging

* Update jest teardown

* Move testing ie11 to Azure

* Update job names

* Remove force exiting on long teardown

* Update Azure config

* Re-add safari testing with BrowserStack

* Update config

* Update prefetch tests for ie11

* Update prefetch for safari and ids for ie11 testing

* trigger prefetching manually in ie
2019-12-26 15:01:22 -05:00
Nick Zahn
5909e67765 Fix/improve test for deduplication of tags with same key (#9793) 2019-12-24 16:22:04 +01:00
Adam Stankiewicz
9c9f0609a0 Fix deduplicating dynamic (array) meta tags (#9315) 2019-11-26 12:27:33 -05:00