Commit 8ae1cd35 authored by JJ Kasper's avatar JJ Kasper Committed by Tim Neutkens

Fix dynamic require breaking after updating to v8 (#6475)

* Fix dynamic require breaking after updating to v8

* Add test for dynamic require
parent 1c1d5d01
......@@ -93,7 +93,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, isServe
return callback()
}
resolve(request, { basedir: context, preserveSymlinks: true }, (err, res) => {
resolve(request, { basedir: dir, preserveSymlinks: true }, (err, res) => {
if (err) {
return callback()
}
......
(function en (props) {
// no-nop
})()
(function en (props) {
// no-nop
})()
const locale = 'ru'
console.log(require(`../locales/${locale}`))
export default () => (
<p>If you can see this then we are good 👍</p>
)
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import {
renderViaHTTP,
launchApp,
findPort,
killApp
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 30
let server
let appPort
describe('Dynamic require', () => {
beforeAll(async () => {
appPort = await findPort()
server = await launchApp(join(__dirname, '../'), appPort)
})
afterAll(() => killApp(server))
it('should not throw error when dynamic require is used', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/If you can see this then we are good/)
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment