Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal Webpack #3578

Merged
merged 138 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
fcb3430
Speed up next build
timneutkens Dec 21, 2017
c1ebbf6
Document webpack config
timneutkens Dec 21, 2017
83916b7
Speed up next build
timneutkens Dec 21, 2017
443ece9
Remove comment
timneutkens Dec 21, 2017
0aacb17
Add comment
timneutkens Dec 21, 2017
ad6cc8a
Merge branch 'fix/webpack-build-speed-increase' into feature/universa…
timneutkens Dec 21, 2017
6ce025e
Clean up rules
timneutkens Dec 21, 2017
c3914ea
Add comments
timneutkens Dec 21, 2017
b1aac7b
Run in parallel
timneutkens Dec 21, 2017
7bee9a7
Push plugins seperately
timneutkens Dec 21, 2017
5373354
Create a new chunk for react
timneutkens Dec 21, 2017
dc3f242
Don’t uglify react since it’s already uglified. Move react to commons…
timneutkens Dec 22, 2017
6fabf34
Use the minified version directly
timneutkens Dec 22, 2017
654c48e
Re-add globpattern
timneutkens Dec 22, 2017
3192950
Merge branch 'canary' of github.com:zeit/next.js into fix/add-comment…
timneutkens Dec 22, 2017
25e8bca
Move loaders into a separate variable
timneutkens Dec 22, 2017
82e5505
Add comment linking to Dan’s explanation
timneutkens Dec 22, 2017
c8ff14b
Remove dot
timneutkens Dec 22, 2017
b4fbe50
Add universal webpack
timneutkens Dec 23, 2017
a057415
Initial dev support
timneutkens Dec 27, 2017
8226bd9
Fix linting
timneutkens Dec 27, 2017
91569e0
Merge branch 'canary' of github.com:zeit/next.js into feature/webpack
timneutkens Dec 27, 2017
e5d2078
Add changes from Arunoda's work
timneutkens Dec 27, 2017
b843e6e
Made next dev works.
arunoda Jan 4, 2018
9da6404
Fix client side hot reload
timneutkens Jan 4, 2018
5cb819a
Server side hmr
timneutkens Jan 4, 2018
b97bc2f
Only in dev
timneutkens Jan 4, 2018
89f9793
Add on-demand-entries client + hot-middleware
timneutkens Jan 5, 2018
aec6aa1
Add .babelrc support
timneutkens Jan 5, 2018
888bc35
Speed up on demand entries by running in parallel
timneutkens Jan 5, 2018
ab26369
Serve static generated files
timneutkens Jan 5, 2018
8859c5f
Add missing config in dev
timneutkens Jan 5, 2018
84d785a
Add sass support
timneutkens Jan 5, 2018
c5ccf23
Add support for .map
timneutkens Jan 5, 2018
bb5cf9a
Add cssloader config and fix .jsx support
timneutkens Jan 5, 2018
565bf54
Rename
timneutkens Jan 5, 2018
122fc92
use same defaults as css-loader. Fix linting
timneutkens Jan 9, 2018
c487416
Add NoEmitErrorsPlugin
timneutkens Jan 9, 2018
c6c7e15
Add clientBootstrap
timneutkens Jan 9, 2018
008e659
Use webpackhotmiddleware on the multi compiler
timneutkens Jan 9, 2018
fa4b18f
alpha.3
timneutkens Jan 9, 2018
2057482
Use babel 16.2.x
timneutkens Jan 11, 2018
7bd3178
Fix reloading after error
timneutkens Jan 11, 2018
c136af8
Remove comment
timneutkens Jan 11, 2018
bf78292
Release 5.0.0-univeral-alpha.1
timneutkens Jan 11, 2018
5e5b9e8
Remove check for React 16
timneutkens Jan 11, 2018
7b339a4
Release 5.0.0-universal-alpha.2
timneutkens Jan 11, 2018
6494359
React hot loader v4
timneutkens Jan 13, 2018
f8f1fba
Use our static file rendering machanism to serve pages.
arunoda Jan 13, 2018
820d3c3
Release 5.0.0-universal-alpha.3
timneutkens Jan 13, 2018
48e4d63
Remove optional loaders
timneutkens Jan 13, 2018
190b930
Release 5.0.0-universal-alpha.4
timneutkens Jan 13, 2018
573d4a6
Remove clientBootstrap
timneutkens Jan 14, 2018
e0d2a41
Remove renderScript
timneutkens Jan 15, 2018
7d83ae4
Make sure pages bundles are served correctly
timneutkens Jan 13, 2018
9eac841
Remove unused import
timneutkens Jan 15, 2018
ea67454
Revert to using the same code as canary
timneutkens Jan 15, 2018
340b93d
Fix hot loader
timneutkens Jan 15, 2018
52605da
Release 5.0.0-universal-alpha.5
timneutkens Jan 15, 2018
3347940
Check if externals dir exist before applying config
timneutkens Jan 15, 2018
5434104
Add typescript support
timneutkens Jan 16, 2018
d4b1d9b
Add support for transpiling certain packages in node_modules
timneutkens Jan 16, 2018
4ca1a44
Add BABEL_DISABLE_CACHE support
timneutkens Jan 16, 2018
5821d49
Make sourcemaps in production opt-in
timneutkens Jan 16, 2018
91ad193
Revert "Add support for transpiling certain packages in node_modules"
timneutkens Jan 16, 2018
dbbdec4
Support typescript through next.config.js
timneutkens Jan 17, 2018
5fd08f1
Remove comments
timneutkens Jan 17, 2018
fcea07c
Bring back commons.js calculation
timneutkens Jan 17, 2018
04651be
Remove unused dependencies
timneutkens Jan 17, 2018
1f023a8
Move base.config.js to webpack.js
timneutkens Jan 17, 2018
435b60d
Make sure to only invalidate webpackDevMiddleware one after other.
arunoda Jan 17, 2018
1a2ab91
Allow babel-loder caching by default.
arunoda Jan 18, 2018
495e0a4
Add comment about preact support
timneutkens Jan 17, 2018
2a3aa74
Bring back buildir replace
timneutkens Jan 17, 2018
8e96607
Remove obsolete plugin
timneutkens Jan 18, 2018
6473226
Remove build replace, speed up build
timneutkens Jan 18, 2018
30af0bf
Resolve page entries like pages/day/index.js to pages/day.js
timneutkens Jan 18, 2018
d82c566
Add componentDidCatch back
timneutkens Jan 18, 2018
94fdee5
Compile to bundles
timneutkens Jan 18, 2018
bd27a7e
Use config.distDir everywhere
timneutkens Jan 18, 2018
deff65a
Make sure the file is an array
timneutkens Jan 18, 2018
ef06a04
Remove console.log
timneutkens Jan 18, 2018
de8d0fb
Apply optimization to uglifyjs
timneutkens Jan 18, 2018
c80228b
Add comment pointing to source
timneutkens Jan 18, 2018
49e2808
Create entries the same way in dev and production
timneutkens Jan 18, 2018
7106aff
Remove unused and broken pagesGlobPattern
timneutkens Jan 18, 2018
a10c21e
day/index.js is automatically turned into day.js at build time
timneutkens Jan 18, 2018
fb7c862
Remove poweredByHeader option
timneutkens Jan 18, 2018
d948ef5
Load pages with the correct path.
arunoda Jan 19, 2018
763a1d2
Release 5.0.0-universal-alpha.6
timneutkens Jan 19, 2018
9b709c5
Make sure react-dom/server can be overwritten by module-alias
timneutkens Jan 19, 2018
6b62551
Only add react-hot-loader babel plugin in dev
timneutkens Jan 19, 2018
4617987
Release 5.0.0-universal-alpha.7
timneutkens Jan 19, 2018
6833e8b
Revert tests
timneutkens Jan 19, 2018
516fa62
Release 5.0.0-universal-alpha.10
timneutkens Jan 19, 2018
97f45e9
Make sure next/head is working properly.
arunoda Jan 19, 2018
e57c236
Add wepack alias for 'next' back.
arunoda Jan 19, 2018
7ed60b7
Make sure overriding className in next/head works
timneutkens Jan 19, 2018
4911d0a
Alias react too
timneutkens Jan 19, 2018
f820315
Merge branch 'feature/webpack' of github.com:zeit/next.js into featur…
timneutkens Jan 19, 2018
8e9f8c7
Add missing r
timneutkens Jan 19, 2018
7e9fa41
Fragment fallback has to wrap the children
timneutkens Jan 19, 2018
1e6e829
Use min.js
timneutkens Jan 20, 2018
3897e64
Remove css.js
timneutkens Jan 20, 2018
9f4de5b
Remove wallaby.js
timneutkens Jan 20, 2018
0aa6aac
Release 5.0.0-universal-alpha.11
timneutkens Jan 20, 2018
65c0747
Merge branch 'canary' of github.com:zeit/next.js into feature/webpack
timneutkens Jan 20, 2018
a13f3e4
Resolve relative to workdir instead of next
timneutkens Jan 20, 2018
15d2280
Make sure we touch the right file
timneutkens Jan 21, 2018
280b9c7
Resolve next modules
timneutkens Jan 21, 2018
3479800
Remove dotjsx removal plugins since we use webpack on the server
timneutkens Jan 21, 2018
49b119b
Revert "Resolve relative to workdir instead of next"
timneutkens Jan 22, 2018
5650e50
Externalize any locally loaded module lives outside of app dir.
timneutkens Jan 21, 2018
e7a938c
Remove server aliases
timneutkens Jan 22, 2018
827c813
Check node_modules reliably
timneutkens Jan 22, 2018
aeea881
Add symlink to next for tests
timneutkens Jan 22, 2018
f9e9712
Make sure dynamic imports work locally.
arunoda Jan 23, 2018
6845af9
dynmaic -> dynamic
timneutkens Jan 23, 2018
89f5563
Remove webpack-node-externals
timneutkens Jan 23, 2018
c8f9c70
Make sure dynamic imports support SSR.
arunoda Jan 26, 2018
53c9a6b
Remove css support in favor of next-css
timneutkens Jan 26, 2018
d6dee1e
Make sure we load path from `/` since it’s included in the path matching
timneutkens Jan 28, 2018
ef5f3de
Catch when ensurepage couldn’t be fulfilled for `.js.map`
timneutkens Jan 28, 2018
96b99ac
Register require cache flusher for both client and server
timneutkens Jan 29, 2018
440b39f
Add comment explaining this is to facilitate hot reloading
timneutkens Jan 29, 2018
c73853c
Only load module when needed
timneutkens Jan 29, 2018
3269104
Remove unused modules
timneutkens Jan 29, 2018
e38c605
Release 5.0.0-universal-alpha.12
timneutkens Jan 29, 2018
01c84a1
Only log the `found babel` message once
timneutkens Jan 29, 2018
91ce3f9
Make sure ondemand entries working correctly.
arunoda Jan 29, 2018
a62b764
Better sourcemaps
timneutkens Jan 29, 2018
415de61
Release 5.0.0-universal-alpha.13
timneutkens Jan 29, 2018
3de72fc
Lock uglify version to 1.1.6
timneutkens Jan 29, 2018
256ad20
Release 5.0.0-universal-alpha.14
timneutkens Jan 29, 2018
563c9c3
Fix a typo.
arunoda Jan 30, 2018
3b0d1f8
Introduce multi-zones support for mircofrontends
arunoda Jan 30, 2018
3018694
Add section on css
timneutkens Jan 30, 2018
1226b3d
Merge branch 'feature/webpack' of github.com:zeit/next.js into featur…
timneutkens Jan 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/lib/asset')
4 changes: 1 addition & 3 deletions bin/next-dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env node
import 'source-map-support/register'
import { resolve, join } from 'path'
import parseArgs from 'minimist'
import { existsSync, readFileSync } from 'fs'
import Server from '../server'
import { printAndExit } from '../lib/utils'
import pkgUp from 'pkg-up'

const argv = parseArgs(process.argv.slice(2), {
alias: {
Expand Down Expand Up @@ -64,7 +62,7 @@ srv.start(argv.port, argv.hostname)
.catch((err) => {
if (err.code === 'EADDRINUSE') {
let errorMessage = `Port ${argv.port} is already in use.`
const pkgAppPath = pkgUp.sync('.')
const pkgAppPath = require('pkg-up').sync('.')
const appPackage = JSON.parse(readFileSync(pkgAppPath, 'utf8'))
const nextScript = Object.entries(appPackage.scripts).find(scriptLine => scriptLine[1] === 'next')
if (nextScript) errorMessage += `\nUse \`npm run ${nextScript[0]} -- -p <some other port>\`.`
Expand Down
12 changes: 7 additions & 5 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EventEmitter from '../lib/EventEmitter'
import App from '../lib/app'
import { loadGetInitialProps, getURL } from '../lib/utils'
import PageLoader from '../lib/page-loader'
import * as asset from '../lib/asset'

// Polyfill Promise globally
// This is needed because Webpack2's dynamic loading(common chunks) code
Expand All @@ -29,6 +30,9 @@ const {
location
} = window

// With this, static assets will work across zones
asset.setAssetPrefix(assetPrefix)

const asPath = getURL()

const pageLoader = new PageLoader(buildId, assetPrefix)
Expand Down Expand Up @@ -93,10 +97,7 @@ export default async ({ ErrorDebugComponent: passedDebugComponent, stripAnsi: pa
}

export async function render (props) {
// There are some errors we should ignore.
// Next.js rendering logic knows how to handle them.
// These are specially 404 errors
if (props.err && !props.err.ignore) {
if (props.err) {
await renderError(props.err)
return
}
Expand Down Expand Up @@ -159,7 +160,8 @@ async function doRender ({ Component, props, hash, err, emitter: emitterProp = e

let isInitialRender = true
function renderReactElement (reactEl, domEl) {
if (isInitialRender) {
// The check for `.hydrate` is there to support React alternatives like preact
if (isInitialRender && typeof ReactDOM.hydrate === 'function') {
ReactDOM.hydrate(reactEl, domEl)
isInitialRender = false
} else {
Expand Down
3 changes: 2 additions & 1 deletion client/next-dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'react-hot-loader/patch'
import stripAnsi from 'strip-ansi'
import initNext, * as next from './'
import ErrorDebugComponent from '../lib/error-debug'
import initOnDemandEntries from './on-demand-entries-client'
import initWebpackHMR from './webpack-hot-middleware-client'

require('@zeit/source-map-support/browser-source-map-support')

window.next = next

initNext({ ErrorDebugComponent, stripAnsi })
Expand Down
12 changes: 9 additions & 3 deletions client/on-demand-entries-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@
import Router from '../lib/router'
import fetch from 'unfetch'

const {
__NEXT_DATA__: {
assetPrefix
}
} = window

export default () => {
Router.ready(() => {
Router.router.events.on('routeChangeComplete', ping)
})

async function ping () {
try {
const url = `/_next/on-demand-entries-ping?page=${Router.pathname}`
const url = `${assetPrefix}/_next/on-demand-entries-ping?page=${Router.pathname}`
const res = await fetch(url, {
credentials: 'same-origin'
credentials: 'omit'
})
const payload = await res.json()
if (payload.invalid) {
// Payload can be invalid even if the page is not exists.
// So, we need to make sure it's exists before reloading.
const pageRes = await fetch(location.href, {
credentials: 'same-origin'
credentials: 'omit'
})
if (pageRes.status === 200) {
location.reload()
Expand Down
14 changes: 13 additions & 1 deletion client/webpack-hot-middleware-client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import webpackHotMiddlewareClient from 'webpack-hot-middleware/client?overlay=false&reload=true&path=/_next/webpack-hmr'
import webpackHotMiddlewareClient from 'webpack-hot-middleware/client?autoConnect=false'
import Router from '../lib/router'

const {
__NEXT_DATA__: {
assetPrefix
}
} = window

export default () => {
webpackHotMiddlewareClient.setOptionsAndConnect({
overlay: false,
reload: true,
path: `${assetPrefix}/_next/webpack-hmr`
})

const handlers = {
reload (route) {
if (route === '/_error') {
Expand Down
1 change: 0 additions & 1 deletion css.js

This file was deleted.

15 changes: 15 additions & 0 deletions errors/powered-by-header-option-removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# The poweredByHeader has been removed

#### Why This Error Occurred

Starting at Next.js version 5.0.0 the `poweredByHeader` option has been removed.

#### Possible Ways to Fix It

If you still want to remove `x-powered-by` you can use one of the custom-server examples.

And then manually remove the header using `res.removeHeader('x-powered-by')`

### Useful Links

- [Custom Server documentation + examples](https://github.com/zeit/next.js#custom-server-and-routing)
3 changes: 3 additions & 0 deletions examples/hello-world/pages/about2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => (
<div>About 2</div>
)
3 changes: 3 additions & 0 deletions examples/hello-world/pages/day/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => (
<div>Hello Day</div>
)
71 changes: 71 additions & 0 deletions examples/with-zones/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-zones)

# Using multiple zones

With Next.js you can use multiple apps as a single app using it's multi-zones feature.
This is an example showing how to use it.

In this example, we've two apps: 'home' and 'blog'.
We also have a set of rules defined in `rules.json` for the proxy.

Now let's start two of our app using:

```
npm run home
npm run blog
```

Then start the proxy:

```
npm run proxy
```

Now you can visit http://localhost:9000 and access and develop both apps a single app.

### Proxy Rules

This is the place we define rules for our proxy. Here are the rules(in `rules.json`) available for this app:

```json
{
"rules": [
{"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
{"pathname": "/**", "dest": "http://localhost:4000"}
]
}
```

These rules are based on ZEIT now [path alias](https://zeit.co/docs/features/path-aliases) rules and use [`micro-proxy`](https://github.com/zeit/micro-proxy) as the proxy.

## Special Notes

* All pages should be unique across zones. A page with the same name should not exist in multiple zones. Otherwise, there'll be unexpected behaviour in client side navigation.
* According to the above example, a page named `blog` should not be exist in the `home` zone.

## Production Deployment

Here's how are going to deploy this application into production.

* Open the `now.json` file in both `blog` and `home` directories and change the aliases as you wish.
* Then update `rules-prod.json` accordingly.
* Now deploy both apps:

~~~sh
cd home
now && now alias
cd ../blog
now && now alias
cd ..
~~~

* Finally, set the path alias rules with

~~~sh
now alias with-zones.now.sh -r rules-prod.json
~~~

> You can use a domain name of your choice in the above command instead of `with-zones.now.sh`.

That's it.
Now you can access the final app via: <https://with-zones.now.sh>
2 changes: 2 additions & 0 deletions examples/with-zones/blog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
node_modules
6 changes: 6 additions & 0 deletions examples/with-zones/blog/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { NOW_URL } = process.env
const { alias } = require('./now.json')

module.exports = {
assetPrefix: NOW_URL ? `https://${alias}` : 'http://localhost:5000'
}
3 changes: 3 additions & 0 deletions examples/with-zones/blog/now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"alias": "with-zones-blog.now.sh"
}
14 changes: 14 additions & 0 deletions examples/with-zones/blog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "with-zones-blog",
"version": "1.0.0",
"scripts": {
"build": "next build",
"start": "next start -p 4000"
},
"dependencies": {
"next": "zones",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"license": "ISC"
}
5 changes: 5 additions & 0 deletions examples/with-zones/blog/pages/blog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default () => (
<div>
This is our blog
</div>
)
2 changes: 2 additions & 0 deletions examples/with-zones/home/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
node_modules
5 changes: 5 additions & 0 deletions examples/with-zones/home/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default () => (
<div>
<h2>The Company</h2>
</div>
)
6 changes: 6 additions & 0 deletions examples/with-zones/home/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { NOW_URL } = process.env
const { alias } = require('./now.json')

module.exports = {
assetPrefix: NOW_URL ? `https://${alias}` : 'http://localhost:4000'
}
3 changes: 3 additions & 0 deletions examples/with-zones/home/now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"alias": "with-zones-home.now.sh"
}
14 changes: 14 additions & 0 deletions examples/with-zones/home/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "with-zones-home",
"version": "1.0.0",
"scripts": {
"build": "next build",
"start": "next start -p 4000"
},
"dependencies": {
"next": "zones",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"license": "ISC"
}
10 changes: 10 additions & 0 deletions examples/with-zones/home/pages/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import asset from 'next/asset'
import Link from 'next/link'

export default () => (
<div>
<p>This is the about page.</p>
<div><Link href='/'><a>Go Back</a></Link></div>
<img width={200} src={asset('/zeit.png')} />
</div>
)
15 changes: 15 additions & 0 deletions examples/with-zones/home/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Link from 'next/link'
import asset from 'next/asset'
import dynamic from 'next/dynamic'

const Header = dynamic(import('../components/Header'))

export default () => (
<div>
<Header />
<p>This is our homepage</p>
<div><Link href='/blog'><a>Blog</a></Link></div>
<div><Link href='/about'><a>About us</a></Link></div>
<img width={200} src={asset('/nextjs.png')} />
</div>
)
Binary file added examples/with-zones/home/static/nextjs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/with-zones/home/static/zeit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/with-zones/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "with-zones",
"version": "1.0.0",
"scripts": {
"home": "next home -p 4000",
"home-build": "next build home",
"home-start": "next start home -p 4000",
"blog": "next blog -p 5000",
"blog-build": "next build blog",
"blog-start": "next start blog -p 5000",
"proxy": "micro-proxy -r rules-dev.json"
},
"dependencies": {
"micro-proxy": "^1.0.0",
"next": "latest",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"license": "ISC"
}
6 changes: 6 additions & 0 deletions examples/with-zones/rules-dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": [
{"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
{"pathname": "/**", "dest": "http://localhost:4000"}
]
}
6 changes: 6 additions & 0 deletions examples/with-zones/rules-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": [
{"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "https://with-zones-blog.now.sh"},
{"pathname": "/**", "dest": "https://with-zones-home.now.sh"}
]
}
10 changes: 10 additions & 0 deletions lib/asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let assetPrefix

export default function asset (path) {
const pathWithoutSlash = path.replace(/^\//, '')
return `${assetPrefix}/static/${pathWithoutSlash}`
}

export function setAssetPrefix (url) {
assetPrefix = url
}
1 change: 0 additions & 1 deletion lib/css.js

This file was deleted.

5 changes: 5 additions & 0 deletions lib/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ export function flushChunks () {
}

export class SameLoopPromise {
static resolve (value) {
const promise = new SameLoopPromise((done) => done(value))
return promise
}

constructor (cb) {
this.onResultCallbacks = []
this.onErrorCallbacks = []
Expand Down
2 changes: 1 addition & 1 deletion lib/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function reduceComponents (components) {
.filter(unique())
.reverse()
.map((c) => {
const className = (c.className ? c.className + ' ' : '') + 'next-head'
const className = (c.props && c.props.className ? c.props.className + ' ' : '') + 'next-head'
return React.cloneElement(c, { className })
})
}
Expand Down
Loading