Commit graph

32 commits

Author SHA1 Message Date
Tim Neutkens
c7e2a1df6a
Use SWC for Next.js core client files (#27196)
Replaces Babel with SWC for Next.js core client-side files.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## 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-07-28 15:10:51 +00:00
Tim Neutkens
fdabeb7098
Use SWC to compile Next.js core server files (#27167)
- Use SWC to compile Next.js core server files
- Ensure only @babel/runtime/helpers/interopRequireDefault helper is used

Just an initial comparison to compare size difference of this change.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## 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-07-14 18:12:04 +00:00
Tim Neutkens
136b754396
Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00
Brandon Bayer
755a1b412c
Strongly type Router.events.on and Router.events.off (#26456)
This strongly types `Router.events.on` and `Router.events.off`. Previously the event type was `string` but now it's `'routeChangeStart' | 'beforeHistoryChange' | 'routeChangeComplete' | 'routeChangeError' | 'hashChangeStart' | 'hashChangeComplete'`


## Bug

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

Closes #25679
Closes #23753
Closes #15497
2021-06-22 18:43:09 +00:00
Rob Vermeer
27d78a5d41
Fix domain locales not available on client (#26083)
* bug: Fix domain locales not available on client

* Add test case

* update tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-22 11:55:52 -05:00
Brandon Chang
e261887926
Update comments for clarity & grammar in router.ts (#25947) 2021-06-11 11:51:52 +02:00
JJ Kasper
9793e9004f
Add isPreview field to router (#21638)
This adds an `isPreview` field to the `next/router` to allow detecting when in preview mode. 

Closes: https://github.com/vercel/next.js/issues/14903
2021-02-18 18:34:33 +00:00
JJ Kasper
55e4a3d1ad
Only create locale domain links if on locale domain (#22032)
This updates to only create locale domain links if the current hostname is a locale domain to prevent making links unvisitable in development and preview environments where the configured locale domains don't point to the current build. 

Closes: https://github.com/vercel/next.js/issues/21211
Closes: https://github.com/vercel/next.js/issues/22011
2021-02-11 10:18:24 +00:00
tarunama
575fcf3fcf
refactor(client): add return types (#20728)
## summary
- Explicitly define return types
- Add type of  [Observer](https://github.com/vercel/next.js/pull/20728/files#diff-5de64b97b2f26e4e41d197a8295e8750825c75b8ca557a4b947a4c3569345974R7)
2021-01-05 15:11:37 +00:00
JJ Kasper
3a9d18b549
Add isReady field on router (#20628)
Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server.

Closes: https://github.com/vercel/next.js/issues/8259
Closes: https://github.com/vercel/next.js/pull/9370
2020-12-31 16:54:32 +00:00
JJ Kasper
bbc1a21c74
Update to have default locale matched on root (#17669)
Follow-up PR to https://github.com/vercel/next.js/pull/17370 when the path is not prefixed with a locale and the default locale is the detected locale it doesn't redirect to locale prefixed variant. If the default locale path is visited and the default locale is visited this also redirects to the root removing the un-necessary locale in the URL. 

This also exposes the `defaultLocale` on the router since the RFC mentions `Setting a defaultLocale is required in every i18n library so it'd be useful for Next.js to provide it to the application.` although doesn't explicitly spec where we want to expose it. If we want to expose it differently this can be updated.
2020-10-08 11:12:17 +00:00
JJ Kasper
b2d1d87e7f
Add initial changes for i18n support (#17370)
This adds the initial changes outlined in the [i18n routing RFC](https://github.com/vercel/next.js/discussions/17078). This currently treats the locale prefix on routes similar to how the basePath is treated in that the config doesn't require any changes to your pages directory and is automatically stripped/added based on the detected locale that should be used. 

Currently redirecting occurs on the `/` route if a locale is detected regardless of if an optional catch-all route would match the `/` route or not we may want to investigate whether we want to disable this redirection automatically if an `/index.js` file isn't present at root of the pages directory. 

TODO: 

- [x] ensure locale detection/populating works in serverless mode correctly
- [x] add tests for locale handling in different modes, fallback/getStaticProps/getServerSideProps

To be continued in fall-up PRs

- [ ] add tests for revalidate, auto-export, basePath + i18n
- [ ] add mapping of domains with locales
- [ ] investigate detecting locale against non-index routes and populating the locale in a cookie

x-ref: https://github.com/vercel/next.js/issues/17110
2020-10-07 21:11:01 +00:00
Tim Neutkens
e72ac76422
Remove tslint disables (#16116)
We no longer use tslint so these comments don't do anything.
2020-08-12 14:39:07 +00:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Maxi Gimenez
0bc0760356
chore(next): link/router/document missing types (#12692) 2020-05-10 17:52:30 -04:00
JJ Kasper
d3e308a79f
Add basePath in link component and add/remove it consistently (#9988)
* Add basePath in link component and add/remove it consistently

* Update to not use regex for delBasePath

* Expose addBasePath as router method

* Revert "Expose addBasePath as router method"

This reverts commit 40fed596195c6affabf837e42d472452768e13a3.

* Expose basePath as router field

* Apply suggestion

* Expose basePath as router field

* remove un-used vars

* Update externals

* Apply lint fix

* Update size-limit test

* Update prefetch
2020-04-14 09:50:39 +02:00
Joe Haddad
6d5c48742b
Implement isFallback Router Property (#10539)
This adds a `isFallback` property to detect if the page is being rendered in "fallback" mode or normal mode.
Accessed via the `useRouter()` hook.

---

Closes #10527
2020-02-15 13:01:10 -05:00
Tim Neutkens
6988a2e0a5
Use builtins for React transform (#10207)
* Disable core-js on Next.js core files as it's not transforming anything important

* Move babel options to taskr plugin

* Disable transform-runtime for pages dir

* Disable correctly

* Disable corejs for core files

* Temporarily check if this fixes the error

* Use builtIns and exclude async-to-generator

* Update index.test.js
2020-01-22 16:24:02 +01:00
Tim Neutkens
9b999b1ce3
Convert wrapper class to function component (#9095)
* Convert wrapper class to function component

* Remove unneeded export

* Check versions of chrome and chromedriver

* Update to chromedriver 76

* Revert config.yml

* Update with-router.tsx
2019-11-09 14:56:59 -08:00
Gerald Monaco
beed775e55 Update legacy _app context (#9083) 2019-10-16 11:39:49 +02:00
Tim Neutkens
2ba352da39 Move next-server back into next package (#8613)
* Initial move

* Make emitting work

* Update paths

* Remove leftover files

* Add correct externals configuration

* Import correct path

* Update path to work with ts-server test

* Update lib directory

* Compile next-server/lib
2019-09-04 10:00:54 -04:00
Luis Fernando Alvarez D
d4d5ad4ba5 Remove propertyFields from the client router (#8219)
* Remove forEach over the components prop

* Remove propertyFields
2019-08-06 15:42:33 +02:00
JJ Kasper
4850bd03ef Provide AppTree to getInitialProps for getDataFromTree (#7732)
* Provide AppContainer to getInitialProps for getDataFromTree

* Update to only pass AppTree component instead of AppContainer

* Clean up props and remove extra imports

* Make updates from review

* De-dupe AppTree a bit

* Re-use wrapApp in router

* Remove un-needed change

* revert changes to examples until on stable

* Add test for AppTree
2019-07-30 14:00:19 -04:00
Joe Haddad
f8b56da7e1 Revert "Improve type definitions" (#8098)
Reverts zeit/next.js#8097

This PR caused bundle sizes to increase. We need to fix this bug before we continue adding invalid TypeScript exports to our code.
2019-07-25 13:58:24 +00:00
Adam Misiorny
55e87ea50c Improve types (#8097) 2019-07-24 21:48:38 -05:00
Luis Fernando Alvarez D
b94123ccc9 Improve exported router types (#7853)
* Added the RouteUrl type and improved router types

* Added more tests for router types

* Add build test for typescript types

* Add next-env.d.ts to the typescript test

* Removed next-env.d.ts

* Added next-env.d.ts to gitignore

* Remove route url re-exports

* renamed PublicRouterInstance to be NextRouter

* export the Url type

* Replaced BaseRouter with NextRouter in server/utils

* Don't export the Url type

* Update tsconfig.json
2019-07-11 13:35:39 -04:00
Tim Neutkens
3e51ddb8af
Move syntax formatting to prettier (#7454)
* Run prettier over packages/**/*.js

* Run prettier over packages/**/*.ts

* Run prettier over examples

* Remove tslint

* Run prettier over examples

* Run prettier over all markdown files

* Run prettier over json files
2019-05-29 13:57:26 +02:00
Lukáš Huvar
e0c3545829 Remove components from client router (#7281) 2019-05-07 16:20:13 -05:00
Luis Fernando Alvarez D
ab22b58818
Allow _app and _document to be extended with other props (#7184) 2019-04-29 11:47:40 -05:00
Luis Fernando Alvarez D
b963863106 Prefer type over interface (#7164) 2019-04-26 09:37:57 +02:00
Tim Neutkens
c9d599b698
Add .d.ts for next-server (#7133)
* Add .d.ts files

* Drop next declarations from index.d.ts

* Bring back number of errors

* Fix more errors

* Fix rewriteUrlForExport
2019-04-24 16:47:50 +02:00
Luis Fernando Alvarez D
c48340cd8c
Move next/router to Typescript (#7019)
Added types to next/router
2019-04-15 23:00:48 -05:00
Renamed from packages/next/client/router.js (Browse further)