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

2239 commits

Author SHA1 Message Date
Michael Herold 5b3578e58f #4751 - Explicitly mention install when cloning examples (#4758)
Preferably this installation wouldn't be necessary, but in lieu of a fix...

#4751
2018-07-11 23:56:15 +02:00
Albin Ekblom d8be2a0379 Add example of process.env runtimeConfig (#4759) 2018-07-11 12:48:14 +02:00
Jacob Page d51245b877 Improve documentation on runtime configuration (#4756)
* Remove nesting of runtime configuration under the babel section, since it's not related to babel.
* Clean up confusing verbiage relating to "keys."
2018-07-10 23:02:45 +02:00
jhartley218 ad2d4432e7 Update @types/next to latest in typescript example. (#4750)
Updating to a more recent version of `@types/next` fixes an error I encountered while building a new app on top of the "with-typescript" example:

`Property `push` not found in SingletonRouter`

Additional context: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/26665

To test, add a simple Router.push operation to the `pages/index.tsx`

```
import Router from 'next/router'
// ...
<span onClick={() => Router.push({ pathname: '/about' })}>TEST</span>
```
2018-07-09 13:32:52 +02:00
Tim Neutkens a42a969e07 6.1.1-canary.0 2018-07-06 20:08:04 +02:00
Tim Neutkens 183ed6b748 Merge branch 'master' into canary 2018-07-06 20:07:21 +02:00
Brendan Houle d7d61d3d4a Prepend polyfills only once (#4643) (#4738) 2018-07-06 11:54:16 +02:00
NikitaVlaznev 728871b005 Apollo example: avoid double render in browser (#4734)
Apollo's getDataFromTree is supposed to be called during the server side rendering.
Being called in browser it fires an unnecessary fake render process and blocks components from rendering with loading=true.

Also there was a mistake in this code:

    // `getDataFromTree` renders the component first, the client is passed off as a property.
    // After that rendering is done using Next's normal rendering pipeline
    this.apolloClient = props.apolloClient || initApollo(props.apolloState.data)

**Apollo** component is not rendered by getDataFromTree actually, it renders the **App** directly, thus props.apolloClient will always be undefined.

This example was discussed here: https://github.com/zeit/next.js/issues/387.
2018-07-05 20:49:23 +02:00
Jacob Page 498f37e33f Support events emitter for router (#4726)
Fixes #4679 
* Document usage of `events` router property
* Expose `events` in the `router` context object
2018-07-05 14:41:18 +02:00
Michael Hsu a1f5f35c2e fix(with-pkg): Rename dist to server (#4727)
This PR is a follow-up to 6.1 breaking #4506: Rename `dist` to `server`
2018-07-04 15:12:36 +02:00
Luc 71fe4984bf Upgrade styled-jsx to 2.2.7 (#4714)
Fixes #4713

I ran into this issue, when re-installing :
```
error upath@1.0.4: The engine "node" is incompatible with this module. Expected version ">=4 <=9".
error Found incompatible module
```

I used `yarn install --ignore-engines` as a workaround.
2018-07-02 23:00:18 +02:00
Junyoung Choi (Sai) a25359bf3f Improve with-mobx example (#4705)
in flavor of https://github.com/zeit/next.js/pull/4377
2018-06-30 22:29:24 +02:00
Vinicius Pacheco Furtado de6bf4e75f Fix typescript examples (#4704)
Update @zeit/next-typescript version on examples using it
2018-06-30 22:23:38 +02:00
Gary Meehan 0da53a1444 Add [with-storybook] example (#4588)
The purpose of the PR is to add the simplest possible integration with Storybook. 

It leaves the default Storybook and also adds a custom component to show how it would be used in both the app and Storybook.

Update: 
Tested with latest 👉  6.1.1
2018-06-29 22:24:44 +02:00
Gary Meehan 6a489efc1a [hello-world example] remove unused file (patch)
Removes unused file
Adds note on `day` subdirectory.
2018-06-29 22:23:39 +02:00
dengyunxie 4744fbd096 Make the file beautiful (#4694)
unified format😀😋
2018-06-29 17:02:00 +02:00
Tim Neutkens 0bcee3c23f 6.1.1 2018-06-29 10:27:42 +02:00
Niklas Wagner dde20fc841 Added note for AWSAppSyncClient (#4611)
I had some trouble to get server side rendering with the AWSAppSyncClient working. I finally found a solution in https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/82 but it might be worth to share it here as well. Instead of adding a big code block to each file I'll just refer to this Pull Request.

______

In case you want to use the `AWSAppSyncClient` you just need to replace the `create()` function with this function:
```jsx
import AWSAppSyncClient from 'aws-appsync';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';

function create(initialState) {
  const client = new AWSAppSyncClient({
    url: AWS_AppSync.graphqlEndpoint,
    region: AWS_AppSync.region,
    auth: {
      type: AUTH_TYPE.API_KEY,
      apiKey: AWS_AppSync.apiKey,

      // Amazon Cognito Federated Identities using AWS Amplify
      //credentials: () => Auth.currentCredentials(),

      // Amazon Cognito user pools using AWS Amplify
      // type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
      // jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken(),
    },
    disableOffline: true,
  }, {
    cache: new InMemoryCache().restore(initialState || {}),
    ssrMode: true
  });

  return client;
}
```
2018-06-29 10:08:26 +02:00
Tim Neutkens 9d52268604 6.1.0-canary.0 2018-06-28 20:58:33 +02:00
Tim Neutkens da0c7a9ce6 Merge branch 'master' into canary 2018-06-28 20:57:39 +02:00
Tim Neutkens 57d8af857a
Make sure hashchanges get triggered (#4676)
When clicking a next/link with a hash (#something) multiple times, it wouldn't keep the scrolling behavior browsers have. This makes sure we correctly trigger it.
2018-06-28 20:56:18 +02:00
Thomas Hermann 1c817d2bbf Use nonce attribute for all scripts and preloads if provided (#4539)
When implementing a strict CSP with nonces and `strict-dynamic`, every script and preload requires a nonce.

https://csp.withgoogle.com/docs/strict-csp.html
2018-06-28 20:16:30 +02:00
Tim Neutkens 17e410a1d0
Fix Typescript HMR (#4689)
Fixes #4686

Adds tests for @zeit/next-typescript so that we don't regress on this again.

I've fixed an issue in the `next` CLI too which caused lingering processes when the process gets force killed, which is what we do in the test suite, so it kept running if there was no manual quit.
2018-06-28 20:07:41 +02:00
Leo Lamprecht 810705a076 Replaced npm token (#4680) 2018-06-28 19:09:50 +02:00
Andrew Cherniavskii 54ab3bc5be Fix code splitting on Windows (#4685)
Closes #4684
2018-06-28 15:19:39 +02:00
Luc e98a877ee4 Merge url query with exportPathMap (#4678)
This PR fixes #4615

From the issue :
> One thing we might consider is merging and showing a warning for keys not defined in exportPathMap

The behaviour after this PR is the following :

```js
// next.config.js
module.exports = {
  exportPathMap: () => ({
    '/': { page: '/', query: { a: 'blue' } }
  })
}
```

| url called | `ctx.query` | warning ? |
|-|-|-|
| `/` | `{ a: 'blue' }` | |
| `/?a=red` | `{ a: 'blue' }` | |
| `/?b=green` | `{ a: 'blue', b: 'green' }` | `... parameter 'b' missing in exportPathMap` |

Is that the expected behaviour ? If not, I'll update the PR to shape the expected behavior.
2018-06-28 08:37:57 +02:00
Tim Neutkens 512f16e01f 6.1.0 2018-06-27 21:19:51 +02:00
Steve Korshakov 7fcfb8bde9 Make production compilation faster (patch) (#4677)
I have spend whole day on profiling next.js compiling performance and one of the easy hacks to reduce built time is avoid doing full `stats.toJson()` that is heavy by default.
2018-06-27 10:34:15 +02:00
Tim Neutkens 1ebd9967ac 6.0.4-canary.9 2018-06-25 23:28:51 +02:00
Tim Neutkens 85769c3d32
Pass through buildId to webpack config in development (#4665)
Fixes #4664
2018-06-25 23:06:46 +02:00
Kelly Burke e70c59517b Add example to Recipes section (#4661) 2018-06-25 12:31:09 +02:00
Olivier Tassinari 36c82fd127 Fix incorrect wording (#4658)
I can't use a functional component with `_document.js`.
[is-react](https://www.npmjs.com/package/is-react) can be used for another potential implementation of the warning logic, but maybe relying on `React.createElement()` internal checks is enough.
2018-06-24 17:10:24 +02:00
Bünyamin Benny Genel 6ed2da4575 with-socket.io Example updated with _app.js (#4644)
with-socket.io example was using a single index file and was managing connection in there. This would lead handling connection (disconnecting and reconnecting) in each added page.

I updated example with addition of `_app.js` and handled connection in there. This helped only subscribing to event in page and maintaining connection throughout example.
2018-06-23 22:17:37 +02:00
Olivier Tassinari f4af03b9c8 Remove unneeded async (#4635)
Unless I'm missing something, we don't need this async. The transpiled JavaScript is much smaller 🚀
2018-06-23 22:15:27 +02:00
Olivia Isaacs 91900d1172 Update "url deprecated" error docs with note re: React Dev Tools (#4652)
Fixes #4284 

Made change as discussed in #4284
2018-06-22 23:23:10 +02:00
Brice BERNARD 0989ecc223 [with-jest] Move jest deps to devDeps (#4650) 2018-06-22 17:12:31 +02:00
Tim Neutkens 3ae9f877a9
Rephrase url deprecation text and add link to next-codemod (#4649)
* Rephrase url deprecation text and add link to next-codemod

* Clean up double words
2018-06-22 14:21:28 +02:00
Tim Neutkens 6cba9fa511
Remove the React 15 support comment (#4648)
Next.js supports React 15 / React-like alternatives that don’t have the `rehydrate` method (preact) again since Next.js 5+. It’s still not recommended to use React 15. But there’s no need to mention that here as this is the initial installation and we instruct the user to install the latest version of React.
2018-06-22 11:53:15 +02:00
Bünyamin Benny Genel 67cb87adb5 Added with-unstated example (#4628)
Small example app using [unstated](https://github.com/jamiebuilds/unstated) library. Example uses components and logic from [with-redux](https://github.com/zeit/next.js/tree/canary/examples/with-redux) example.
2018-06-19 21:50:37 +02:00
Tim Neutkens fc2d59de4d
Add class properties configuration (#4619) 2018-06-19 21:48:54 +02:00
Alexander bf882eb60c Failing test for #4620 (#4625)
Failing test for #4620
2018-06-18 23:22:40 +02:00
Tim Neutkens c4d0b212f5
Pass in the generated asPath instead of a full url (#4622)
Fixes #4620 

On the server and when navigating pages, the `asPath` is the pathname + query + hash visible to the users, not an url. This makes sure that we keep it consistent between hot reloads.
2018-06-18 20:54:05 +02:00
Telegin Evgeniy cdfcde16a6 Update with-universal-configuration (#4624)
resolves #4623
2018-06-17 13:50:52 +02:00
Tim Neutkens d674dcc426
Move plugins and loaders to webpack folder (#4618)
Also adds basic `flow` to webpack.js and the plugins.
2018-06-16 19:23:02 +02:00
Tim Neutkens 82f2e08eab 6.0.4-canary.8 2018-06-16 15:52:28 +02:00
Tim Neutkens c3866649c4
Apply hot-self-accept to all pageExtensions (#4616)
This makes sure plugins like @zeit/next-typescript or @zeit/next-mdx don't have to provide the `hot-self-accept-loader`.
This fixes for example @zeit/next-mdx, which doesn't implement `pageExtensions` but we do use mdx as top level pages for https://github.com/zeit/docs
2018-06-16 15:51:00 +02:00
Tim Neutkens 4d2ca789d2
Only log out using external babelrc once (#4600) 2018-06-16 13:03:42 +02:00
Telegin Evgeniy 3566b92900 Update with-markdown example (#4612)
I have updated [examples/with-markdown](https://github.com/zeit/next.js/tree/canary/examples/with-markdown) in order to make it works with next 6 🎉 

<details>
<summary>Error</summary>
Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/zhenyatelegin/Desktop/next.js/examples/with-markdown/node_modules/markdown-in-js/babel.js
</details>
2018-06-15 20:55:14 +02:00
Tim Neutkens 491d2ec0dd 6.0.4-canary.7 2018-06-15 11:23:22 +02:00
Telegin Evgeniy 6cdd7cb291 Update with-absolute-imports example to Babel 7 (#4610)
Hello!

I have updated `babel-plugin-module-resolver` to `^3.1.1` and moved it to `devDependencies` in [with-absolute-imports](https://github.com/zeit/next.js/tree/canary/examples/with-absolute-imports) example to make it work with Babel 7 :)

## Error logs
```
zhenyatelegin@MBP-Zhenya  ~/Desktop/next.js/examples/with-absolute-imports   canary  yarn build
yarn run v1.5.1
warning package.json: No license field
$ next build
> Failed to build
{ Error: (client) ./pages/index.js
Module build failed: Error: Cannot find module 'babel-plugin-module-resolver' from '/Users/zhenyatelegin/Desktop/next.js/examples/with-absolute-imports'
    at Function.module.exports [as sync] (/Users/zhenyatelegin/Desktop/next.js/node_modules/resolve/lib/sync.js:40:15)
    at resolveStandardizedName (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:78:29)
    at resolvePlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:27:10)
    at loadPlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:35:18)
    at createDescriptor (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:152:21)
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:104:12
    at Array.map (<anonymous>)
    at createDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:103:27)
    at createPluginDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:99:10)
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:50:19
    at plugins (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:40:25)
    at mergeChainOpts (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:296:68)
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:251:7
    at buildRootChain (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:85:20)
    at loadPrivatePartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:41:53)
    at Object.loadPartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:66:16)
 @ multi ./pages/index.js
    at /Users/zhenyatelegin/Desktop/next.js/dist/server/build/index.js:144:31
    at runWithDependencies (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/MultiCompiler.js:154:4)
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/async/dist/async.js:1140:9
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/Users/zhenyatelegin/Desktop/next.js/node_modules/async/dist/async.js:1064:13)
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/async/dist/async.js:969:16
    at /Users/zhenyatelegin/Desktop/next.js/node_modules/async/dist/async.js:1137:13
    at runCompilers (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/MultiCompiler.js:96:47)
    at fn (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/MultiCompiler.js:101:6)
    at compiler.run (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/MultiCompiler.js:150:5)
    at emitRecords.err (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/Compiler.js:265:13)
    at Compiler.emitRecords (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/Compiler.js:371:38)
    at emitAssets.err (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/Compiler.js:258:10)
    at applyPluginsAsyncSeries1.err (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/Compiler.js:364:12)
    at next (/Users/zhenyatelegin/Desktop/next.js/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
  errors:
   [ '(client) ./pages/index.js\nModule build failed: Error: Cannot find module \'babel-plugin-module-resolver\' from \'/Users/zhenyatelegin/Desktop/next.js/examples/with-absolute-imports\'\n    at Function.module.exports [as sync] (/Users/zhenyatelegin/Desktop/next.js/node_modules/resolve/lib/sync.js:40:15)\n    at resolveStandardizedName (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:78:29)\n    at resolvePlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:27:10)\n    at loadPlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:35:18)\n    at createDescriptor (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:152:21)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:104:12\n    at Array.map (<anonymous>)\n    at createDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:103:27)\n    at createPluginDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:99:10)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:50:19\n    at plugins (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:40:25)\n    at mergeChainOpts (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:296:68)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:251:7\n    at buildRootChain (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:85:20)\n    at loadPrivatePartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:41:53)\n    at Object.loadPartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:66:16)\n @ multi ./pages/index.js',
     '(server) ./pages/index.js\nModule build failed: Error: Cannot find module \'babel-plugin-module-resolver\' from \'/Users/zhenyatelegin/Desktop/next.js/examples/with-absolute-imports\'\n    at Function.module.exports [as sync] (/Users/zhenyatelegin/Desktop/next.js/node_modules/resolve/lib/sync.js:40:15)\n    at resolveStandardizedName (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:78:29)\n    at resolvePlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:27:10)\n    at loadPlugin (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/files/plugins.js:35:18)\n    at createDescriptor (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:152:21)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:104:12\n    at Array.map (<anonymous>)\n    at createDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:103:27)\n    at createPluginDescriptors (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:99:10)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:50:19\n    at plugins (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-descriptors.js:40:25)\n    at mergeChainOpts (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:296:68)\n    at /Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:251:7\n    at buildRootChain (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/config-chain.js:85:20)\n    at loadPrivatePartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:41:53)\n    at Object.loadPartialConfig (/Users/zhenyatelegin/Desktop/next.js/node_modules/@babel/core/lib/config/partial.js:66:16)\n @ multi ./pages/index.js' ],
  warnings: [] }
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c next build
Directory: /Users/zhenyatelegin/Desktop/next.js/examples/with-absolute-imports
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/zhenyatelegin/Desktop/next.js/examples/with-absolute-imports/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
2018-06-15 11:10:25 +02:00