Commit graph

340 commits

Author SHA1 Message Date
Arunoda Susiripala
bd80b78f5d Handle undefined assets when combining. (#1569)
It's possible for common.js to be empty in certain cases.
So, we need to handle it.
2017-03-30 16:35:53 +02:00
Arunoda Susiripala
bb72e19190 Move all NPM modules into a single chunk in dev mode. (#1512)
This will isolate all the NPM modules into a single chunk.
That chunk won't touch by webpack unless, there's a new NPM module.
That gives us much better re-build performance.
2017-03-26 13:48:59 -07:00
Guillermo Rauch
50274959cb Revert "Move all NPM modules into a single chunk in dev mode. (#1505)"
This reverts commit a879f47f9a.
2017-03-26 11:24:58 -07:00
Arunoda Susiripala
a879f47f9a Move all NPM modules into a single chunk in dev mode. (#1505)
This will isolate all the NPM modules into a single chunk.
That chunk won't touch by webpack unless, there's a new NPM module.
That gives us much better re-build performance.
2017-03-25 10:26:08 -07:00
Arunoda Susiripala
32af8294a7 Load the main JS bundle in production with async (#1485)
* Use a webpack plugin to combine assets.

* Add comments and make this releseable.

* Fix some typos.

* Fix some typos.
2017-03-24 13:21:34 +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
Arunoda Susiripala
b2fabf0fe0 Load script with the defer attribute (#1437)
Load script with the defer attribute
2017-03-19 18:46:50 +05:30
Arunoda Susiripala
ffade8d5ac Fix client error modal not showing in dev (HMR) (#1448)
* Fix HMR not working issue.
Our hot-reload code on the server has custom webpack error dectection logic.
Is supports only multi-modules entries.
So, we need to all entries as multi-module entries
even if there's just a single entry.

* Add a test case for showing errors over HMR.
2017-03-18 16:01:55 -07: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
ef2bbfee5a Add default entries to main.js (#1343)
So, we don't need to add them to individual pages.
This also fix the issue where, error pages doesn't ping the server.
2017-03-04 17:29:35 -08:00
Tim Neutkens
2a1f8ad387 Fix linting errors in standard 9.0 (#1333)
* Fix linting errors in standard 9.0

* Update lockfile
2017-03-02 16:17:41 -08:00
Arana Jhonny
bc47aac8f4 Fixed some problems with standard (#1331) 2017-03-02 22:46:16 +01:00
Tim Neutkens
40738c6e44 Throw Error when url.parse without true is parsed (#1282)
* Throw Error when url.parse without true is parsed

This is a bit more descriptive when this mistake is made by the user.

* Parse when needed

* Parse querystring if it is not provided
2017-03-01 15:30:07 -08:00
Arunoda Susiripala
fd430e53bf Revert "Ignore .next from hot reload watcher" (#1313) 2017-02-28 09:46:11 +01:00
Arunoda Susiripala
c79d2676d2 Disable common chunks plugin in dev. (#1311)
With the on-demand-entires, this makes no sense.
2017-02-27 21:49:49 -08:00
Tim Neutkens
4620cd8cd6 Ignore .next from hot reload watcher (#1307)
* Move on-demand-entries-ping to _next namespace

* Ignore .next from watching
2017-02-27 13:35:17 -08:00
Arunoda Susiripala
ee56636660 Make sure to invalidate only once before webpack complete the build. (#1297)
* Make sure to invalidate only once before webpack complete the build.

* Increase the touch timeout to 1 sec.
2017-02-27 12:05:10 -08:00
Tim Neutkens
b37431461d Move on-demand-entries-ping to _next namespace (#1305) 2017-02-27 12:04:01 -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
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
Joe Lutz
e3bf20cbcf Fix relative module aliases for Windows (#1249)
* Fix relative module aliases for Windows

* Update regular expressions to use `path.sep` instead of `[\\/]`

* Make the minimal changes possible.
2017-02-24 04:49:34 +05:30
Arunoda Susiripala
fb496b7c9a Run tests in Travis. (#1247)
* Run tests in Travis.

* Update deps and config.

* Update jest config.

* Disable a test temp.

* Increase the timeout.
2017-02-22 23:38:49 +05:30
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
Joe Lutz
2e0db62b52 Fix "EXDEV: cross-device link not permitted" error (#1174)
* Fix "EXDEV: cross-device link not permitted" error

* Fix lint errors

Not sure why standard passes in my dev environment, but hopefully this fixes the CI errors.

* Fix logic mistake

Wow, my bad :/
2017-02-16 15:16:02 +01:00
Fin Hopkins
47d57f4bcd Async render fixes for #1170 (#1172)
The change in #1155 to remove server-side gzipping changed static
rendering to no longer return a promise, which broke the Hapi example
that was waiting for a resolved promise before closing the request.

This PR fixes up all render or serve methods of server.js to
consistently either await and/or return. Additionally, it collapses
serveStatic and _serveStatic, as _serveStatic no longer needs to be
factored out.
2017-02-15 23:48:35 -03:00
Fin Hopkins
8a5250985f Changes hard-coded module aliases to be relative (#1164)
Without this, modules built with Babel or Webpack would have hard-coded absolute paths
all the way back to the root of the filesystem. This prevented compilation and running
on different machines or even from different directories on the same machine.

With this change, paths are hard-coded to the top-most node_madules directory found,
which should make them portable relative to the app.

Fixes #1160
2017-02-16 07:37:29 +05:30
Arunoda Susiripala
b2360ec567 Completely delete the build dir. (#1158) 2017-02-15 17:31:21 +01:00
Tim Neutkens
fca186f9e7 Remove pre-gzip support (#1155) 2017-02-15 15:49:45 +01:00
Naoyuki Kanezawa
141ab99888 build on tmp dir (#1150) 2017-02-15 10:03:33 -03:00
Thomas Lindstrøm
acc1983f80 Don't delete .next folder before a replacement is built (#1139) 2017-02-14 20:14:30 -03:00
Arunoda Susiripala
9d529ea0b1 Remove babell-plugin-transform-react-constant-elements. (#1102)
* Remove babell-plugin-transform-react-constant-elements.
With this, our shared-modules example's counter won't work in
production mode. (as this plugin enabled)
So, we could see more issues like this.
That's why we don't need this at this time.

* Update package.json.
2017-02-14 07:37:34 +05:30
Tim Neutkens
77c14f96b1 Add react-jsx-source for development (#1115) 2017-02-14 07:24:01 +05:30
sfhardman
dbc2ceefde Return a promise from getRequestHandler execution, await _serveStatic in serveStaticWithGzip, update custom-server-hapi to complete request lifecycle (#1099) 2017-02-12 23:12:32 -03:00
Arunoda Susiripala
b220193167 Babelrc false babelrc (#1094)
* Detect babelrc disabling via babelrc.

* Simplify boolean condition.
2017-02-13 06:18:22 +09:00
Tim Neutkens
f93bacfaba Use minimist string option for hostname (#1090)
* Use minimist string option

* Consistently use --hostname

* Code style

* Show hostname
2017-02-13 01:23:42 +09:00
Jesse Hattabaugh
c4a22abb4c adding hostname argument to CLI (#1017)
* adding hostname argument to CLI

* using -H instead of -hn

* removing hostname default

* checking that hostname has a truthy value that's not a boolean

* making the log message match the hostname

* oops
2017-02-12 12:26:10 +01:00
Tim Neutkens
faef6e48e0 Remove pure-class-to-function (#1077)
* Optimize React

* Remove unused preset

* Remove pure-class-to-function
2017-02-11 07:42:12 +05:30
Tim Neutkens
250c066de5 Optimize React on next build (#1075)
* Optimize React

* Remove unused preset
2017-02-11 04:05:13 +09:00
Naoyuki Kanezawa
ed00eb7236 ensure not to render ErrorDebug on production (#1064) 2017-02-10 10:05:22 +01:00
Tim Neutkens
53c245bf63 Throw when parsedUrl is not provided (#1015)
* Throw when parsedUrl is not provided

* Allow parsedUrl to be empty

* Remove unwanted line.

* Reset to the original
2017-02-09 08:52:48 +05:30
Naoyuki Kanezawa
9348762f4a add next/error (#1040) 2017-02-08 16:59:33 -03:00
Arunoda Susiripala
55f48563a0 Add babel-preset-latest support. (#1027)
* Add babel-preset-2016 support.
This adds the support for Exponentiation operator (**)

* Use babel-preset-latest.

* Remove babel-plugin-transform-async-to-generator in favor of babel-plugin-latest
It has es2017 preset and it comes with the above plugin.
2017-02-08 13:05:25 +01:00
Lukas Strassel
4a73ccbb00 add react and react dom as peer (#1024)
- tackles #997
- add ./idea to gitignore for webstorm users
- update all the examples
2017-02-08 10:11:38 +05:30
Tim Neutkens
aa971d6a1c Disallow directories in /static (#1028) 2017-02-08 05:43:25 +05:30
Naoyuki Kanezawa
ddd93e9865 Improve babel settings (#976)
* fix babelrc settings

* use only transform-es2015-modules-commonjs for transpiling emitting files
2017-02-03 12:18:44 -08:00
Tim Neutkens
3143e0d0a1 Add styled-jsx to babel plugins (#970)
* Resolve all modules through module resolver

* Add styled-jsx back
2017-02-03 12:09:52 +05:30
Arunoda Susiripala
57e9a5e5f6 Find custom babel config location properly. (#969)
* Find custom babel config location properly.
Earlier we simply check for the .bablerc file in the dir.
But the actual logic is much complex.
Now we are using the babel's actual logic to find the
custom config location.

* Fix failing tests.
2017-02-03 14:33:35 +09:00
Tim Neutkens
efe0c7b433 Resolve all modules through module resolver (#963) 2017-02-02 15:58:02 -08:00
Tim Neutkens
59281adef3 Allow parsed url to be passed down (#950)
* Allow parsed url to be passed down

* Update example to reflect url passing

* Check if passed url.query is empty

* Rename url to parsedUrl
2017-02-02 12:21:08 +05:30
Arunoda Susiripala
24edfbdea7 Resolve styled-jsx/style when transpiling ES2015 modules. (#953) 2017-02-02 06:56:21 +01:00
Tim Neutkens
f9717347a4 Resolve preset es2015 from next directory (#949) 2017-02-02 07:35:21 +05:30
Artem Samofalov
2f7d743050 add pretty message if port already in use(#927) (#932)
* add pretty message if port already use(#927)

* fix console async nature

* fix linter

* clean callbacks code

* Check package.json for the startup script

* fix path to package

* omit callback

* remove extra check, code execute in try block

* + reason for change start listen port of node http

* remove extra code for search package
2017-02-01 21:36:23 +01:00
Arunoda Susiripala
ec2c8c6784 Fix .json import issue (#944)
* Fix .json import error
This is a regression we've added by #926 (tree-shaking-support)

* Add a test case.
2017-02-01 15:17:15 +09:00
Arunoda Susiripala
f3e541fe23 Add support for Webpack 2's tree-shaking (#926)
* Let webpack2 to handle ES2015 module system
Since Node.js can't do that, we need to transpile
ES2015 module system in the emit-file-loader.

* Use sourceMaps only in dev.

* Introduce a transform option to emit-file-loader
So, we can move our ES2015 transpile code with that option.

* Remove unwanted argument options.

* Update comments.

* Use dev flag instead of NODE_ENV
2017-01-31 15:31:27 +09: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
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
alex newman
c21531151f Move nextdata into nextScript and make Main return a single el (#831) 2017-01-19 16:14:05 -08:00
Naoyuki Kanezawa
43149bdb08 fix not to overwrite the ignored option on Windows (#824) 2017-01-19 08:09:40 +01:00
Arunoda Susiripala
60ec4def1e Add NODE_PATH support for resolveLoaders as well. (#778)
* Add NODE_PATH support for resolveLoaders as well.

* Remove unwanted code.
2017-01-16 14:40:14 +09:00
nkzawa
8a06c7b092 example: fix style 2017-01-15 00:30:39 +09:00
Naoyuki Kanezawa
dbecc2a701 Use dynamic entry feature of webpack (#750)
* update webpack version and use dynamic entry feature of it

* fix typo
2017-01-12 07:39:04 -08:00
Naoyuki Kanezawa
e3e0a68b9a Fix handling http methods (#748)
* support HEAD method

* respond with 501 if method is not GET or HEAD
2017-01-12 07:38:43 -08:00
Arunoda Susiripala
1dc52dbc6c New test setup (#640)
* Use jest-cli instead of gulp plugin.

* Use jest-cli instead of gulp plugin.

* Move fixtures into the examples dir.

* Move test code of example app to the basic example.

* Add isolated tests for server/resolve

* Allow tests to use cheerio.

* Use portfinder to get a unique port.

* Move back integration tests into the example dir.

* Introduce next-test-utils.

* Remove gulp-jest

* Add coveralls support.

* Use transpiled version of code in dist.
This is to make sure same file gets covered
by both unit/isolated tests and integration tests.

* Add support for source maps.

* Use code from dist always.

* Use nyc to stop instrument.

* Add integration test suite for production usage.

* Use jest-cli.

* Add support for running e2e tests.

* Check gzipPath with fs.stat before serving
Otherwise, serve package might throw issues other than ENOENT

* Install chromedriver with npm install.

* Install chrome on travis-ci.

* Add --forceExit to Jest.

* Run tests only on Node v6.
That's because selenium-webdriver only supports
Node 6 LTS.

* Use chromedriver NPM module to install chromedriver.

* Use wd as the webdriver client.

* Run chromedriver before tests.

* Run travis for both node 4 and 6

* Remove unwanted npm install script.

* Move some common text utilities to next-test-utils

* Add lint checks and testing in npm prepublish hook.

* Use npm on travis-ci.
We are having some caching issues with yarn and chromedriver.

* Make tests work on windows.\n But chromedriver doesn't work.

* Clean up dependencies.

* Run chromedriver in background without any tools.

* Fix a typo in the code.

* Use ES6 features used in node4 inside the gulpfile.

* Add some comments.

* Add support for running in windows.

* Stop chromedriver properly on windows.

* Fix typos.
2017-01-12 13:14:49 +09:00
nkzawa
4c32dd96b7 remove unused module alias 2017-01-12 12:39:07 +09: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
8811a334f4 Remove default next pages compilation from the main babel-loader. (#731)
* Remove default next pages compilation from the main babel-loader.
This will fix the issue when the user ignore node_modules
via our .babelrc option.

* Change babel-loaders 'query' to 'options'.
That's what's supported/recommended in webpack 2
2017-01-11 17:57:33 -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
Arunoda Susiripala
d7eac7fa2c Check the existence of the gzipped path explicitly (#704)
* Check the existance of the gzipped path explicitely.

* Fix a typo in the comments.

* Fix a typo.
2017-01-08 19:01:25 -08:00
Arunoda Susiripala
88e4adfc2a Add case sensitive checks for imports and JSON page resolver (#697)
* Add case-sensitive-paths-webpack-plugin plugin.

* Add case-sensitive check for server/resolve.
2017-01-08 18:12:29 -08:00
Arunoda Susiripala
042ffa1175 Add correct content-type header for gzipped version. (#705) 2017-01-08 18:12:10 -08:00
Naoyuki Kanezawa
929041133c resolve react-dom/server (#688) 2017-01-07 21:56:51 -08:00
Naoyuki Kanezawa
0c82d8a483 hot-reloader: return when rejected (#689) 2017-01-07 18:02:29 -08:00
Naoyuki Kanezawa
b8373b847d fix HMR for dynamic entries (#652) 2017-01-05 09:29:09 -08:00
Naoyuki Kanezawa
47a7a480d4 set output.strictModuleExceptionHandling option (#655) 2017-01-05 09:28:54 -08:00
Naoyuki Kanezawa
0a3313d1b9 add the watch ignored setting (#636) 2017-01-03 10:05:04 -08:00
Arunoda Susiripala
6d6ef1ca9f Remove the use of fs.access (#625) 2017-01-02 16:50:01 -08:00
Arunoda Susiripala
4b9f3fc431 Fix JSON pages not building on Windows (#611)
* Check for .json file extension before JSON parse. Was throwing when reading js files.

* Fix cross platform regex

* Revert back to the original content in read-page.js
2017-01-01 20:06:49 -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
33fa931207 Resolve the path in renderJSON before serving. (#599) 2017-01-01 19:07:56 +09:00
Naoyuki Kanezawa
1e308c7118 fix webpack resolve paths (#592) 2016-12-31 21:57:13 -08:00
Naoyuki Kanezawa
8d543bd148 remove the monkeypatch of watchpack (#580) 2016-12-31 11:40:18 -08:00
Arunoda Susiripala
3dae510d51 Add app's node_modules dir to resolveLoaders. (#583)
Otherwise, webpack will throw an error saying
it couldn't find entries.
That's because it couldn't find babel-loader and
other loaders installed into app's node_modules dir.
2016-12-31 22:17:52 +09:00
Arunoda Susiripala
165924b71b Add Gzip support for JSON pages (#571)
* Server JSON pages directly from the filesystem.

* Make Json pages even if there's an error.

* Implement much better page serving.

* Use JsonPagesPlugin in the production mode as well.

* Add gzip support for JSON pages.

* Use glob-promise instead of recursive-readdir

* Handle renderStatic 404 properly.

* Simply the gzip code.

* Cache already read JSON pages.

* Change JSON pages extension to .json.

* Fix HMR related issue.

* Fix hot-reload for .json solely on server.

* Properly clear cache on hot-reloader.

* Convert .js pages into .json page right inside the plugin.

* Fix gzipping .json pages.

* Remove unwanted json pages cleanup.

* Get rid of deprecated fs.exists for fs.access
2016-12-31 21:46:23 +09:00
Naoyuki Kanezawa
c210a2e73c check if response is already sent (#569) 2016-12-30 11:55:20 -08:00
Arunoda Susiripala
29c226771c Add AOT gzip content-encoding support for main build files. (#565)
* Add AOT gzip content-encoding support.
Currently we only do this for
main.js and commons.js only.

* Remove unwanted await.

* Use Promise.all to gzip assets in parallel.
2016-12-29 14:38:19 -08:00
Naoyuki Kanezawa
ff117b7ed6 Webpack 2 (#449)
* upgrade webpack

* fix WatchRemoveEventPlugin for webpack2

* use webpack2 for building for files

* bump webpack

* bump webpack

* monkeypatch watchpack
2016-12-28 10:16:52 -08:00
Naoyuki Kanezawa
798fd3c1e8 Fix custom document compilation (#534)
* compile _document using webpack

* don't emit the bundle file of _document.js

* exclude _document.js from minChunks of CommonsChunkPlugin

* handle creation/removal of pages/_document.js

* improve path handlings
2016-12-27 15:28:19 -08:00
Naoyuki Kanezawa
815f17989b fix config path (#537) 2016-12-27 15:27:51 -08:00
Arunoda Susiripala
ac2a71876d Add support for using .babelrc in the app root. (#493)
* Add support for using .babelrc in the app root.

* Update the README about the .babelrc usage.

* Fix a typo.

* Remove additional example usage.
2016-12-26 10:13:45 -08:00
Naoyuki Kanezawa
ad0f0a4d79 watch-page-plugin: prevent null access (#523) 2016-12-26 10:13:28 -08:00
Naoyuki Kanezawa
d1f8b1aef1 fix recovering runtime error (#515) 2016-12-25 12:03:07 -08:00
Arunoda Susiripala
f7b9cb009f Add cacheDirectory support for babel-loader. (#487)
This will improve the initial babel compilation
specially for larger projects.
2016-12-23 09:49:29 +09:00
Arunoda Susiripala
aa7fccbbc4 Fix incorrect babal alias for next/router. (#480) 2016-12-22 22:00:11 +09:00
Arunoda Susiripala
1719738ed1 Allow to customize our babel configuration (#466)
* Add a way to customize babel configurations.

* Add babel configuration docs to README.
2016-12-21 17:36:00 -08:00
Naoyuki Kanezawa
fe962b12de make sure to flush styles and head (#459) 2016-12-21 07:57:25 -08:00
Naoyuki Kanezawa
4faa281f23 suppress logging on test (#455) 2016-12-21 06:39:08 -08:00
Arunoda Susiripala
2798df5745 Create a babel-preset for plugins and presets we use. (#445)
* Create a babel-preset for plugins and presets we use.
Anyone could get it via 'next/babel'

* Remove  'use strict' from the source.

* Add next/router to alias resolver in our babel preset.
2016-12-20 18:01:56 -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
Naoyuki Kanezawa
a87ef1a7af Incorporate styled-jsx (#420)
* integrate styled-jsx

* define styles of pages with styled-jsx

* bump styled-jsx

* bump styled-jsx

* error-debug: fix style

* bump styled-jsx

* fix examples to use styled-jsx

* bump styled-jsx
2016-12-19 10:42:19 -08:00
Arunoda Susiripala
26c485a22f Add X-Powered-By header. (#416)
* Add X-Powered-By header.

* Add support to disable setting x-provided-by header

* Add some test cases.
2016-12-19 07:27:47 -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
Ives van Hoorne
5ab7463b93 Exploration of different config + expose webpack config (#222)
* Use next.config.js instead of package.json

* Remove irrelevant comment

* Integrate with custom webpack config

* Include hotReload option

* Remove async/await for getConfig

* Read package.json, show warning when webpack in config is defined

* Prepend warning message with WARNING

* Update log statements

* Documentation

* Restart server on change of config

* Fix process handling and cases where there is no config

* Also restart server when config file gets deleted

* Changed second parameter of webpack to config

* Support for returning Promise

* Update documentation, fix bug with webpack config

* Remove package.json, cdn and hotReload from config
2016-12-17 10:38:11 -08: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
nkzawa
59d514e071 stop watching files after running tests 2016-12-17 13:04:40 +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
aa6870a4e6 Fix #204 (#401)
React addons require React in a special way.
That causes Webpack to push React into the app's bundle.
This fix adds new externals entries to prevent that.
2016-12-15 17:45:58 -08:00
Dmitry Poddubniy
45e36fdff7 fixed bug #362, also set chunks names (#363)
* fixed bug #362, also set chunks names

* set simple solution for minChunks

* revert in favor of #310
2016-12-16 03:59:59 +05:30
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
nkzawa
b4ccb126d9 ignore .babelrc on babel-loader 2016-12-11 18:09:54 +09:00
Arunoda Susiripala
7086287eaf Set the default minChunks values to the length of pages. (#350)
Earlier it was for all length of entry points.
But we add two more entry points for errors.
Because of that, moving common modules to commons.js won't work.
2016-12-06 10:25:01 +01:00
Naoyuki Kanezawa
edfdc482e3 fix to not call hot.accept on sub-components (#294) (#351) 2016-12-06 10:24:42 +01:00
Naoyuki Kanezawa
9990a5fc78 use react-hot-loader/webpack (#338) 2016-12-05 18:09:38 +01:00
nkzawa
e1a231cd68 remove FriendlyErrorsWebpackPlugin option 2016-12-04 07:01:15 +09:00
Arunoda Susiripala
5c2e845ad7 Revert "Allow the pages directory to be in node_modules (#318)" (#324)
This reverts commit a13c6ccb11.
2016-12-02 16:58:08 +09:00
nkzawa
e0fb04d685 clear console on each webpack build 2016-12-02 14:46:45 +09:00
Naoyuki Kanezawa
12f31b5bf3 Source map support (#279)
* generate source-maps on development

* remove unused dep
2016-12-02 10:43:38 +09:00
nkzawa
4a71fb6b3c Merge branch 'master' into pr/264 2016-12-02 10:21:21 +09:00
Naoyuki Kanezawa
fc369fa240 webpack: emit json and apply json-loader after emitting files (#298) 2016-12-01 17:46:49 -05:00
nkzawa
214c885b90 remove unnecessary escape character for lint 2016-12-01 20:54:17 +09:00
Frederick Fogerty
a13c6ccb11 Allow the pages directory to be in node_modules (#318) 2016-12-01 20:30:36 +09:00
Ian Mitchell
7a66870af9 Add Polling for Bash on Windows (#302)
* Add Polling for Bash on Windows

Fixes #166

* Add Windows Bash Dependency
2016-11-28 09:04:59 -05:00
Jonas Windey
10b815b9c9 Add react-require to avoid importing React (#295)
* Add react-require

* Add babel-plugin-react-require
2016-11-28 06:46:42 -05: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
Naoyuki Kanezawa
c7ba914f52 Handle runtime errors (#268)
* display runtime errors by error-debug

* server: fix status

* render Error component on client error

* server: render runtime errors of error template

* server: handle errors of error template on render404

* server: add a comment

* server: refactor renderJSON

* recover from runtime errors

* _error: check if xhr exists

* _error: improve client error

* _error: improve error message
2016-11-24 23:03:16 +09:00
Naoyuki Kanezawa
a14cc66720 Remove webpack-dev-server (#276)
* remove webpack-dev-server

* webpack: fix publicPath
2016-11-23 10:32:49 -08:00
Chris Cunniff
880b71047b fixes #175, no longer sets process.env.NODE_ENV='production' or runs uglify in next dev mode (#274) 2016-11-18 16:26:17 +09:00
zpnk
e0455823a0 Add default utf-8 charset. (#270) 2016-11-17 15:06:54 -08:00
Jonathan Chan
1efd6b2f73 fix loader-utils spelling (#265) 2016-11-16 16:04:57 +09:00
Florian Didron
825d1878ff Removes unecessary and undisplayed default message 2016-11-16 13:05:19 +09:00
Florian Didron
becf2f2a62 Adds friendly error plugin 2016-11-16 11:46:58 +09:00
Naoyuki Kanezawa
c60ed0b730 webpack: load modules from NODE_PATH too (#233)
* webpack: load modules from NODE_PATH too

* fix splitting NODE_PATH
2016-11-14 13:43:31 +09:00
nkzawa
e81de708b8 resolve dependency of pages/_error-debug from next root dir 2016-11-06 01:12:21 +09:00
Naoyuki Kanezawa
d1a0309af9 Add pathname and query to the argument of getInitialProps (#194)
* pass pathname and query to getInitialProps on both server and client

* README: describe about the contet object of getInitialProps
2016-11-04 01:05:03 -07:00
Naoyuki Kanezawa
e775721f34 Hot reload error page (#190)
* add detach-plugin

* detach-plugin: remove unused property

* watch-pages-plugin: replace _error.js when user defined one was added/removed

* dynamic-entry-plugin: delete cache

* fix HMR settings for _error.js

* render: pass error only on dev

* hot-reload: enable to hot-reload error page

* server: check if /_error has compilation errors

* webapck-dev-client: fix reloading /_error
2016-11-04 00:12:37 +09:00
nkzawa
a3548a6717 hot-reloader: remove fileSystem property 2016-11-01 01:15:50 +09:00
Naoyuki Kanezawa
f335c21c7c hot-reload failed and succeeded chunks (#167) 2016-10-31 19:51:03 +09:00
nkzawa
ca161c375f set babel plugins using absolute paths 2016-10-29 00:50:31 +09:00
nkzawa
990e39b13e replace babel-plugin-module-alias with babel-plugin-module-resolver 2016-10-29 00:48:14 +09:00
Naoyuki Kanezawa
93d856706b add cdn config (#111) 2016-10-28 23:38:24 +09:00
nodegin
e763dc731b Fix #85 (#97) 2016-10-27 08:49:05 +09:00
nkzawa
42725614d9 fix WatchPagesPlugin to use webpack/hot/dev-server 2016-10-25 23:42:36 +09:00
nkzawa
a9c0ae3498 use webpack/hot/dev-server to full-reload on HMR errors 2016-10-25 22:51:44 +09:00
nkzawa
ba2e2aced9 webpack: fix loader exclude settings 2016-10-25 18:11:39 +09:00
nkzawa
7569ef6ca9 hot reload compilation errors 2016-10-25 00:20:50 +09:00
nkzawa
7ec46d512b hot reload added/removed pages 2016-10-24 16:22:15 +09:00
nkzawa
301cd26235 dynamic-entry-plugin: improve 2016-10-24 11:38:55 +09:00
nkzawa
61dc5137f5 dynamic-entry-plugin: fix hasEntry 2016-10-24 10:55:25 +09:00
nkzawa
7dfc298859 Merge branch 'master' of https://github.com/zeit/next.js 2016-10-24 01:42:31 +09:00
nkzawa
07b95ae080 dynamically add/remove pages 2016-10-24 01:42:13 +09:00
Dan Zajdband
e164074f8e Added glamor css (#38)
* Added glamor css

* Using pseudoclasses instead of calling functions

* Updated readme using style instead of default import for css
2016-10-21 09:39:20 -07:00
nkzawa
ec774a39da refactor paths 2016-10-19 21:58:08 +09:00
nkzawa
2e2db37ccb add error page for debug 2016-10-19 21:41:45 +09:00
nkzawa
400b75658b write files even on error 2016-10-18 23:14:00 +09:00
nkzawa
f2d456b986 less logs to display on compile error 2016-10-18 18:33:49 +09:00
nkzawa
3c44137b9b improve hot-reloading 2016-10-17 23:35:31 +09:00
nkzawa
8689af6480 server: tweak 2016-10-17 16:07:41 +09:00
nkzawa
ae5098599a hot-reloader: refactoring 2016-10-17 16:05:46 +09:00
nkzawa
a40bba954b remove .next before compiling 2016-10-17 12:55:33 +09:00
nkzawa
fb6f5d4382 change build directories structure 2016-10-17 12:55:09 +09:00
nkzawa
c697618e11 server/read: remove unused argument 2016-10-17 11:19:42 +09:00
nkzawa
1be8447a26 Merge branch 'master' into add/hot-reload 2016-10-17 11:10:16 +09:00
nkzawa
9b585e91d8 move loaders 2016-10-17 10:57:51 +09:00
nkzawa
577e2c27a7 use webpack for transpiling too 2016-10-17 10:54:36 +09:00
Dan Zajdband
1477734211 Added linting using standard (#27)
* Added linting using standard

* Linting on test
2016-10-16 17:00:17 -07:00
Dan Zajdband
7a331084dc Reverting default props for errors. (#12) 2016-10-16 15:44:26 -07:00
nkzawa
82f23e2aca fix generating _error.js 2016-10-16 13:01:17 +09:00
nkzawa
3bc8fdecb3 always use write-file-webpack-plugin 2016-10-16 11:49:09 +09:00
Dan Zajdband
e527098bb9 Implemented missing pieces for overriding 404 and 500 pages. (#10) 2016-10-15 17:36:54 -05:00
nkzawa
3032ade283 write assets to disk 2016-10-16 04:49:42 +09:00
nkzawa
e7ffb2c17d emit modules as file 2016-10-16 01:17:27 +09:00
nkzawa
26e6193a97 hot-reload: initial 2016-10-15 00:05:08 +09:00
nkzawa
4f21383e0f improve render 2016-10-10 13:24:30 +09:00
nkzawa
3e721b6878 apply css on server rendering 2016-10-09 18:50:41 +09:00
nkzawa
6718b05347 add _error.js, fix error handlings 2016-10-09 18:25:38 +09:00
nkzawa
429668b464 improve resolving files, cache files 2016-10-08 21:01:58 +09:00
nkzawa
22bf51bbe0 support getInitialProps 2016-10-08 19:16:22 +09:00
nkzawa
5a14a7249b serve static dir 2016-10-08 14:21:10 +09:00
nkzawa
e2ab55ad23 fix client/router 2016-10-08 14:12:51 +09:00
nkzawa
89f96cc160 support next/head 2016-10-07 10:57:31 +09:00
nkzawa
9150521c55 set dev flag when rendering 2016-10-07 10:56:48 +09:00
Dan Zajdband
1833effeb7 Fixes next dev and adds the css requires 2016-10-06 18:40:15 -04:00
nkzawa
88b01e0a72 next-dev 2016-10-06 20:05:52 +09:00
nkzawa
cb11c7cbc6 add Link component 2016-10-06 16:07:41 +09:00
nkzawa
66b224ad26 server: render .json urls 2016-10-06 16:06:55 +09:00
Naoyuki Kanezawa
22cfcf5357 Merge pull request #1 from zeit/add/css
Added css using aphrodite
2016-10-06 12:30:07 +09:00
Dan Zajdband
7a39dac8c7 Added css using aphrodite 2016-10-05 22:42:55 -04:00
nkzawa
ebb7bc5fbc render: fix bundle path 2016-10-06 10:21:15 +09:00
nkzawa
0cc1ed0516 make react external on webpack 2016-10-06 09:37:42 +09:00
nkzawa
9b06a22f31 initial source 2016-10-06 08:52:50 +09:00