b0f87fbc7c
Bundle the ssr client layer for RSC, this solves the problem when there's an esm package is using on client components, but esm imports the installed react instead of the built-in react version since esm imports is not intercepted by require hook. After bundling the ssr client layer and treating react as externals, now react compiles as cjs externals and could be intercepted by require hook, other code are bundled together which can also get optimized. ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` Co-authored-by: Shu Ding <g@shud.in> Co-authored-by: JJ Kasper <jj@jjsweb.site>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { createNext, FileRef } from 'e2e-utils'
|
|
import { NextInstance } from 'test/lib/next-modes/base'
|
|
import { fetchViaHTTP, renderViaHTTP } from 'next-test-utils'
|
|
import path from 'path'
|
|
import cheerio from 'cheerio'
|
|
import webdriver from 'next-webdriver'
|
|
|
|
describe('app-dir assetPrefix handling', () => {
|
|
if ((global as any).isNextDeploy) {
|
|
it('should skip next deploy for now', () => {})
|
|
return
|
|
}
|
|
|
|
let next: NextInstance
|
|
|
|
beforeAll(async () => {
|
|
next = await createNext({
|
|
files: new FileRef(path.join(__dirname, 'asset-prefix')),
|
|
dependencies: {
|
|
react: 'experimental',
|
|
'react-dom': 'experimental',
|
|
},
|
|
skipStart: true,
|
|
})
|
|
|
|
await next.start()
|
|
})
|
|
afterAll(() => next.destroy())
|
|
|
|
it('should redirect route when requesting it directly', async () => {
|
|
const res = await fetchViaHTTP(
|
|
next.url,
|
|
'/a/',
|
|
{},
|
|
{
|
|
redirect: 'manual',
|
|
}
|
|
)
|
|
expect(res.status).toBe(308)
|
|
expect(res.headers.get('location')).toBe(next.url + '/a')
|
|
})
|
|
|
|
it('should render link', async () => {
|
|
const html = await renderViaHTTP(next.url, '/')
|
|
const $ = cheerio.load(html)
|
|
expect($('#to-a-trailing-slash').attr('href')).toBe('/a')
|
|
})
|
|
|
|
it('should redirect route when requesting it directly by browser', async () => {
|
|
const browser = await webdriver(next.url, '/a')
|
|
expect(await browser.waitForElementByCss('#a-page').text()).toBe('A page')
|
|
})
|
|
|
|
it('should redirect route when clicking link', async () => {
|
|
const browser = await webdriver(next.url, '/')
|
|
await browser
|
|
.elementByCss('#to-a-trailing-slash')
|
|
.click()
|
|
.waitForElementByCss('#a-page')
|
|
expect(await browser.waitForElementByCss('#a-page').text()).toBe('A page')
|
|
})
|
|
})
|