1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
Commit graph

188 commits

Author SHA1 Message Date
Arunoda Susiripala 4f26e84ff2 Move webpack idle wait code to the page-loader.
Because that's the place to do it.
2017-04-06 12:19:00 +05:30
Arunoda Susiripala 751d2e9853 Remove lib/eval-script.js
We no longer need it.
2017-04-06 11:42:36 +05:30
Arunoda Susiripala 822a99b0d5 Get rid of eval completely. 2017-04-05 12:15:39 +05:30
Arunoda Susiripala 03209d88fd Fix some issues related to rendering. 2017-04-05 02:38:38 +05:30
Arunoda Susiripala c95d2b28d0 Implement router using the page-loader. 2017-04-05 01:25:56 +05:30
Arunoda Susiripala a0945c7800 Introduce script tag based page loading system. 2017-04-03 23:40:24 +05:30
Arunoda Susiripala 5fcb49632e Introduce better debug error handling (#1592)
* Introduce better debug error handling
With this we are rendering runtime and debug errors inside
a it's own error root.
That gives us better error handling and control.
Also, now we are patching React core to capture runtime errors.

* Render the initial error on the server.
2017-04-01 14:03:40 -07:00
Arunoda Susiripala 87ff667e6e Revert "Introduce better debug error handling (#1590)" (#1591)
This reverts commit 0bdd321654.
2017-04-01 13:23:09 -07:00
Arunoda Susiripala 0bdd321654 Introduce better debug error handling (#1590)
With this we are rendering runtime and debug errors inside
a it's own error root.
That gives us better error handling and control.
Also, now we are patching React core to capture runtime errors.
2017-04-01 13:09:16 -07:00
Arunoda Susiripala 4a069e9d93 Remove Service Worker unregister code. (#1568)
We don't need to do it now. Because, any running service workers
might have stopped by now.
2017-03-30 16:18:15 +02:00
Arunoda Susiripala d32e69eeb9 Get rid of res.clone() (#1567)
Usually res.clone() should work. But it's not working with
the laster Safari (10.1)
We need to use a method we do not clone
2017-03-30 16:09:31 +02:00
я котик пур-пур aa4105e001 Add the system-ui font family (#1555) 2017-03-29 11:55:26 -03:00
Tim Neutkens 769cb49c30 Fix serviceworker call on http (#1542) 2017-03-28 21:23:38 +02:00
Arunoda Susiripala fb1e828318 Wait until webpack updates before eval the JSON page. (#1511) 2017-03-26 13:38:55 -07:00
Arunoda Susiripala 97c472c0c8 Handle pages with no default export and show an error. (#1484)
That error is meaningful and easy to find the issue.
2017-03-23 09:40:22 +05:30
Arunoda Susiripala bc2d5f3bdb Show errored file always in the error overlay. (#1470)
This was not happening when there's module not found errors.
Now we try to do this for all the errors if possible.
2017-03-23 04:43:23 +05:30
Tim Neutkens 228bbbef74 Use jsonPageRes instead of xhr (#1424) 2017-03-15 08:07:29 +05:30
Dan Zajdband d92ab55d22 Add/link replace (#1419)
* Using developit/unfetch as the Fetch API polyfill

* Added the replace prop into the Link component

* Added integration test for replace prop on Link component
2017-03-14 18:06:34 -05:00
Arunoda Susiripala 57099a544c Use mitt instead of EventEmitter. (#1398)
EventEmitter is quite bit and mitt is a pretty good/small replacement.
2017-03-13 10:04:30 +05:30
Sergio Daniel Xalambrí 38822717a9 Add support for URL objects in Link and Router (#1345)
* Add support for URL objects in Link and Router

* Fix typo in comment

* Fix possible bug if the `href` prop is `null`

* Document the usage of URL objects in Link and Router

* Update readme.md

* Parse URL to get the host & hostname in `isLocal`

This should check if the current location and the checked URL have the same `host` or `hostname`.

* Format `as` parameter from object to string if required

* Format `href` and `as` inside the construct and componentWillReceiveProps

* Use `JSON.stringify` to compare objects

* Add usage example

* chore(package): update chromedriver to version 2.28.0 (#1386)

https://greenkeeper.io/

* Refactor the codebase a bit.

* Change the example name.

* Add a few test cases.

* Add the example to the README.
2017-03-12 09:27:51 +05:30
Arunoda Susiripala 6db7101c40 Add beforeHistoryChange router event. (#1360) 2017-03-08 08:30:47 -08:00
Thomas Preusse 634a62441d send credentials when fetching new route (#1371) 2017-03-07 15:14:17 -08:00
Arunoda Susiripala 6979e35947 Add content based HASH to main.js and common.js (#1336)
* Use file hashes instead of BUILD_ID.
Now JSON pages also not prefixed with a hash and
doesn't support immutable caching.
Instead it supports Etag bases caching.

* Remove appUpdated Router Events hook.
Becuase now we don't need it because there's no buildId validation.

* Remove buildId generation.

* Turn off hash checks in the dev mode.

* Update tests.

* Revert "Remove buildId generation."

This reverts commit fdd36a5a0a307becdbd1d85ae3881b3a15b03d26.

* Bring back the buildId validation.

* Handle buildId validation only in production.

* Add BUILD_ID to path again.

* Remove duplicate immutable header.

* Fix tests.
2017-03-07 10:43:56 -08:00
Arunoda Susiripala 08d9847ab7 Shallow routing changes (#1363)
* Fix a typo in a test suite.

* Add old props.url API with warn for all tags.
2017-03-06 10:14:10 -08:00
Arunoda Susiripala f8f3fa7dce Introducing Shallow Routing (#1357)
* Simplify route info handling.

* Add basic resolve=false support.

* Make sure to render getInitialProps always if it's the first render.

* Change resolve=false to shallow routing.

* Add test cases for shallow routing.

* Update README for shallow routing docs.

* Update docs.

* Update docs.

* Update docs.
2017-03-06 08:48:35 -08:00
Arana Jhonny bc47aac8f4 Fixed some problems with standard (#1331) 2017-03-02 22:46:16 +01:00
Arunoda Susiripala 46b5d6a445 Fire the route cancel event only when needed. (#1316)
Earlier we do it for every route change.
2017-02-28 19:59:19 +01:00
Arunoda Susiripala 96fca5e2ad Add better hash URL support. (#1250)
* Add better hash URL support.
1. Add scrolling to given id related to hash
2. Hash changes won't trigger getInitialProps

* Add some comments.

* Fix tests.

* Add some test cases.
2017-02-28 09:31:17 -08:00
Arunoda Susiripala 818cd63ee9 Fire the route cancelled error right away. (#1312)
Earlier it wait until the JSON page is fetched.
But that's wrong and it affects when using libs like NProgress.
2017-02-28 09:48:40 +01:00
Tim Neutkens 01fa65d4a2 Unregister old serviceworker code (#1304)
Bring back 1b9e8771ec with a check for the prefetch serviceworker + if it is supported by the browser
2017-02-27 11:15:39 -08:00
Tim Neutkens f8f90955c5 Add prefetch to propTypes + flow typings (#1295) 2017-02-27 10:50:28 +05:30
Arunoda Susiripala d3b1ead149 Implement "on demand entries" (#1111)
* Add a plan for dynamic entry middleware.

* Use dynamic pages middleware to load pages in dev.

* Add the first version of middleware but not tested.

* Integrated.

* Disable prefetching in development.
Otherwise it'll discard the use of dynamic-entries.

* Build custom document and error always.

* Refactor code base.

* Change branding as on-demand entries.

* Fix tests.

* Add a client side pinger for on-demand-entries.

* Dispose inactive entries.

* Add proper logs.

* Update grammer changes.

* Add integration tests for ondemand entries.

* Improve ondemand entry disposing logic.

* Try to improve testing.

*  Make sure entries are not getting disposed in basic integration tests.

* Resolve conflicts.

* Fix tests.

* Fix issue when running Router.onRouteChangeComplete

* Simplify state management.

* Make sure we don't dispose the last active page.

* Reload invalid pages detected with the client side ping.

* Improve the pinger code.

* Touch the first page to speed up the future rebuild times.

* Add Websockets based pinger.

* Revert "Add Websockets based pinger."

This reverts commit f706a49a3d886d0231259b7a1fded750ced2e48f.

* Do not send requests per every route change.

* Make sure we are completing the middleware request always.

* Make sure test pages are prebuilt.
2017-02-26 11:45:16 -08:00
Tim Neutkens 408633c1dc Remove traces of glamor (#1286)
* Remove traces of glamor

As talked about with @rauchg. Glamor takes up around 60KB of the bundle (pre-gzip). Since styled-jsx is the way to go now and we support adding glamor by the user we should remove it as dependency cause it is bundled even when not used.

Added rehydration to the example, since we did that in our code.

There is only one thing I'm not sure about and want to discuss:
what should we do with next/css. Right now I added a throw for when it is imported. I'm not sure if we should do that / some other way to notify the user it has been removed. The reasoning behind the throw is that when we would do a console.warn the user would see 'css.default.<X>' not found because we don't have the glamor dependency anymore.

* Update yarn.lock

* Remove test for styles
2017-02-26 17:58:00 +05:30
Guillermo Rauch 1417f3040b ponify (#1278) 2017-02-25 19:41:17 -08:00
Guillermo Rauch e7c85e0162 Revert "Remove unfetch because of production build errors. (#1288)"
This reverts commit 756a32aefd.
2017-02-25 19:28:24 -08:00
Arunoda Susiripala 756a32aefd Remove unfetch because of production build errors. (#1288)
See https://github.com/zeit/next.js/pull/1278#issuecomment-282528628
2017-02-26 08:26:55 +05:30
Dan Zajdband 216efa526b Using developit/unfetch as the Fetch API polyfill (#1278) 2017-02-25 15:49:27 -03:00
Shawn Kelly 7d4d709587 fix: cmd+click Links (#1233)
Check currentTarget is 'A', not target. This is important when an anchor tag wraps another dom node.
2017-02-21 10:08:54 -08:00
Arunoda Susiripala 0bd250f4aa Handle BUILD_ID mismatch error (#1224)
* Reload the page if the buildIds are mismatch.

* Reload the browser with main.js and commons.js buildId mismatch.

* Implement proper reloading with an API to persist the state.

* Add some tests for force reload.

* Change _reload to _forceReload.

* Add a section about reload hooks to the README.

* Allow to add a hook to handle BUILD_ID mismatch.

* Remove readme docs.

* Do not show a custom error to the user.

* Cancel the routing when there's a BUILD_ID mismatch.

* Fix a typo.

* Passing route to SingletonRouter.onBuildIdMismatch

* Handle buildId mismatch automatically.
2017-02-20 15:48:17 -08:00
Arunoda Susiripala f4337d3072 Make sure reading the body of same JSON page request safe. (#1185)
* Make sure reading the body of same JSON page request safe.
It's not possible to read the body twice from fetch()'s response
So, we've to clone the response before doing anything.

* Fix tests.
2017-02-17 01:12:32 -03:00
Guillermo Rauch 1b9e8771ec Revert "Add a way to disable running service workers. (#1167)"
This reverts commit d8af41d690.
2017-02-16 19:35:36 -03:00
Arunoda Susiripala d8af41d690 Add a way to disable running service workers. (#1167) 2017-02-15 21:13:27 -03:00
Naoyuki Kanezawa 8e4e2e3e01 improve prefetch (#1161) 2017-02-16 00:59:42 +05:30
Arunoda Susiripala 412f9739d8 Reload the page if asked to change the current URL (#1159)
* Add support to reload the page when ask to change the same url.

* Do not run change() in the initial page load.

* Add integration tests.

* Add self-reload.js
2017-02-15 19:27:41 +01:00
Naoyuki Kanezawa 540a86f007 fix prefetch url (#1154) 2017-02-15 15:01:03 +01:00
Naoyuki Kanezawa 38d236e2b3 fix prefetching relative path (#1151) 2017-02-15 13:34:13 +01:00
Arunoda Susiripala 14c86bef1d Introduce a simple prefetching solution (#957)
* Implement a very simple prefetching solution.

* Remove next-prefetcher.

* Require 'whatwg-fetch' only in the client.

* Use xhr in the code.

* Use a simple fetching solution.

* Fix 404 and xhr status issue.

* Move the prefetching implementation to next/router.

* Add deprecated warnning for next/prefetch

* Run only 2 parellel prefetching request at a time.

* Change xhr to jsonPageRes.

* Improve the prefetching logic.

* Add unit tests covering the Router.prefetch()

* Update examples to use the new syntax.

* Update docs.

* Use execOnce() to manage warn printing.

* Remove prefetcher building from the flyfile.js
Because, we no longer use it.
2017-02-15 14:22:22 +05:30
Eric Zingeler d382e4db9a replace location.origin usage with new utils/getLocationOrigin (#1142) 2017-02-15 14:01:19 +05:30
Naoyuki Kanezawa 45e77d535f Fix status messages on error (#1131)
* fix status messages on error

* error: use the special message for 404
2017-02-14 16:15:42 +01:00
Naoyuki Kanezawa 1cd242ba57 remove gulpfile.js (#1092) 2017-02-12 17:32:45 +01:00
Naoyuki Kanezawa 9348762f4a add next/error (#1040) 2017-02-08 16:59:33 -03:00
Arunoda Susiripala 5b2854dce9 Properly handle hash URL changes. (#996)
* Properly handle hash URL changes.

* Make sure we replace origin correctly.

* Get rid of RegExp for getUrl().
2017-02-05 17:58:44 +09:00
Tim Neutkens 6431f5fce2 Allow any element to be rendered under Link (#921)
* Allow any element to be rendered under Link

* Use Children.only instead of Children.map

* Remove check for multiple children since we already throw at 2+

* Clean up variables
2017-02-03 12:27:12 -08:00
Naoyuki Kanezawa 0b3db91731 Fix handling finished response (#889)
* allows to not return props if response is already finished on getInitialProps

* check res.finished after getInitialProps call of Document
2017-01-26 16:36:50 +05:30
Arunoda Susiripala b4e2b7bd4d Handles the initial popstate event of older version of Safari. (#870) 2017-01-26 01:58:26 +09:00
Guillermo Rauch 85cd38f4bd tweak font sizes again 🙈 2017-01-21 18:12:27 -08:00
Zhao 3813f73ece Fix error fonts (#826)
* add "consolas" font for windows

* fix too small font size in non-retina display
2017-01-21 18:04:41 -08:00
Naoyuki Kanezawa 98e2951f0c Use ErrorDebug component on error of react-hot-loader (#852)
* use ErrorDebug component for reporter of react-hot-loader

* app: fix props of ErrorDebug
2017-01-21 10:46:18 -08:00
Arunoda Susiripala 399e510389 Make sure lastAppProps always have some value. (#829)
* Make sure lastAppProps always have some value.

* Revert "Make sure lastAppProps always have some value."

This reverts commit b4ae722d9c1a4460e17dbdc041b111cbd492b2aa.

* Throw an error, if we found an empty object from getInitialProps.

* Add proper tests for getInitialProps empty check.
2017-01-20 11:33:46 -08:00
Dan Zajdband 70b92e6b65 Added deprecation message when adding an extra anchor in behalf of the user. (#797) 2017-01-16 22:02:11 +01:00
Tim Neutkens 8318f5b8de Add cross browser stacktrace (#776)
* Add cross browser stacktrace

* Remove unused stack variable
2017-01-16 01:17:29 +09:00
Arunoda Susiripala fae2305f46 Add correct sync version of error handling with existSync. (#769)
* Add correct sync version of error handling with existSync.

* Update utils.js
2017-01-15 21:15:06 +09:00
Tim Neutkens 23cddda9cf Only show deprecation when using next/css (#762) 2017-01-13 14:46:21 -08:00
Tim Neutkens 3b3353f821 Revert "Dont' override glamor methods, use a new object instead (#754)" (#755)
This reverts commit 86516629cf.
2017-01-12 14:52:19 -08:00
Tim Neutkens 86516629cf Dont' override glamor methods, use a new object instead (#754) 2017-01-12 12:50:21 -08:00
Naoyuki Kanezawa 0ef28ab128 Don't discard component state on error (#741)
* render debug page as overlay

* handle errors occurrred on rendering cycle for HMR

* retrieve props if required on HMR
2017-01-11 17:58:20 -08:00
Arunoda Susiripala b7e57f9347 Implement "Immutable build artifacts" feature (#745)
* Write BUILD_ID when building.
It's a random id (uuid.v4())

* Add buildId to the core JS files.

* Add immutable cache-control header.
Only if the buildId is matched.

* Set '-' as the dev buildId always.

* Add buildId handling for JSON pages.
2017-01-11 12:16:18 -08:00
Naoyuki Kanezawa 8570d19af6 Handle errors of React lifecycle methods (#661)
* handle errors of lifecycle methods

* handle errors of render method
2017-01-05 09:27:39 -08:00
Craig Smith e38cacc4c2 Prevent prefetcher from making identical requests. (#665) 2017-01-05 19:16:20 +09:00
Arunoda Susiripala 01a17738db Reset prefetchCache when reloading a route. (#617)
* Reset prefetchCache when reloading a route.

* Prefetch again when there's a HMR reload.

* Make .send() to return a promise.
2017-01-02 20:18:14 +09:00
Naoyuki Kanezawa c1a620a7c4 Support relative urls on Link component (#614)
* link: support relative urls

* link: support protocol-relative urls

* router: fix error for clicking anchor tag
2017-01-01 22:22:07 -08:00
Naoyuki Kanezawa 897c60b4fd Fix error routes (#595)
* fix router error handlings

* respond with JSON when error occurs on JSON routes
2017-01-01 11:36:37 -08:00
Arunoda Susiripala c890dc3573 Implement Router Events (#511)
* Move route loading logic to a common place.

* Add router events.

* Add EventEmitter's core API methods.

* Add example app for loading events and docs.

* Fix some typos.

* Get rid of Router.ready()

* Remove events package.
It's already shipping with webpack.

* Handling aborting properly.

* Expose simple attribute based events listener API.
Removed the proposed event listener API from the public API.

* Remove error logged when there's an abort error.
There are many other ways to capture this error.
So, it doesn't look nice to print this always.

* Change router events to pass only the current URL as arguments.

* Add a section about Cancelled Routes to README.
2016-12-30 17:15:22 -08:00
Naoyuki Kanezawa 0f11018819 fix getInitialProps called on client on first load (#572) 2016-12-30 11:55:00 -08:00
Tim Neutkens e8985b3588 Add warning for multiple children in Link (#558)
* Add warning for multiple children in Link

* Add space after if

* Use proptype validation
2016-12-29 21:53:20 +09:00
Naoyuki Kanezawa 242758e3ee fix navigation failure (#546) 2016-12-27 21:27:52 -08:00
Naoyuki Kanezawa af2d78c042 router: register initial route (#508) 2016-12-24 09:29:23 -08:00
Dan Zajdband 01e1883f79 Added glamor example and pointing warning to css migration guide (#500) 2016-12-23 11:18:25 -08:00
Naoyuki Kanezawa 74d4d22f84 router: fix route value on popstate (#490) 2016-12-23 09:14:14 -08:00
nkzawa 6b18e34f66 link: tweak scroll condition 2016-12-22 17:17:50 +09:00
James O'Dwyer 31feced24a Avoid autoscrolling anchored URLs (#474)
* force scroll to false if # is found in url

* only overwrite scroll if scroll=true is not passed in

* clean up logic around setting scroll var
2016-12-22 17:15:49 +09:00
Naoyuki Kanezawa 2a29bf6242 display deprecation warning only when method was called (#462) 2016-12-21 10:43:31 -08:00
Arunoda Susiripala 141c045c68 Make next/router a client only API. (#443)
* Prevent using 'next/router' APIs inside 'getInitialProps'

* Remove incorrect documentation.

* Make next/router a client only API.
2016-12-20 09:27:43 -08:00
Arunoda Susiripala 565bb5790b Update url.pushTo and url.replaceTo update only on dev. (#434)
In order to warn the user, now we are using a warn function
which is located in the lib/utils module.
2016-12-19 13:04:38 -08:00
Arunoda Susiripala e45cc89ce3 Add deprecate messages for url.replaceTo and url.pushTo (#433) 2016-12-19 10:49:15 -08:00
Arunoda Susiripala 22776c2eee Implement the Singleton Router API (#429)
* Immplement the initial singleton Router.

* Use the new SingletonRouter for HMR error handling.

* Use SingletonRouter inside the Link.

* Create an example app using the Router.

* Make the url parameter optional in Router.push and Router.replace

* Add a section about next/router in the README.
2016-12-19 06:40:26 -08:00
Naoyuki Kanezawa 1e70324a41 print a deprecated message for next/css (#421) 2016-12-17 13:59:38 -08:00
Arunoda Susiripala 37a9c661ff Make prefetching works again. (#422) 2016-12-17 13:59:03 -08:00
Thomas Jaggi de6521a481 Allow for custom route in pushTo and replaceTo methods (#417) 2016-12-18 05:18:50 +09:00
Arunoda Susiripala b62a0e8f55 Bundle all the modules inside the app (#414)
* Remove the use of CDN and bundle everything inside the app.
We still pre-build the prefetcher because it needs
different webpack config which only targets browsers
supports Service Workers.

* Remove cdn config item.
We no longer using it.

* Stop adding script tags when staticMarkup=true

* Remove babel-plugin-transform-remove-strict-mode NPM module.
2016-12-17 17:49:10 +09:00
Naoyuki Kanezawa 1708222381 Programmatic API (#310)
* add 'next' api

* add render APIs

* add 'as' prop to Link

* check Accept header to serve json response

* check if response was finished on getInitialProps call

* move server/app to server/index

* load webpack-hot-middleware-client by absolute path

* server: options for testing

* add tests

* example: improve

* server: make dir optional

* fix client routing

* add parameterized routing example

* link: fix display url

* Add custom-server-express example (#352)

* Add custom-server-express example

* Remove extraneous nexts in express routes defs

* Update next config in server.js

* Handle accept headers totally inside Next.js (#385)

* Handle accept headers totally inside Next.js
Now user doesn't need to handle it anymore.

* Move json pages serving to /_next/pages base path.

* Join paths correctly.

* remove next/render
2016-12-16 12:33:08 -08:00
Naoyuki Kanezawa 8ddafaea5c custom document support (#405) 2016-12-16 10:42:40 -08:00
Arunoda Susiripala 43b0e6f514 Remove console.logs (#402) 2016-12-16 11:43:46 +09:00
Arunoda Susiripala 36abdc77c5 Prefetch pages with Service Workers (#375)
* Register the service worker.

* Update prefetcher code to do prefetching.

* Implement the core prefetching API.
support "import <Link>, { prefetch } from 'next/prefetch'"

* Implement a better communication system with the service worker.

* Add a separate example for prefetching

* Fix some typos.

* Initiate service worker support even prefetching is not used.
This is pretty important since initiating will reset the cache.
If we don't do this, it's possible to have old cached resources
after the user decided to remove all of the prefetching logic.
In this case, even the page didn't prefetch it'll use the
previously cached pages. That because of there might be a already running
service worker.

* Use url module to get pathname.

* Move prefetcher code to the client from pages
Now we also do a webpack build for the prefetcher code.

* Add prefetching docs to the README.md

* Fix some typo.

* Register service worker only if asked to prefetch
We also clean the cache always, even we initialize
the service worker or not.
2016-12-15 11:13:40 -08:00
Matthew Mueller a8f58be450 fix link for environments without synthetic events (like preact/the browser) (#393) 2016-12-15 10:03:02 +05:30
Luke Edwards 249a0c4007 append bundle script to body (#353) 2016-12-07 08:53:50 +09:00
nkzawa 0b20273c77 remove workaround for react-hot-loader 2016-12-04 07:06:47 +09:00
Naoyuki Kanezawa f049a0bfa0 fix reading incorrect package.json (#323) 2016-12-02 15:56:02 +09:00
nkzawa 6ad1e23167 Merge branch 'master' into pr/259 2016-12-02 10:35:07 +09:00
Arunoda Susiripala fcd59adea1 Add support for webpack's CommonsChunkPlugin and remove next bundle (#301)
* Add example app which demonstrate the problem.

* Add the first working version.

* Fix lint issues.

* Add README.md

* Use /_next/main.js as the main file URI

* Add the support for loading the core next bundle.

* Optimize the output by removing Next modules from pages.

* Use the same package.json as master use.

* Change the example repo's README for simpler instructions.

* Change example projects package.json to support next build and start.

* Change main.js into commons.js.

* Add support for hot core reload and errors.

* Introduce require based on eval-script.

* Add error reporting support with hot reloading.

* Update README.md
2016-11-28 09:15:56 +09:00