Commit graph

317 commits

Author SHA1 Message Date
Tim Neutkens
355078c350
Separate toRoute function (#6766)
Because Typescript output is turned to commonjs for these modules currently it’s better to do this. Also convert withRouter to typescript, making it smaller.
2019-03-23 23:00:46 +01:00
Tim Neutkens
cf7f707ff9
Remove PropTypes from _error and next/dynamic (#6763)
* Remove proptypes

* Remove loadable capture in favor of React.createContext

* Add loadable context file

* Make sure we use the context value instead
2019-03-23 21:00:31 +01:00
Joe Haddad
efdbd87625
v8.0.4-canary.19 2019-03-21 22:47:57 -04:00
JJ Kasper
397674c40e Fix export not checking amp right for /index.amp (#6748)
* Fix export not checking amp right for /index.amp

* Add test checking hybrid amp index behavior
2019-03-21 21:40:42 -04:00
Joe Haddad
34be001749
v8.0.4-canary.18 2019-03-20 16:06:57 -04:00
JJ Kasper
19f39511f4
v8.0.4-canary.17 2019-03-20 13:24:02 -05:00
Joe Haddad
773a3a21c5 v8.0.4-canary.16 2019-03-20 11:43:07 -04:00
Joe Haddad
b5880717e6
v8.0.4-canary.15 2019-03-20 09:21:21 -04:00
JJ Kasper
18af71c011 Add support for amp to export (#6725)
* Add support for amp to export

* Anchor canonical replace

* Disable profiling test for now

* Centralize amp utils to next-server/server/utils

* re-enable profiling test
2019-03-19 23:53:47 -04:00
Joe Haddad
2cd0e99af4
v8.0.4-canary.14 2019-03-19 15:49:37 -04:00
JJ Kasper
bce75ae9c3
Add checking for corresponding pages for link tags (#6719) 2019-03-19 14:01:42 -05:00
JJ Kasper
2cc8365d82
v8.0.4-canary.13 2019-03-19 10:16:06 -05:00
JJ Kasper
12cbb934b3 Add support for creating AMP pages (#6706)
* Add support for .amp.js pages and
resolving /page?amp=1 to page.amp.js

* Update amp tests

* Update example and clean up amp page resolving

* Add nested amp test

* page => normalizedPage

* Add type to page options

* Add handling of amp with all pageExtensions
and normalize page

* Make sure findPageFile only falls back to
amp if enabled
2019-03-18 23:24:21 -04:00
Tim Neutkens
ad856eb299 v8.0.4-canary.12 2019-03-18 13:30:22 +01:00
JJ Kasper
87bd1c3b09
Add error handling for error being thrown in _app getinitialProps (#6680)
* Fix handling of undefined being thrown
in getInitialProps and update integration test

* Update test

* Move test to app-document
2019-03-17 11:43:03 -05:00
JJ Kasper
a6ddaefe22 Add experimental exportTrailingSlash config (#6664)
By default when `next export`ing a Next.js application we will automatically append a `/` to all urls to be fully compatible with the directory structure being output.

However since most platforms support directory indexes it makes sense to change this default in the future.

This PR adds `exportTrailingSlash` as experimental flag. We'll try this out for a bit on nextjs.org / zeit.co/docs before introducing it as new option.

The default value is `true` as this is the current behavior in stable Next.js.

```
{
  experimental: {
    exportTrailingSlash: false
  }
}
```

⚠️ as with all experimental flags being added this is subject to breaking between canary/stable versions.
2019-03-17 00:54:58 +01:00
Joe Haddad
d5f736d623
v8.0.4-canary.11 2019-03-15 10:54:23 -04:00
Tim Neutkens
83334f1110
Convert change/getRouteInfo to not use async (#6648)
More updates to the router coming.
2019-03-14 19:43:29 +01:00
JJ Kasper
1e4372c627
Show a better error when someone throws undefined (#6646)
* Show a better error when someone throws undefined

* Update error wording

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Update error wording in test

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Update test and add check for statusCode
before updating error
2019-03-13 13:39:05 -05:00
Tim Neutkens
b7bd1f775a
Convert router/router.js to typescript (#6644)
- Removed `fetchRoute` as it was only used once (internal method, non-breaking)
- Convert files to TypeScript
- Don't extend `ServerRouter` from `Router` as it introduces unneeded overhead, we only have to provide `pathname` `asPath` and `query` for `withRouter`. Also added `events` even though it shouldn't be called on SSR, just making sure we don't break things.
2019-03-13 15:56:20 +01:00
JJ Kasper
c685b9b0d0
Apply workaround for Firefox bug (#6630)
* Apply workaround for Firefox bug
and shallow routing

* Update to only apply workaround when needed

* Add TODO for future removal

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
2019-03-12 16:36:25 -05:00
JJ Kasper
e2944c0aca
Fix loading showing before pastDelay (#6628) 2019-03-12 14:12:49 -05:00
JJ Kasper
58cbd0aa4e Fix HMR failing when rendering with /index (#6541)
Fixes: #6497
2019-03-12 12:40:49 +01:00
JJ Kasper
b6dfb44a8f
v8.0.4-canary.10 2019-03-12 01:27:01 -05:00
Tim Neutkens
b32e65a830 Add experimental profiling flag (#6594)
* Add experimental profiling flag

* Update config.js
2019-03-11 13:53:24 -04:00
Joe Haddad
eee0d6ce8d Default to the previous CPU calculation (#6605) 2019-03-11 17:42:54 +01:00
JJ Kasper
852a62bf56 Add experimental cpus config and use CircleCI env var (#6604)
* Add using CircleCI env var for max workers
and expose webpack to config

* Expose experimental cpu config

* Fix typo

* Remove log
2019-03-11 17:33:30 +01:00
Tim Neutkens
3c04b0f4e1
Don’t prefetch outside of production (#6578)
Fixes #1827 

This doesn't affect integration tests as they'd use `next build` which forces production mode. Development forces `development`.
2019-03-08 20:08:57 +01:00
JJ Kasper
41278a62f2
Remove _error page from blocked pages (#6579) 2019-03-08 13:00:09 -06:00
Tim Neutkens
654860e7b5 v8.0.4-canary.9 2019-03-07 19:57:48 +01:00
JJ Kasper
e112df4319 Throw error when router methods are used in SSR (#6550)
* Update to use the correct router instance in withRouter so error is
thrown when router method is used during SSR

* Revert changes to with-router and add error to methods on
direct router instance

* Extend Router and override methods with error instead

* Update ServerRouter, add err.sh, and add test
2019-03-07 17:13:38 +01:00
Tim Neutkens
f177ce4291 v8.0.4-canary.8 2019-03-06 13:10:21 +01:00
Tim Neutkens
8f25bc6871 v8.0.4-canary.7 2019-03-03 20:47:05 +01:00
Joe Haddad
e52508fbf6
Consolidate traditional and AMP rendering methods (#6506)
* Format a few documents

* Drop `renderToAMP` and `renderToAMPHTML`
2019-03-01 15:35:43 -05:00
Joe Haddad
494889acd8
Format a few documents (#6505) 2019-03-01 14:51:13 -05:00
JJ Kasper
912e45b506 Show error when router or Component are returned in _app.js (#6487)
* Show error when `router` or `Component` are returned in _app.js
getInitialProps

* Update to only show error in dev mode

* Update packages/next-server/server/render.tsx

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
2019-03-01 18:08:27 +01:00
Joe Haddad
a8d7a6ce42 v8.0.4-canary.6 2019-02-28 15:38:12 -05:00
Joe Haddad
68123d8b8d v8.0.4-canary.5 2019-02-28 14:35:21 -05:00
tangye
704edcc1ba Make router UrlIsNew comparing method work as expected (#6383)
* make router UrlIsNew comparing method work as expected

* Remove shallow-equals from router and update urlIsNew check

* Remove shallow-equals test since it is no longer used

* Add integration test for asPath query
2019-02-28 12:53:29 -06:00
JJ Kasper
1c1d5d01f8 Throw error when Promise is returned in next.config (#6476)
After discussion, it was decided we should throw an error when a promise is returned in `next.config.js` as this isn't supported

Fixes: #6416
2019-02-28 14:39:51 +01:00
Tim Neutkens
88388f79b4 v8.0.4-canary.4 2019-02-27 13:20:30 +01:00
Connor Davis
b8d3b7e69e
v8.0.4-canary.3 2019-02-26 16:07:42 -06:00
Joe Haddad
6ffc2ffc2a v8.0.4-canary.2 2019-02-25 17:55:33 -05:00
Joe Haddad
f15cfeba0a
AMP automatic page refreshing in dev (#6392)
* AMP page reload

* Fix comment

* Skip dev files in production

* Polyfill event source

* Add HMR test for AMP

* Use webdriver

* Use a dynamic server for HMR test

* ffs
2019-02-25 17:00:14 -05:00
Tim Neutkens
f7ee137f9c v8.0.4-canary.1 2019-02-23 12:25:34 +01:00
Tim Neutkens
41ed6803ac v8.0.4-canary.0 2019-02-23 11:21:29 +01:00
Tim Neutkens
b88addfcd5
Remove event-source-polyfill dependency (#6407) 2019-02-22 16:23:58 +01:00
Tim Neutkens
a99323cbc0 v8.0.3 2019-02-22 13:35:24 +01:00
Tim Neutkens
ca7b77292b v8.0.3-canary.0 2019-02-22 10:39:39 +01:00
Tim Neutkens
016d41f2a8 v8.0.2 2019-02-22 00:17:13 +01:00
Tim Neutkens
ce7dcaeadb v8.0.2-canary.7 2019-02-21 15:43:00 +01:00
Tim Neutkens
faf69b45c2 v8.0.2-canary.6 2019-02-21 01:09:43 +01:00
Isaac Hinman
6e23b75c90 feat: Validate url.format calls (#6379) 2019-02-20 17:01:45 -05:00
Connor Davis
61de215e04
Move webpack config to TypeScript (#6348) 2019-02-20 13:24:02 -06:00
Tim Neutkens
0bf5041ef4 v8.0.2-canary.5 2019-02-20 17:05:55 +01:00
Andrew Gerard
369ac488e0 Assign deep defaults for custom config (#6359)
* assign deep defaults for custom config

* allow for new object type defaults

* fix linting
2019-02-20 14:00:03 +01:00
Tim Neutkens
b0a9b99b7f v8.0.2-canary.4 2019-02-20 13:30:27 +01:00
Connor Davis
fcf1167cd4 Upgrade standard and fix files (#6358)
Upgrades `standard` to major version 12
2019-02-19 22:45:07 +01:00
JJ Kasper
bf69357f27 Remove onDemandEntries WebSocket server in favor of EventSource connection (#6354)
After talking with @timneutkens it was decided it'd be more streamlined to replace the onDemandEntries WebSocket with an alternative. Using the EventSource connection gives us these benefits over the WebSocket one:

- less code needed
- no extra server running
- no extra config for onDemandEntries
2019-02-19 21:58:47 +01:00
Joe Haddad
6dfcacb7bf
Use a query parameter for AMP pages instead of new route (#6336)
Per consensus in a mixed-application scenario, we'll use the `amp` query parameter convention.
2019-02-18 09:44:21 -05:00
Tim Neutkens
9f2eb85de3 v8.0.2-canary.3 2019-02-17 20:48:43 +01:00
Tim Neutkens
dd9811b206
Fix recursive hydration of next/dynamic (#6326)
Fixes #5347

The main issue is that we were waiting only 1 level of dynamic imports, so the dynamic imports nested inside other dynamic import files were not awaited. This would cause either a flash of loading states or you wouldn't see the loading state (because of preload) but it would then show a hydration warning in development.

Thanks to @arthens for providing the reproduction that I modelled the tests after.
2019-02-17 19:52:00 +01:00
Tim Neutkens
774af7fa0b v8.0.2-canary.2 2019-02-17 13:15:42 +01:00
Tim Neutkens
3882979236 v8.0.2-canary.1 2019-02-16 17:12:27 +01:00
Tim Neutkens
036f5bf11b v8.0.2-canary.0 2019-02-16 16:41:30 +01:00
Tim Neutkens
708c537fc6 Merge branch 'master' into canary 2019-02-16 16:38:42 +01:00
Connor Davis
1e5d0908d0 Block Certain Env Keys That Are Used Internally (#6260)
Closes: #6244 

This will block the following keys:
```
NODE_.+
__.+
```

There doesn't seem to be a way to simulate a failed build or else I'd add tests for it.
2019-02-15 17:49:40 +01:00
Tim Neutkens
4051ffcb01 [experimental] Rendering to AMP (#6218)
* Add initial AMP implementation

* Implement experimental feature flag

* Implement feedback from sbenz

* Add next/amp and `useAmp` hook

* Use /:path*/amp instead

* Add canonical

* Add amphtml tag

* Add ampEnabled for rel=“amphtml”

* Remove extra type
2019-02-14 10:22:57 -05:00
Tim Neutkens
7fd9cb440d v8.0.1 2019-02-13 09:31:49 +01:00
Tim Neutkens
77a5a6f91a v8.0.1-canary.0 2019-02-13 07:20:54 +01:00
Tim Neutkens
e4f96e65d3 v8.0.0 2019-02-11 09:02:37 +01:00
Tim Neutkens
8ddf9c7f27 v8.0.0-canary.23 2019-02-11 08:28:49 +01:00
Tim Neutkens
100b733960 v8.0.0-canary.22 2019-02-11 08:17:22 +01:00
Tim Neutkens
bfd2d08ff2 v8.0.0-canary.21 2019-02-10 05:10:24 +01:00
Tim Neutkens
2ecb2489ce v8.0.0-canary.20 2019-02-10 04:56:14 +01:00
Tim Neutkens
c0701e948f v8.0.0-canary.19 2019-02-08 16:04:44 +01:00
Connor Davis
28b61a8c94 Remove Unneeded _error import (#6224) 2019-02-08 11:57:29 +01:00
Tim Neutkens
b2b2041e39 v8.0.0-canary.18 2019-02-01 13:23:56 +00:00
Sultan Tarimo
1a416b688e Load ErrorComponent dynamically (#6171)
Closes #6152.

- Only dynamically load /_error.js when an exception occurs.
- Fix websocket “/_error.js” ping oddity.
2019-01-31 20:45:36 +00:00
Connor Davis
8b24103d7f Throw Error When Running next start on Serverless Build (#6166)
Fixes #6144
2019-01-29 13:42:07 +01:00
Tim Neutkens
0e21615245 v8.0.0-canary.17 2019-01-27 22:03:13 +01:00
Tim Neutkens
136c37eca9 v8.0.0-canary.16 2019-01-27 17:20:24 +01:00
Tim Neutkens
f05d339dcf v8.0.0-canary.15 2019-01-26 02:02:48 +01:00
Tim Neutkens
b4ade0a3cd Revert "Move phases back to next/constants (#6104)"
This reverts commit 9112f63eba.
2019-01-26 02:01:49 +01:00
Tim Neutkens
024323b6d8 v8.0.0-canary.14 2019-01-25 19:14:11 +01:00
Tim Neutkens
adfdc79842
Move next/head to Typescript (#6131)
Solves a bunch of inconsistencies in handling React elements too.
2019-01-25 16:43:12 +01:00
Tim Neutkens
6c49bee959
Make side-effect.js smaller (#6118)
Start at making side-effect.js / head.js smaller.
2019-01-25 01:39:15 +01:00
Connor Davis
97bf2679aa
v8.0.0-canary.13 2019-01-24 16:27:05 -06:00
Tim Neutkens
1191843e17 v8.0.0-canary.12 2019-01-24 10:51:13 +01:00
Tim Neutkens
9112f63eba
Move phases back to next/constants (#6104)
* Move phases back to next/constants

* Fix typescript error
2019-01-23 14:10:12 +01:00
Tim Neutkens
c5d5148bad v8.0.0-canary.11 2019-01-22 13:12:50 +01:00
Connor Davis
43b0b95e1d
v8.0.0-canary.10 2019-01-21 09:13:26 -06:00
Tim Neutkens
0714300b8c v8.0.0-canary.9 2019-01-19 13:40:53 +01:00
Jason Aslakson
00003193df Additional config options for hot reloader web socket connection (#6083)
* Additional config options for hot reloader web socket connection

* Apply suggestions from code review

Accepting suggested code changes

Co-Authored-By: jaslakson <jason.aslakson@americastestkitchen.com>

* updated README with websocket proxy options

* Fix test / cleanup port setting

* Always set proxy_path
2019-01-19 13:39:09 +01:00
Tim Neutkens
b52c416713 v8.0.0-canary.8 2019-01-18 12:15:56 +01:00
Tim Neutkens
9ab8714f38 v8.0.0-canary.7 2019-01-14 16:19:20 +01:00
Alexander Nanberg
7e7be0e2e8 Revert #6030 (#6052)
* Revert #6030

* Fix _app childContextTypes
2019-01-14 15:41:09 +01:00
Alexander Nanberg
ff5cf6d4de Migrate next/head to use React.createContext (#6038)
Continuation of #5945
2019-01-14 01:59:26 +01:00
Tim Neutkens
02ab732096
Remove next/asset (#6046)
* Remove next/asset

Reasoning described in #5970

* Remove next/asset tests

* Bring back asset-page
2019-01-14 01:32:20 +01:00
Tim Neutkens
f94d24bffc v8.0.0-canary.6 2019-01-12 00:45:34 +01:00
tangye
ad5431b4ae
should not change method to replaceState unless asPath is the same (#6033)
original code in `/lib/router/router.js`
```
  urlIsNew (pathname, query) {
    return this.pathname !== pathname || !shallowEquals(query, this.query)
  }
```
the urlIsNew compare `this.pathname` to an argument `pathname`
the invokers:
```
    // If asked to change the current URL we should reload the current page
    // (not location.reload() but reload getInitialProps and other Next.js stuffs)
    // We also need to set the method = replaceState always
    // as this should not go into the history (That's how browsers work)
    if (!this.urlIsNew(asPathname, asQuery)) {
      method = 'replaceState'
    }
```
the parameter here is `asPathname` destructured from `asPath`

so here is a problem when we reuse a single page rendered in two asPaths

pages/a.js
```
<>
  <Link href='/a'><a>goto a</a></Link>
  <Link href='/a' as='/b'><a>goto b</a></Link>
</>
```
If we navigate to page /a, then click 'goto b', actually the history is replaced, not pushed.
It is expected that history could be correctly pushed and popped as long as the browser url is changed.
2019-01-11 15:44:25 -06:00
Tim Neutkens
0607638e8f v8.0.0-canary.5 2019-01-11 22:29:15 +01:00
Alexander Nanberg
25fb3f9c2e Migrate next/router to use React.createContext (#6030)
Fixes parts of #5716. I had some issues with the test suite but I'm fairly certain that I got it working correctly.
2019-01-11 16:04:56 +01:00
Tim Neutkens
2a9b733715 v8.0.0-canary.4 2019-01-10 23:03:25 +01:00
Jayden Seric
49fea51f34 Fix Head.propTypes (#6020)
This PR fixes the buggy `Head.propTypes` here:

https://github.com/zeit/next.js/blob/v8.0.0-canary.3/packages/next-server/lib/head.js#L107

Currently, `Head.propTypes` allows one child node like this:

```jsx
import Head from 'next/head'

// …

<Head>
  <title>Title</title>
</Head>
```

But more than one child node mistakenly causes a prop type error like this:

```jsx
<Head>
  <title>Title</title>
  <meta name="description" content="Description." />
</Head>
```

```
Warning: Failed prop type: Invalid prop `children` supplied to `Head`.
```
2019-01-10 12:53:43 +01:00
Tim Neutkens
a9f71e449d v8.0.0-canary.3 2019-01-09 00:09:15 +01:00
Luc
fc19b233eb Replace event-emitter.js by mitt (#5987)
This PR aims at replacing next-server/lib/event-emitter.js by mitt.

Fix https://github.com/zeit/next.js/issues/4908

event-emitter.js is ~400 bytes gzipped vs mitt is 200 bytes
2019-01-04 21:49:21 +01:00
Kévin Dunglas
c51ac8e8dc Fix typo in a comment (#5982) 2019-01-02 20:21:57 +01:00
Tim Neutkens
7d080760a8 v8.0.0-canary.2 2019-01-02 16:29:19 +01:00
Tim Neutkens
fd3cb2a190 v8.0.0-canary.1 2019-01-02 15:07:33 +01:00
Tim Neutkens
672a87d981 v8.0.0-canary.0 2019-01-02 13:59:52 +01:00
Tim Neutkens
9a9e358911
Use result of getUrl() (#5973)
As getUrl() is already called and passed to initialization: https://github.com/zeit/next.js/blob/canary/packages/next/client/index.js#L46
2019-01-01 02:08:32 +01:00
JJ Kasper
ba8cb31a40 Added WebSocket arg to allow manually setting port (#5963)
Saw a reply on the original pull request that the WebSocket using a random port broke their set up so I added a `--websocket` or `-w` argument similar to the `-p` argument to allow manually setting this port also.
2019-01-01 01:07:10 +01:00
Tim Neutkens
36164ead80
Don’t bundle next/asset if it’s not used (#5971) 2018-12-31 19:05:34 +01:00
Anderson Leite
20fe65ce41 Implement tslint for core files (#5952)
Fixes #5845 

Implement tslint for core files

**What is this?**
Implements tslint for both next and next-server, but keeps standardjs/eslint for the .js files that are still there, we're gradually migrating to Typescript.

**How does it work?**
Before every commit (pre-commit) we execute the following `tslint` command:
`tslint -c tslint.json 'packages/**/*.ts`

**TSLint Rules**
In order to avoid as much changes as possible I marked some rules as false. This way we can improve the linter but making sure this step will not break things. (see tslint.json)

**Note**
After merging this PR, you'll need to update your dependencies since it adds tslint to package.json
2018-12-31 14:44:27 +01:00
Tim Neutkens
aabc72015c v7.0.2-canary.50 2018-12-28 11:41:47 +01:00
Tim Neutkens
0f23faf81f
Serverless Next.js (#5927)
**This does not change existing behavior.**

building to serverless is completely opt-in.

- Implements `target: 'serverless'` in `next.config.js`
- Removes `next build --lambdas` (was only available on next@canary so far)

This implements the concept of build targets. Currently there will be 2 build targets:

- server (This is the target that already existed / the default, no changes here)
- serverless (New target aimed at compiling pages to serverless handlers)

The serverless target will output a single file per `page` in the `pages` directory:

- `pages/index.js` => `.next/serverless/index.js`
- `pages/about.js` => `.next/serverless/about.js`

So what is inside `.next/serverless/about.js`? All the code needed to render that specific page. It has the Node.js `http.Server` request handler function signature:

```ts
(req: http.IncomingMessage, res: http.ServerResponse) => void
```

So how do you use it? Generally you **don't** want to use the below example, but for illustration purposes it's shown how the handler is called using a plain `http.Server`:

```js
const http = require('http')
// Note that `.default` is needed because the exported module is an esmodule
const handler = require('./.next/serverless/about.js').default
const server = new http.Server((req, res) => handler(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```

Generally you'll upload this handler function to an external service like [Now v2](https://zeit.co/now-2), the `@now/next` builder will be updated to reflect these changes. This means that it'll be no longer neccesary for `@now/next` to do some of the guesswork in creating smaller handler functions. As Next.js will output the smallest possible serverless handler function automatically.

The function has 0 dependencies so no node_modules are required to run it, and is generally very small. 45Kb zipped is the baseline, but I'm sure we can make it even smaller in the future.

One important thing to note is that the function won't try to load `next.config.js`, so `publicRuntimeConfig` / `serverRuntimeConfig` are not supported. Reasons are outlined here: #5846

So to summarize:

- every page becomes a serverless function
- the serverless function has 0 dependencies (they're all inlined)
- "just" uses the `req` and `res` coming from Node.js
- opt-in using `target: 'serverless'` in `next.config.js`
- Does not load next.config.js when executing the function

TODO:

- [x] Compile next/dynamic / `import()` into the function file, so that no extra files have to be uploaded.
- [x] Setting `assetPrefix` at build time for serverless target
- [x] Support custom /_app
- [x] Support custom /_document
- [x] Support custom /_error
- [x] Add `next.config.js` property for `target`

Need discussion:
- [ ] Since the serverless target won't support `publicRuntimeConfig` / `serverRuntimeConfig` as they're runtime values. I think we should support build-time env var replacement with webpack.DefinePlugin or similar.
- [ ] Serving static files with the correct cache-control, as there is no static file serving in the serverless target
2018-12-28 11:39:12 +01:00
Anderson Leite
44d12d0c95 Remove unused imports. (#5950) 2018-12-26 20:58:17 +01:00
Tim Neutkens
32451e979e
Move out requires from renderToHTML (#5915)
This brings us one step closer to outputting serverless functions as renderToHTML now renders the passed components, which allows us to bundle the renderToHTML function together with statically imported components in webpack.
2018-12-18 17:12:49 +01:00
Tim Neutkens
bd2dee21d4 v7.0.2-canary.49 2018-12-17 19:30:35 +01:00
Tim Neutkens
581e193a72
Check if App / Document are valid React Components (#5907)
We already checked if Document is a valid component, but we didn't yet for App.
2018-12-17 17:42:40 +01:00
Tim Neutkens
6e2cbfaff3 v7.0.2-canary.48 2018-12-17 16:13:05 +01:00
Kyle Holmberg
72e7929242 Change page export validity check on client and server in development (#5857)
Resolves #4055 

Credit: https://github.com/zeit/next.js/pull/5095

I didn't use the ignore webpack plugin from the original PR and tested bundle size with https://github.com/zeit/next.js/pull/5339 - seems to be safe on that front.

Was able to get tests to pass locally, unsure of what goes wrong in CI 🤷‍♂️ 

**Questions**
1) The initial PR didn't include changes to `next-server/lib/router` in `getRouteInfo()`. Should the same changes be made within?

2) Should we add a test for rendering a component created via `forwardRef()`?

`component-with-forwardedRef`:
```javascript
export default React.forwardRef((props, ref) => <span {...props} forwardedRef={ref}>This is a component with a forwarded ref</span>);
```

some test:
```javascript
test('renders from forwardRef', async () => {
  const $ = await get$('/component-with-forwardedRef')
  const span = $('span')
  expect(span.text()).toMatch(/This is a component with a forwarded ref/)
})
```
2018-12-17 16:09:23 +01:00
Tim Neutkens
346915eb9d v7.0.2-canary.47 2018-12-16 16:37:17 +01:00
Tim Neutkens
be24aaa0d2 v7.0.2-canary.46 2018-12-16 14:30:50 +01:00
Tim Neutkens
e96d694445 v7.0.2-canary.45 2018-12-16 02:01:21 +01:00
Tim Neutkens
f4a2cbb403 v7.0.2-canary.44 2018-12-15 23:45:34 +01:00
Tim Neutkens
00a14d696d v7.0.2-canary.43 2018-12-13 19:47:10 +01:00
Tim Neutkens
4426fdb98e
Make sure 404 is rendered (#5880) 2018-12-13 19:46:16 +01:00
Tim Neutkens
5e3bf6e537
Convert render.js to typescript (#5869)
* Convert render.js to typescript

* Compile tsx files too

* Remove internal renderErrorToHTML function

* Interopt component result

* requirePage doesn’t need async

* Move out enhancing logic into it’s own function

* Remove buildManifest from renderPage

* Move render into it’s own function

* Change let to const

* Move renderDocument into it’s own function
2018-12-13 01:00:46 +01:00
Tim Neutkens
2dec1fcd63 v7.0.2-canary.42 2018-12-11 21:59:30 +01:00
Tim Neutkens
93424b64a9
Use correct default for query (#5851) 2018-12-10 23:40:26 +01:00
Tim Neutkens
8b6173917a
Convert next-server.js to typescript (#5844) 2018-12-09 22:46:45 +01:00
Tim Neutkens
61894816ba
Remove app variable as it’s only used once (#5842)
* Remove app variable as it’s only used once

* Remove double spread
2018-12-08 13:14:44 +01:00
Tim Neutkens
0e6d190706
Move sendHTML and rewrite in ts (#5839)
* Move send-html function and rewrite in typescript

* Move getPageFiles and convert to ts

* Move getPageFiles and convert to ts (#5841)

* Move getPageFiles and convert to ts

# Conflicts:
#	packages/next-server/server/render.js

* Fix unit tests
2018-12-07 15:52:29 +01:00
Tim Neutkens
8873242b0b
Move getPageFiles and convert to ts (#5841)
* Move getPageFiles and convert to ts

# Conflicts:
#	packages/next-server/server/render.js

* Fix unit tests
2018-12-07 13:35:01 +01:00
Tim Neutkens
8ca5749ff9
Remove unused properties (#5837) 2018-12-07 00:57:39 +01:00
Tim Neutkens
ffe1a12f2e
Move getDynamicImportBundles into own ts file (#5836) 2018-12-06 22:34:53 +01:00
Tim Neutkens
3c62b07593
Move serve-static to typescript (#5833) 2018-12-06 16:54:33 +01:00
Tim Neutkens
5d2250ac27
Remove unused functions (#5832)
Couldn't find a reference to these functions as next-server uses the renderToHTML directly.
2018-12-06 16:47:10 +01:00
Tim Neutkens
261eb16308
Only check if BUILD_ID exists when reading throws error (#5834)
We don't have to check if the file already exists here, since it's always in production mode (dev overrides the readBuildId method to always be `development`) If the file is not found (error is thrown) we check if the file exists. If not we throw a helpful error. In other cases we throw the original error.
2018-12-06 16:46:53 +01:00
Tim Neutkens
902c5244f3 v7.0.2-canary.41 2018-12-05 22:41:26 +01:00
Tim Neutkens
dd556bf90b
Add tsc type checking (#5826)
* Add tsc type checking

* Add linting on circle

* Add node-fetch types

* Use strict mode
2018-12-05 21:45:50 +01:00
Tim Neutkens
7098501547 v7.0.2-canary.40 2018-12-05 15:05:59 +01:00
Tim Neutkens
a62a6276c7 v7.0.2-canary.39 2018-12-05 14:45:14 +01:00
Tim Neutkens
84223d39e7 v7.0.2-canary.38 2018-12-04 20:10:53 +01:00
Tim Neutkens
dada692bd6 v7.0.2-canary.37 2018-12-04 15:28:36 +01:00
Tim Neutkens
dd3b5bf81d v7.0.2-canary.36 2018-12-04 11:04:21 +01:00
Matheus Fernandes
977bf8d9eb Zeit -> ZEIT (#5804) 2018-12-03 23:01:23 +01:00
Tim Neutkens
082db2877d v7.0.2-canary.35 2018-12-03 19:50:59 +01:00