mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
parent
f4988e7fa3
commit
8e2c199ea7
1
.babelrc
1
.babelrc
|
@ -5,6 +5,7 @@
|
||||||
"@babel/preset-flow"
|
"@babel/preset-flow"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
"@babel/plugin-proposal-object-rest-spread",
|
"@babel/plugin-proposal-object-rest-spread",
|
||||||
"@babel/plugin-proposal-class-properties",
|
"@babel/plugin-proposal-class-properties",
|
||||||
"@babel/plugin-transform-runtime"
|
"@babel/plugin-transform-runtime"
|
||||||
|
|
|
@ -2,6 +2,12 @@ import initNext, * as next from './'
|
||||||
import initOnDemandEntries from './on-demand-entries-client'
|
import initOnDemandEntries from './on-demand-entries-client'
|
||||||
import initWebpackHMR from './webpack-hot-middleware-client'
|
import initWebpackHMR from './webpack-hot-middleware-client'
|
||||||
|
|
||||||
|
// Temporary workaround for the issue described here:
|
||||||
|
// https://github.com/zeit/next.js/issues/3775#issuecomment-407438123
|
||||||
|
// The runtimeChunk doesn't have dynamic import handling code when there hasn't been a dynamic import
|
||||||
|
// The runtimeChunk can't hot reload itself currently to correct it when adding pages using on-demand-entries
|
||||||
|
import('./noop')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
__NEXT_DATA__: {
|
__NEXT_DATA__: {
|
||||||
assetPrefix
|
assetPrefix
|
||||||
|
|
0
client/noop.js
Normal file
0
client/noop.js
Normal file
1
test/integration/ondemand/components/hello.js
Normal file
1
test/integration/ondemand/components/hello.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default () => <p>Hello</p>
|
7
test/integration/ondemand/pages/nav/dynamic.js
Normal file
7
test/integration/ondemand/pages/nav/dynamic.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
|
const Hello = dynamic(import('../../components/hello.js'))
|
||||||
|
|
||||||
|
export default () => <div className='dynamic-page'>
|
||||||
|
<Hello />
|
||||||
|
</div>
|
5
test/integration/ondemand/pages/nav/index.js
Normal file
5
test/integration/ondemand/pages/nav/index.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
|
export default () => <div>
|
||||||
|
<Link href='/nav/dynamic'><a id='to-dynamic'>To dynamic import</a></Link>
|
||||||
|
</div>
|
|
@ -1,6 +1,7 @@
|
||||||
/* global jasmine, describe, beforeAll, afterAll, it, expect */
|
/* global jasmine, describe, beforeAll, afterAll, it, expect */
|
||||||
import { join, resolve } from 'path'
|
import { join, resolve } from 'path'
|
||||||
import { existsSync } from 'fs'
|
import { existsSync } from 'fs'
|
||||||
|
import webdriver from 'next-webdriver'
|
||||||
import {
|
import {
|
||||||
renderViaHTTP,
|
renderViaHTTP,
|
||||||
findPort,
|
findPort,
|
||||||
|
@ -57,4 +58,21 @@ describe('On Demand Entries', () => {
|
||||||
if (!existsSync(indexPagePath)) return
|
if (!existsSync(indexPagePath)) return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should navigate to pages with dynamic imports', async () => {
|
||||||
|
let browser
|
||||||
|
try {
|
||||||
|
browser = await webdriver(context.appPort, '/nav')
|
||||||
|
const text = await browser
|
||||||
|
.elementByCss('#to-dynamic').click()
|
||||||
|
.waitForElementByCss('.dynamic-page')
|
||||||
|
.elementByCss('p').text()
|
||||||
|
|
||||||
|
expect(text).toBe('Hello')
|
||||||
|
} finally {
|
||||||
|
if (browser) {
|
||||||
|
browser.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue