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

66 commits

Author SHA1 Message Date
Tim Neutkens 349608fe49 Do feature detection instead of disabling iframes. (#3880) 2018-02-25 19:49:38 +05:30
Tim Neutkens 50fcefdf97 Return true instead of void (#3869) 2018-02-22 22:37:40 +05:30
Arunoda Susiripala a32b22bb2d
Remove special error script handling (#3849)
* Remove special error script handling.
As a result of that, we can't detect 500 errors and buildIdMismatch via client side.

* Fix failing test cases.

* Refactor the code base.

* Remove Router.onAppUpdated
2018-02-21 23:11:25 +05:30
Björn Tegelund de6741f886 Fix typo in withRouter (#3723) 2018-02-07 13:39:23 +05:30
Henric Malmberg b8f189f2a5 do not use window.history if inside iframe (#3437)
* do not use window.history if inside iframe

* Move security related test cases into a its own file.

* Removes the unused renderScript function

* Add a nerv example. (#3573)

* Add a nerv example.

* Fix for indentation/style

* Fix for name

* warn user about browser history if next.js used in iframe
2018-02-04 13:00:38 +01:00
Tim Neutkens e093441bad Universal Webpack (#3578)
* Speed up next build

* Document webpack config

* Speed up next build

* Remove comment

* Add comment

* Clean up rules

* Add comments

* Run in parallel

* Push plugins seperately

* Create a new chunk for react

* Don’t uglify react since it’s already uglified. Move react to commons in development

* Use the minified version directly

* Re-add globpattern

* Move loaders into a separate variable

* Add comment linking to Dan’s explanation

* Remove dot

* Add universal webpack

* Initial dev support

* Fix linting

* Add changes from Arunoda's work

* Made next dev works.
But super slow and no HMR support.

* Fix client side hot reload

* Server side hmr

* Only in dev

* Add on-demand-entries client + hot-middleware

* Add .babelrc support

* Speed up on demand entries by running in parallel

* Serve static generated files

* Add missing config in dev

* Add sass support

* Add support for .map

* Add cssloader config and fix .jsx support

* Rename

* use same defaults as css-loader. Fix linting

* Add NoEmitErrorsPlugin

* Add clientBootstrap

* Use webpackhotmiddleware on the multi compiler

* alpha.3

* Use babel 16.2.x

* Fix reloading after error

* Remove comment

* Release 5.0.0-univeral-alpha.1

* Remove check for React 16

* Release 5.0.0-universal-alpha.2

* React hot loader v4

* Use our static file rendering machanism to serve pages.
This should work well since the file path for a page is predictable.

* Release 5.0.0-universal-alpha.3

* Remove optional loaders

* Release 5.0.0-universal-alpha.4

* Remove clientBootstrap

* Remove renderScript

* Make sure pages bundles are served correctly

* Remove unused import

* Revert to using the same code as canary

* Fix hot loader

* Release 5.0.0-universal-alpha.5

* Check if externals dir exist before applying config

* Add typescript support

* Add support for transpiling certain packages in node_modules

Thanks to @giuseppeg’s work in https://github.com/zeit/next.js/pull/3319

* Add BABEL_DISABLE_CACHE support

* Make sourcemaps in production opt-in

* Revert "Add support for transpiling certain packages in node_modules"

This reverts commit d4b1d9babfb4b9ed4f4b12d56d52dee233e862da.

In favor of a better api around this.

* Support typescript through next.config.js

* Remove comments

* Bring back commons.js calculation

* Remove unused dependencies

* Move base.config.js to webpack.js

* Make sure to only invalidate webpackDevMiddleware one after other.

* Allow babel-loder caching by default.

* Add comment about preact support

* Bring back buildir replace

* Remove obsolete plugin

* Remove build replace, speed up build

* Resolve page entries like pages/day/index.js to pages/day.js

* Add componentDidCatch back

* Compile to bundles

* Use config.distDir everywhere

* Make sure the file is an array

* Remove console.log

* Apply optimization to uglifyjs

* Add comment pointing to source

* Create entries the same way in dev and production

* Remove unused and broken pagesGlobPattern

* day/index.js is automatically turned into day.js at build time

* Remove poweredByHeader option

* Load pages with the correct path.

* Release 5.0.0-universal-alpha.6

* Make sure react-dom/server can be overwritten by module-alias

* Only add react-hot-loader babel plugin in dev

* Release 5.0.0-universal-alpha.7

* Revert tests

* Release 5.0.0-universal-alpha.10

* Make sure next/head is working properly.

* Add wepack alias for 'next' back.

* Make sure overriding className in next/head works

* Alias react too

* Add missing r

* Fragment fallback has to wrap the children

* Use min.js

* Remove css.js

* Remove wallaby.js

* Release 5.0.0-universal-alpha.11

* Resolve relative to workdir instead of next

* Make sure we touch the right file

* Resolve next modules

* Remove dotjsx removal plugins since we use webpack on the server

* Revert "Resolve relative to workdir instead of next"

This reverts commit a13f3e4ab565df9e2c9a3dfc8eb4009c0c2e02ed.

* Externalize any locally loaded module lives outside of app dir.

* Remove server aliases

* Check node_modules reliably

* Add symlink to next for tests

* Make sure dynamic imports work locally.
This is why we need it: b545b519b2/lib/MainTemplate.js (L68)
We need to have the finally clause in the above in __webpack_require__.
webpack output option strictModuleExceptionHandling does that.

* dynmaic -> dynamic

* Remove webpack-node-externals

* Make sure dynamic imports support SSR.

* Remove css support in favor of next-css

* Make sure we load path from `/` since it’s included in the path matching

* Catch when ensurepage couldn’t be fulfilled for `.js.map`

* Register require cache flusher for both client and server

* Add comment explaining this is to facilitate hot reloading

* Only load module when needed

* Remove unused modules

* Release 5.0.0-universal-alpha.12

* Only log the `found babel` message once

* Make sure ondemand entries working correctly.
Now we are just using a single instance of OnDemandEntryHandler.

* Better sourcemaps

* Release 5.0.0-universal-alpha.13

* Lock uglify version to 1.1.6

* Release 5.0.0-universal-alpha.14

* Fix a typo.

* Introduce multi-zones support for mircofrontends

* Add section on css
2018-01-30 16:44:44 +01:00
Tim Neutkens 4be6a521ed
Make sure we show a nice message when there is no default export (#3400) 2017-12-05 15:35:30 -08:00
Jesse Ditson a79357f2a4 Allow use of filenames in exportPathMap (#2973)
* allow use of filenames in exportPathMap

* add link test and handling for file paths when flattening links for export

* add note about exporting file paths to readme.md
2017-10-05 20:33:10 +02:00
Kevin Decker c6bd6ef997 Treat navigation to empty hash as hash navigate (#2971)
# -> #foo and #foo -> # now operate in the same way.
2017-09-27 21:55:49 +02:00
Brikou CARRE a779d830bd Rename withRoute to withRouter to be consistent (#2881) 2017-08-31 21:37:20 +02:00
Arunoda Susiripala 56662b4d84 Add/with router (#2870)
* Add withRoute HOC

Rebased (squashed)
- removed routerToProps
- updated hoist-non-react-statics
- improved propTypes

* Expose the whole Router instead of the route.

* Make the example simple.

* Update examples and the readme.

* Add a test case.
2017-08-30 19:37:12 +05:30
Arunoda Susiripala cc9b1d6ce0 Catch router events errors and print them. (#2663) 2017-07-27 19:20:39 +05:30
Arunoda Susiripala c97aca50e5 Show webpack errors in all pages. (#2588)
* Show webpack errors in all pages.
When there's a webpack error that means HMR failed too.
So, showing other pages won't makes sense since user
can't edit them and get changes via HMR.
That's why now we show the error on all pages.

* Remove exact propType checks from the error component.
When there's an error, something this check shows in the console.
That means it could accept more props.
Also this is not a public API. So, we don't want to do propType checks.
2017-07-18 12:30:23 +05:30
Arunoda Susiripala 0c7089f856 Remove mitt and use an internal EventEmitter (#2477)
This fixes one of the crucial bug in Next.js
The issue happens when you try to load a page when it's
prefetching.
With mitt, it only fires the first registered event.
2017-07-06 12:19:33 +05:30
Arunoda Susiripala a36be58124 Rewrite urls with hashes correct for static export. (#2242)
* Rewrite urls with hashes correct for static export.

* Fix some lint issues inside an example app.
2017-06-13 11:44:31 +05:30
Arunoda Susiripala 0d4e0e52f7 Implement the correct browser behavior for hash changes. (#2223) 2017-06-10 01:02:28 +05:30
Arunoda Susiripala e78c2f44dc Introduce proper url routing for next-export which supports query strings. 2017-05-14 06:10:32 +05:30
Arunoda Susiripala 90991f176c Add <page>/index.html url re-writes to next/router. 2017-05-14 05:55:57 +05:30
Arunoda Susiripala b18ecc925b Implement client side routing as they should work.
Basicaly, now client side routing as they work like
in Next.js including prefetching.
2017-05-11 08:24:27 -07:00
Arunoda Susiripala 311e4ca0ee Make sure the router is aware of the nextExport
Based on the we can change the routing to do SSR always.
Also make sure pageLoader don't download the page via
client side twice.
2017-05-08 18:20:50 -07:00
Arunoda Susiripala 24f3f143a6 Introduce "asPath" into router and getInitialProps (#1857)
* Add asPath to next/router and getInitialProps context.

* Add test cases.

* Update docs.

* Build as-path pages before they use.
2017-05-03 09:40:09 -07:00
Arunoda Susiripala dec85fe6c4 Add CDN support with assetPrefix (#1700)
* Introduce script tag based page loading system.

* Call ensurePage only in the dev mode.

* Implement router using the page-loader.

* Fix a typo and remove unwanted code.

* Fix some issues related to rendering.

* Fix production tests.

* Fix ondemand test cases.

* Fix unit tests.

* Get rid of eval completely.

* Remove all the inline code.

* Remove the json-pages plugin.

* Rename NEXT_PAGE_LOADER into __NEXT_PAGE_LOADER__

* Rename NEXT_LOADED_PAGES into __NEXT_LOADED_PAGES__

* Remove some unwanted code.

* Load everything async.

* Remove lib/eval-script.js
We no longer need it.

* Move webpack idle wait code to the page-loader.
Because that's the place to do it.

* Remove pageNotFound key from the error.

* Remove unused error field 'buildError'

* Add much better logic to normalize routes.

* Get rid of mitt.

* Introduce a better way to register pages.

* Came back to the mitt() based page-loader.

* Add link rel=preload support.

* Add assetPrefix support to add support for CDNs.

* Add assetPrefix support for preload links.

* Update readme.md
2017-04-17 21:18:43 -07:00
Arunoda Susiripala 0b8a14f35c Use existing route info when Router.reload() is called. (#1654)
Earlier, it tries to get that info from the location.href.
That's incorrect.
2017-04-07 09:52:41 -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
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
Tim Neutkens 228bbbef74 Use jsonPageRes instead of xhr (#1424) 2017-03-15 08:07:29 +05:30
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 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
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
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
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
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
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