mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Upgrade standard.js (#4064)
* Upgrade standard.js # Conflicts: # yarn.lock * Upgrade babel-eslint
This commit is contained in:
parent
603b90ce02
commit
ebf0c47c25
|
@ -43,7 +43,7 @@ if (!existsSync(join(dir, 'pages'))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
build(dir)
|
build(dir)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -54,12 +54,12 @@ if (!existsSync(join(dir, 'pages'))) {
|
||||||
|
|
||||||
const srv = new Server({ dir, dev: true })
|
const srv = new Server({ dir, dev: true })
|
||||||
srv.start(argv.port, argv.hostname)
|
srv.start(argv.port, argv.hostname)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (!process.env.NOW) {
|
if (!process.env.NOW) {
|
||||||
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.code === 'EADDRINUSE') {
|
if (err.code === 'EADDRINUSE') {
|
||||||
let errorMessage = `Port ${argv.port} is already in use.`
|
let errorMessage = `Port ${argv.port} is already in use.`
|
||||||
const pkgAppPath = require('find-up').sync('package.json', {
|
const pkgAppPath = require('find-up').sync('package.json', {
|
||||||
|
@ -73,4 +73,4 @@ srv.start(argv.port, argv.hostname)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
process.nextTick(() => process.exit(1))
|
process.nextTick(() => process.exit(1))
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,12 +46,12 @@ const dir = resolve(argv._[0] || '.')
|
||||||
|
|
||||||
const srv = new Server({ dir })
|
const srv = new Server({ dir })
|
||||||
srv.start(argv.port, argv.hostname)
|
srv.start(argv.port, argv.hostname)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (!process.env.NOW) {
|
if (!process.env.NOW) {
|
||||||
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
|
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
|
||||||
|
@ -18,4 +18,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.get('/a', (req, res) => {
|
server.get('/a', (req, res) => {
|
||||||
|
@ -30,4 +30,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ const app = Next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = fastify()
|
const server = fastify()
|
||||||
|
|
||||||
server.get('/a', (req, res) => {
|
server.get('/a', (req, res) => {
|
||||||
|
@ -26,4 +26,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,8 +10,8 @@ const server = new Hapi.Server({
|
||||||
})
|
})
|
||||||
|
|
||||||
app
|
app
|
||||||
.prepare()
|
.prepare()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
server.route({
|
server.route({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/a',
|
path: '/a',
|
||||||
|
@ -43,4 +43,4 @@ app
|
||||||
console.log('Error starting server')
|
console.log('Error starting server')
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = new Koa()
|
const server = new Koa()
|
||||||
const router = new Router()
|
const router = new Router()
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ app.prepare()
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname, query } = parsedUrl
|
const { pathname, query } = parsedUrl
|
||||||
|
@ -25,4 +25,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname, query } = parsedUrl
|
const { pathname, query } = parsedUrl
|
||||||
|
@ -25,4 +25,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.get('/', (req, res) => {
|
server.get('/', (req, res) => {
|
||||||
|
@ -21,8 +21,8 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('> Ready on http://localhost:3000')
|
console.log('> Ready on http://localhost:3000')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((ex) => {
|
.catch((ex) => {
|
||||||
console.error(ex.stack)
|
console.error(ex.stack)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ const route = pathMatch()
|
||||||
const match = route('/blog/:id')
|
const match = route('/blog/:id')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const { pathname, query } = parse(req.url, true)
|
const { pathname, query } = parse(req.url, true)
|
||||||
const params = match(pathname)
|
const params = match(pathname)
|
||||||
|
@ -28,4 +28,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const rootStaticFiles = [
|
const rootStaticFiles = [
|
||||||
|
@ -28,4 +28,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,7 +14,7 @@ const ssrCache = new LRUCache({
|
||||||
})
|
})
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
// Use the `renderAndCache` utility defined below to serve pages
|
// Use the `renderAndCache` utility defined below to serve pages
|
||||||
|
@ -35,7 +35,7 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: make sure to modify this to take into account anything that should trigger
|
* NB: make sure to modify this to take into account anything that should trigger
|
||||||
|
|
|
@ -18,7 +18,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
@ -27,4 +27,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,7 +17,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
@ -26,4 +26,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
@ -20,4 +20,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable */
|
||||||
const withCss = require('@zeit/next-css')
|
const withCss = require('@zeit/next-css')
|
||||||
|
|
||||||
// fix: prevents error when .css files are required by node
|
// fix: prevents error when .css files are required by node
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default connect({
|
||||||
mounted: signal`clock.mounted`,
|
mounted: signal`clock.mounted`,
|
||||||
unMounted: signal`clock.unMounted`
|
unMounted: signal`clock.unMounted`
|
||||||
},
|
},
|
||||||
class Page extends React.Component {
|
class Page extends React.Component {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.props.mounted()
|
this.props.mounted()
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,5 @@ export default connect({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
RichUtils,
|
RichUtils,
|
||||||
convertToRaw,
|
convertToRaw,
|
||||||
convertFromRaw
|
convertFromRaw
|
||||||
} from 'draft-js'
|
} from 'draft-js'
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ const firebase = admin.initializeApp({
|
||||||
}, 'server')
|
}, 'server')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.use(bodyParser.json())
|
server.use(bodyParser.json())
|
||||||
|
@ -61,4 +61,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handler = routes.getRequestHandler(app)
|
const handler = routes.getRequestHandler(app)
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer(handler)
|
createServer(handler)
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handler = routes.getRequestHandler(app)
|
const handler = routes.getRequestHandler(app)
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer(handler)
|
createServer(handler)
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => handle(req, res, parse(req.url, true).pathname))
|
createServer((req, res) => handle(req, res, parse(req.url, true).pathname))
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
/* eslint no-extend-native: 0 */
|
/* eslint no-extend-native: 0 */
|
||||||
|
|
||||||
// Add your polyfills
|
|
||||||
// This files runs at the very beginning (even before React and Next.js core)
|
|
||||||
|
|
||||||
console.log('Load your polyfills')
|
|
||||||
|
|
||||||
// core-js comes with Next.js. So, you can import it like below
|
// core-js comes with Next.js. So, you can import it like below
|
||||||
import includes from 'core-js/library/fn/string/virtual/includes'
|
import includes from 'core-js/library/fn/string/virtual/includes'
|
||||||
import repeat from 'core-js/library/fn/string/virtual/repeat'
|
import repeat from 'core-js/library/fn/string/virtual/repeat'
|
||||||
|
|
||||||
|
// Add your polyfills
|
||||||
|
// This files runs at the very beginning (even before React and Next.js core)
|
||||||
|
console.log('Load your polyfills')
|
||||||
|
|
||||||
String.prototype.includes = includes
|
String.prototype.includes = includes
|
||||||
String.prototype.repeat = repeat
|
String.prototype.repeat = repeat
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
Router.forEachPattern((page, pattern, defaultParams) => server.get(pattern, (req, res) =>
|
Router.forEachPattern((page, pattern, defaultParams) => server.get(pattern, (req, res) =>
|
||||||
|
@ -17,4 +17,4 @@ app.prepare()
|
||||||
|
|
||||||
server.get('*', (req, res) => handle(req, res))
|
server.get('*', (req, res) => handle(req, res))
|
||||||
server.listen(port)
|
server.listen(port)
|
||||||
})
|
})
|
||||||
|
|
|
@ -39,5 +39,5 @@ export default connect(
|
||||||
character: state.character,
|
character: state.character,
|
||||||
error: state.error,
|
error: state.error,
|
||||||
isFetchedOnServer: state.isFetchedOnServer
|
isFetchedOnServer: state.isFetchedOnServer
|
||||||
}),
|
})
|
||||||
)(CharacterInfo)
|
)(CharacterInfo)
|
||||||
|
|
|
@ -46,5 +46,5 @@ export default withRedux(
|
||||||
{
|
{
|
||||||
startFetchingCharacters: actions.startFetchingCharacters,
|
startFetchingCharacters: actions.startFetchingCharacters,
|
||||||
stopFetchingCharacters: actions.stopFetchingCharacters
|
stopFetchingCharacters: actions.stopFetchingCharacters
|
||||||
},
|
}
|
||||||
)(Counter)
|
)(Counter)
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
query: { id: post.id }
|
query: { id: post.id }
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{},
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// combine the map of post pages with the home
|
// combine the map of post pages with the home
|
||||||
|
|
|
@ -7,7 +7,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
// custom route for posts
|
// custom route for posts
|
||||||
|
@ -25,4 +25,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,7 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname } = parsedUrl
|
const { pathname } = parsedUrl
|
||||||
|
@ -25,4 +25,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ const route = pathMatch()
|
||||||
const match = route('/about/:name')
|
const match = route('/about/:name')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const { pathname } = parse(req.url)
|
const { pathname } = parse(req.url)
|
||||||
const params = match(pathname)
|
const params = match(pathname)
|
||||||
|
@ -26,4 +26,4 @@ app.prepare()
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class EventEmitter {
|
||||||
|
|
||||||
emit (event, ...data) {
|
emit (event, ...data) {
|
||||||
if (!this.listeners[event]) return
|
if (!this.listeners[event]) return
|
||||||
this.listeners[event].forEach(cb => cb(...data))
|
this.listeners[event].forEach(cb => cb(...data)) // eslint-disable-line standard/no-callback-literal
|
||||||
}
|
}
|
||||||
|
|
||||||
off (event, cb) {
|
off (event, cb) {
|
||||||
|
|
|
@ -355,7 +355,7 @@ export default class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchRoute (route) {
|
async fetchRoute (route) {
|
||||||
return await this.pageLoader.loadPage(route)
|
return this.pageLoader.loadPage(route)
|
||||||
}
|
}
|
||||||
|
|
||||||
abortComponentLoad (as) {
|
abortComponentLoad (as) {
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
"@taskr/esnext": "1.1.0",
|
"@taskr/esnext": "1.1.0",
|
||||||
"@taskr/watch": "1.1.0",
|
"@taskr/watch": "1.1.0",
|
||||||
"@zeit/next-css": "0.0.7",
|
"@zeit/next-css": "0.0.7",
|
||||||
"babel-eslint": "8.0.1",
|
"babel-eslint": "8.2.2",
|
||||||
"babel-jest": "21.2.0",
|
"babel-jest": "21.2.0",
|
||||||
"babel-plugin-istanbul": "4.1.5",
|
"babel-plugin-istanbul": "4.1.5",
|
||||||
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
"react": "16.2.0",
|
"react": "16.2.0",
|
||||||
"react-dom": "16.2.0",
|
"react-dom": "16.2.0",
|
||||||
"rimraf": "2.6.2",
|
"rimraf": "2.6.2",
|
||||||
"standard": "9.0.2",
|
"standard": "11.0.1",
|
||||||
"taskr": "1.1.0",
|
"taskr": "1.1.0",
|
||||||
"wd": "1.4.1"
|
"wd": "1.4.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable import/first, no-return-await */
|
||||||
require('@zeit/source-map-support').install()
|
require('@zeit/source-map-support').install()
|
||||||
import { resolve, join, sep } from 'path'
|
import { resolve, join, sep } from 'path'
|
||||||
import { parse as parseUrl } from 'url'
|
import { parse as parseUrl } from 'url'
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||||
|
|
||||||
export default class AsyncProps extends React.Component {
|
export default class AsyncProps extends React.Component {
|
||||||
static async getInitialProps () {
|
static async getInitialProps () {
|
||||||
return await fetchData()
|
return fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default (context, render) => {
|
||||||
browser.close()
|
browser.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not show the default HMR error overlay', async() => {
|
it('should not show the default HMR error overlay', async () => {
|
||||||
const browser = await webdriver(context.appPort, '/hmr/about')
|
const browser = await webdriver(context.appPort, '/hmr/about')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('p').text()
|
.elementByCss('p').text()
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe('Custom Server', () => {
|
||||||
expect($dynamic('img').attr('src')).toBe(`http://127.0.0.1:${context.appPort}/static/myimage.png`)
|
expect($dynamic('img').attr('src')).toBe(`http://127.0.0.1:${context.appPort}/static/myimage.png`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support next/asset in client side', async() => {
|
it('should support next/asset in client side', async () => {
|
||||||
const browser = await webdriver(context.appPort, '/')
|
const browser = await webdriver(context.appPort, '/')
|
||||||
await browser
|
await browser
|
||||||
.elementByCss('#go-asset').click()
|
.elementByCss('#go-asset').click()
|
||||||
|
|
|
@ -18,27 +18,27 @@ export default function (context) {
|
||||||
expect(filePathLink).toEqual('/file-name.md')
|
expect(filePathLink).toEqual('/file-name.md')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a page with getInitialProps', async() => {
|
it('should render a page with getInitialProps', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic')
|
const html = await renderViaHTTP(context.port, '/dynamic')
|
||||||
expect(html).toMatch(/cool dynamic text/)
|
expect(html).toMatch(/cool dynamic text/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a dynamically rendered custom url page', async() => {
|
it('should render a dynamically rendered custom url page', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic/one')
|
const html = await renderViaHTTP(context.port, '/dynamic/one')
|
||||||
expect(html).toMatch(/next export is nice/)
|
expect(html).toMatch(/next export is nice/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render pages with dynamic imports', async() => {
|
it('should render pages with dynamic imports', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic-imports')
|
const html = await renderViaHTTP(context.port, '/dynamic-imports')
|
||||||
expect(html).toMatch(/Welcome to dynamic imports/)
|
expect(html).toMatch(/Welcome to dynamic imports/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render paths with extensions', async() => {
|
it('should render paths with extensions', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/file-name.md')
|
const html = await renderViaHTTP(context.port, '/file-name.md')
|
||||||
expect(html).toMatch(/this file has an extension/)
|
expect(html).toMatch(/this file has an extension/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should give empty object for query if there is no query', async() => {
|
it('should give empty object for query if there is no query', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/get-initial-props-with-no-query')
|
const html = await renderViaHTTP(context.port, '/get-initial-props-with-no-query')
|
||||||
expect(html).toMatch(/Query is: {}/)
|
expect(html).toMatch(/Query is: {}/)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue