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

2292 commits

Author SHA1 Message Date
HaNdTriX d3f1fa630e Rewrite with-dotenv example (#4924)
## Issue

I decided to rewrite the [with-dotenv](https://github.com/zeit/next.js/tree/canary/examples/with-dotenv) using [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack) example because:

- changes doesn't get applied  (#4748, brysgo/babel-plugin-inline-dotenv#13)
- the production mode doesn't work at all
- this approach has already been used in the [examples/relay-modern](9320d9f006/examples/with-relay-modern/next.config.js)
- it is [documented](https://webpack.js.org/plugins/environment-plugin/#dotenvplugin) by webpack

## Alternatives

* remove/deprecate example
* fix babel-plugin-inline-dotenv

## Related

Closes: #4748
2018-08-08 09:01:00 -07:00
HaNdTriX 9018da11ca Remove with-global-stylesheet example (#4913)
* Deprecate with-global-stylesheet example

Use @zeit/next-css instead

https://github.com/zeit/next-plugins/tree/master/packages/next-css

RELATED ISSUE: #4902

* Deprecate with-global-stylesheet-simple example

Use @zeit/next-css instead

https://github.com/zeit/next-plugins/tree/master/packages/next-css

RELATED ISSUE: #4902
2018-08-07 18:36:28 -07:00
Connor Bär b50bad56be [BUG] Fix emit-file-loader compatibility with Webpack 4 (#4918)
## Context

When upgrading to Next.js 6.1.1-canary.4 and using the `emit-file-loader` included in Next.js, the following error is thrown:

```bash
 error  in ./src/graveyard/pages/_app.scss
Module build failed (from ../node_modules/next/dist/build/webpack/loaders/emit-file-loader.js):
TypeError: Cannot read property 'context' of undefined
    at Object.module.exports (~/project-root/node_modules/next/dist/build/webpack/load
ers/emit-file-loader.js:27:68)

 @ ./src/pages/_app.js 35:0-53 156:17-26 157:13-22
 @ multi ./pages/_app.js
```

`next.config.js` (shortened):
```js
module.exports = {
  webpack: (config, { dev }) => {
    config.module.rules.push({
      test: /\.scss$/,
      use: [
        {
          loader: 'emit-file-loader',
          options: {
            name: 'dist/[path][name].[ext].js'
          }
        },
        {
          loader: 'babel-loader',
          options: {
            babelrc: false,
            extends: path.resolve(__dirname, './src/.babelrc')
          }
        },
        'styled-jsx-css-loader',
        { loader: 'postcss-loader', options: { sourceMap: dev } },
        {
          loader: 'sass-loader',
          options: {
            sourceMap: dev
          }
        }
      ]
    });

    return config;
  }
};
```

## Suggested Fix

A quick Google search brought me to a [related issue in `webpack-loader`](https://github.com/webpack-contrib/worker-loader/issues/125). As pointed out in the [Webpack docs](https://webpack.js.org/api/loaders/#this-rootcontext):

> Starting with webpack 4, the formerly `this.options.context` is provided as `this.rootContext`.

This PR makes this change while maintaining backward compatibility.

## System information

Next.js: 6.1.1-canary.4
Node: v9.3.0
2018-08-07 13:49:30 -07:00
Tim Neutkens 6de99ebc4a
Set correct status for sigint (#4917)
Fixes #4916
2018-08-07 11:50:26 -07:00
Tim Neutkens a528565c69
Make next/link async safe (#4911)
Removes componentWillMount and uses memoize instead as recommended here: https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html
2018-08-06 22:44:18 -07:00
HaNdTriX 3286ecb3fc Add slate.js example (#4899) 2018-08-06 21:00:31 -07:00
Tim Neutkens f3f939dde4
Run method sorting codemod (#4909)
react-codemod recommended way of having methods defined
2018-08-06 20:53:06 -07:00
Tim Neutkens 80fdfec088
Fix decorator warnings (#4910) 2018-08-06 20:47:27 -07:00
Tim Neutkens b20b80adf0
Run rename-unsafe-lifecycles as preparation for React 17 (#4907)
https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles
2018-08-06 20:23:28 -07:00
Tim Neutkens 4c602ff395
Run manual-bind-to-arrow codemod (#4906)
https://github.com/reactjs/react-codemod#manual-bind-to-arrow
2018-08-06 20:20:01 -07:00
Thomas Hermann 83970c908d Add with-strict-csp example (#4858) 2018-08-06 20:19:16 -07:00
Hugo Heyman e8aa78204a Improve glamor example (#4893)
Changes:
- Use css prop on the element to style it
- Add webpack + babelrc configuration to remove otherwise needed import boilerplate [according to glamor docs](https://github.com/threepointone/glamor/blob/master/docs/createElement.md)

Rationale: The killer feature of glamor that makes it so great is that it relieves you from naming classes/styles if you use the custom css prop. Together with the babel plugin you also don't need any extra import wherever the css prop is used.

All the real world uses I've seen of glamor has used the css props so I think the example should reflect this. As an example here is docs how to use glamor with gatsby (using the css prop):
https://www.gatsbyjs.org/docs/glamor/
2018-08-05 16:13:28 -07:00
Tim Neutkens a41e3c102e
Await preloading right before rendering the page (#4896) 2018-08-05 15:53:34 -07:00
Kate 05b6891620 Fixed server status message in with-redux-observable-example. (#4900)
**Changes:**
- Fixed "was character fetched on server" message by properly passing `isServer`.
- Stop fetching if there was an error (currently it keeps sending requests to the same endpoint every 3 sec)

**Related:**
- https://github.com/zeit/next.js/pull/4818
- https://github.com/zeit/next.js/issues/4724
2018-08-05 10:56:04 -07:00
Sayuti Daniel 919b88509c Let webpack handle contenthash (#4895) 2018-08-04 11:18:20 -07:00
Tomek b1459bfd60 update with-sentry example (#4859)
Changes:

* moved the configuration from HOC to `_app.js`
* fixed the example, as `componentDidCatch` catches errors during rendering phase, but not within event handlers.
2018-08-04 10:51:35 -07:00
Sayuti Daniel bd3f65b37f Use contenthash instead of chunkhash (#4894)
https://github.com/webpack/webpack.js.org/issues/2096
2018-08-04 10:00:13 -07:00
Jacob Page b492e6703d Make EventEmitter more Node-like (#4865)
Add behaviors to make `EventEmitter` a bit more like its NodeJS counterpart. This should make using it a bit less surprising.
2018-08-01 14:43:25 +02:00
Max Stoiber 80202069cf Note babel-plugin-styled-components (#4882)
Otherwise folks might miss that part and get checksum mismatches!
2018-08-01 13:57:30 +02:00
Tim Neutkens 59c7d42d36 6.1.1-canary.4 2018-07-31 21:24:46 +02:00
Tim Neutkens 9240cf7855
Make .events work even when router is not initialized (#4874)
Followup of https://github.com/zeit/next.js/issues/4863#issuecomment-408920755
2018-07-31 21:04:14 +02:00
Tim Neutkens b65d2dff30 6.1.1-canary.3 2018-07-30 21:35:19 +02:00
Tim Neutkens 183866a96d
Add support for rendering .css chunks (#4861)
Depends on https://github.com/zeit/next-plugins/pull/228

Failing tests are expected as `@zeit/next-css` has to be updated/released first.

This implements rendering of `.css` chunks. Effectively removing the custom document requirement when adding next-css/sass/less/stylus.
2018-07-30 15:48:02 +02:00
José Manuel Aguirre 7282f43f7b Missing babel configuration in sw-precache example (#4856)
Missing configuration in package.json and .babelrc causes this example to be broken after installing and running the example.
2018-07-27 22:54:01 +02:00
Tomek 88610694c2 update with-prefetching example (#4850) 2018-07-27 22:08:09 +02:00
Tim Neutkens 283e9afe70
Upgrade serve (#4857) 2018-07-27 21:13:55 +02:00
Tim Neutkens 6a087c6a5d
Rename commons directory to runtime (#4853) 2018-07-27 19:29:25 +02:00
Stefan Ivic fc05c9c273 Update readme with alternative hostname option (#4829)
Tackles the issue in #4025.
2018-07-26 12:42:35 +02:00
Tim Neutkens 8e2c199ea7
Fix dynamic import page navigation (#4842)
Fixes #3775
2018-07-26 12:38:45 +02:00
Tomek f4988e7fa3 update with-markdown example (#4839)
Changes:

* replaced the `markdown-in-js` with nextjs plugin for `MDX`

Highly inspired by the example from [MDX repository](https://github.com/mdx-js/mdx/tree/master/examples/next)
2018-07-25 20:06:40 +02:00
Tim Neutkens 475b426ed1
Compile pages to .next/static directory (#4828)
* Compile pages to .next/static/<buildid>/pages/<page>

* Fix test

* Export class instead of using exports

* Use constant for static directory

* Add comment about what the middleware does
2018-07-25 13:45:42 +02:00
Tomek c090a57e77 update with-flow example (#4835)
Changes:
* updated packages
* moved the content of `layout` to `_app.js` and created simple `Page` component
* replaced `import * as React` because it is not necessary to import everything
* moved `next.js.flow` to `flow-typed` as it is default directory for library definitions
* updated the gif
2018-07-25 13:42:40 +02:00
Tomek d1fbcfe5de update with-asset-import example (#4830)
Changes:
- use `next-images` plugin for handling static files import
2018-07-24 19:11:21 +02:00
S. Suzuki 6bd24fd9e2 Fix micro readme example (#4827)
I found mistake on readme
2018-07-24 13:55:13 +02:00
Tim Neutkens 75476a9136
[WIP] Webpack 4, react-error-overlay, react-loadable (#4639)
Webpack 4, react-error-overlay, react-loadable (major)
2018-07-24 11:24:40 +02:00
Rustam Gilyaziev e2b518525c Update with-react-intl example (#4825)
Changes:
- added withIntl HOC because injectIntl do no hoist static methods
- fixed `Cannot read property 'locale' of undefined`
2018-07-24 00:43:57 +02:00
Tomek b1222962f0 update client-only-render-external-dependency example (#4822)
Changes:
* use `dynamic` imports instead of `require`
* update `recharts` dependency
2018-07-22 20:53:22 +02:00
Tomek 53853d3fa9 update with-redux-observable example (#4818) 2018-07-22 01:37:59 +02:00
Tomek 822cc3c863 update with-react-intl example (#4817) 2018-07-22 01:37:25 +02:00
Tomek 0d93d42640 update with-react-ga example (#4816)
Changes:
* updated `react-ga` package
* updated README.md
* Removed `Layout` component and used custom App component
* used `routeChangeComplete` to log route changes.
2018-07-21 19:27:48 +02:00
Adrian Li 6ef7625ba6 Update example: Semantic-UI (#4815)
The existing example currently does not work because of outdated usage patterns. This PR seeks to update these patterns to the latest recommended best practice while bumping versions.

# Summary

- Bumped version numbers in `package.json`;
- Moved `<link />` tag from `pages/index.js` to `pages/_document.js` as is [recommended](https://github.com/zeit/next-plugins/tree/master/packages/next-css#usage);
- Replace individual css/font imports with import of minified CSS as is [recommended](https://react.semantic-ui.com/usage#semantic-ui-css-package);
- Removed prop (no longer used) from `<List />` element.
2018-07-21 12:42:38 +02:00
Brian Kim 0298c722b1 improve custom-server-fastify example (#4805)
I’ve been experimenting with Next.js and Fastify and I made the following changes to the Fastify example based on what I found:

### Use Fastify’s plugin API
IMO putting Fastify’s listen call in a promise callback is an anti-pattern, b/c the Fastify plugin API is meant to solve the problem of async server bootstrapping.

[From Fastify’s Getting Started docs](https://www.fastify.io/docs/latest/Getting-Started/):
> Fastify provides a foundation that assists with the asynchronous bootstrapping of your application.

### Set reply.sent in handlers which return promises

[From Fastify’s Routes docs](https://www.fastify.io/docs/latest/Routes/#promise-resolution):
> If your handler is an `async` function or returns a promise, you should be aware of a special behaviour which is necessary to support the callback and promise control-flow. If the handler's promise is resolved with `undefined`, it will be ignored causing the request to hang and an *error* log to be emitted.
>
> 1. If you want to use `async/await` or promises but respond a value with `reply.send`:
>     - **Don't** `return` any value.
>     - **Don't** forget to call `reply.send`.
> 2. If you want to use `async/await` or promises:
>     - **Don't** use `reply.send`.
>     - **Don't** return `undefined`.

`app.render` returns a promise which contains undefined, so returning it in a Fastify handler will log an error. However, returning anything besides undefined will cause Fastify to try to write to the response which Next.js has already ended. The solution is to manually set the `reply.sent` flag to true when any Next.js rendering promise is fulfilled as an alternative to calling `reply.send`.

### Make Next.js handle 404 errors
This allows any route to throw a NotFound error and let Next.js handle the rendering of the 404 page.

### Make Next.js handle any route which starts with `_next` in dev
This prevents dev routes from being caught by user-defined routes.
2018-07-19 21:27:22 +02:00
Tim Neutkens d83207cd4b 6.1.1-canary.2 2018-07-19 14:39:44 +02:00
Tim Neutkens 6415d5f4ee
Upgrade fastify in custom-server-fastify (#4801) 2018-07-19 00:18:15 +02:00
Tim Neutkens 76657f8451
Upgrade serve in with-static-export example (#4800) 2018-07-18 22:16:06 +02:00
Lukasz Ostrowski 6e5bab1a1d Ensured process exits after static export (#4747) (#4749)
Fixes [this issue](https://github.com/zeit/next.js/issues/4747)

I don't know what is the reason why the process does not finish, because it can be reproduced in this repo in many environments (my local mac os and Netlify pipeline).

However, it fixes the problem and it's 100% safe.
2018-07-17 17:11:19 +02:00
David Calhoun 6f4925c193 [change] Update RNW example (#4787) 2018-07-15 20:59:20 +02:00
Leo Lamprecht 0f87368da2 Renewed npm token (#4780)
As per [this post](https://blog.npmjs.org/post/175824896885/incident-report-npm-inc-operations-incident-of).

**This needs to be cherry-picked to master as well.**
2018-07-13 19:57:46 +02:00
Tim Neutkens 921084fc4e 6.1.1-canary.1 2018-07-13 18:18:05 +02:00
Albin Ekblom 992ea2e875 Allow app component to be wrapped with custom enhancer when rendering (#4762)
* Add support for custom App and Component enhancers

* Add ctx.renderPage test

* Add tests for single enhancer function

* Cleanup renderPage options check

* Cleanup

* Add comment about backwards compatibility for renderPage

* Add more test cases
2018-07-13 11:22:45 +02:00