Commit fad4ec39 authored by JJ Kasper's avatar JJ Kasper Committed by Tim Neutkens

Don't externalize ssr-prepass if added by user (#7966)

parent 8c5e85d4
...@@ -242,7 +242,19 @@ export default async function getBaseWebpackConfig( ...@@ -242,7 +242,19 @@ export default async function getBaseWebpackConfig(
// When the serverless target is used all node_modules will be compiled into the output bundles // When the serverless target is used all node_modules will be compiled into the output bundles
// So that the serverless bundles have 0 runtime dependencies // So that the serverless bundles have 0 runtime dependencies
'amp-toolbox-optimizer', // except this one 'amp-toolbox-optimizer', // except this one
...(config.experimental.ampBindInitData ? [] : ['react-ssr-prepass']), (context, request, callback) => {
if (
request === 'react-ssr-prepass' &&
!config.experimental.ampBindInitData
) {
// if it's the Next.js' require mark it as external
// since it's not used
if (context.includes('next-server/dist/server')) {
return callback(undefined, `commonjs ${request}`)
}
}
return callback()
},
], ],
optimization: Object.assign( optimization: Object.assign(
{ {
......
module.exports = {
target: 'serverless'
}
import ssrPrepass from 'react-ssr-prepass'
export default () => <p>hello {ssrPrepass && 'world'}</p>
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import {
killApp,
findPort,
nextStart,
nextBuild,
renderViaHTTP
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 30
const appDir = join(__dirname, '../')
let appPort
let app
describe('SSR Prepass', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
it('should not externalize when used outside Next.js', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/hello.*?world/)
})
})
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