-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
13 changed files
with
143 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import 'react-hot-loader/patch' | ||
import * as next from './next' | ||
|
||
module.exports = next | ||
import { requireModule } from '../lib/eval-script' | ||
|
||
window.next = next | ||
module.exports = requireModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Example app using shared modules | ||
|
||
This example features: | ||
|
||
* An app with two pages which has a common Counter component | ||
* That Counter component maintain the counter inside its module. | ||
|
||
## How to run it | ||
|
||
```sh | ||
npm install | ||
npm run dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
|
||
let count = 0 | ||
|
||
export default class Counter extends React.Component { | ||
add () { | ||
count += 1 | ||
this.forceUpdate() | ||
} | ||
|
||
render () { | ||
return ( | ||
<div> | ||
<p>Count is: {count}</p> | ||
<button onClick={() => this.add()}>Add</button> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
const styles = { | ||
a: { | ||
marginRight: 10 | ||
} | ||
} | ||
|
||
export default () => ( | ||
<div> | ||
<Link href='/'> | ||
<a style={styles.a} >Home</a> | ||
</Link> | ||
|
||
<Link href='/about'> | ||
<a style={styles.a} >About</a> | ||
</Link> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "shared-modules", | ||
"version": "1.0.0", | ||
"description": "This example features:", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "next", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"next": "*" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"next": { | ||
"cdn": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Header from '../components/Header' | ||
import Counter from '../components/Counter' | ||
|
||
export default () => ( | ||
<div> | ||
<Header /> | ||
<p>This is the about page.</p> | ||
<Counter /> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Header from '../components/Header' | ||
import Counter from '../components/Counter' | ||
|
||
export default () => ( | ||
<div> | ||
<Header /> | ||
<p>HOME PAGE is here!</p> | ||
<Counter /> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters