mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Follow up of #61986 where we didn't handle the subpath externals very well, found by @sokra Closes NEXT-2517
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import path from 'path'
|
|
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
createNextDescribe(
|
|
'app-dir - server components externals',
|
|
{
|
|
files: __dirname,
|
|
},
|
|
({ next, isTurbopack }) => {
|
|
it('should have externals for those in config.experimental.serverComponentsExternalPackages', async () => {
|
|
const $ = await next.render$('/')
|
|
|
|
const text = $('#directory').text()
|
|
const subpath = $('#subdirectory').text()
|
|
expect(text).toBe(
|
|
path.join(next.testDir, 'node_modules', 'external-package')
|
|
)
|
|
expect(subpath).toBe(
|
|
path.join(next.testDir, 'node_modules', 'external-package', 'subpath')
|
|
)
|
|
})
|
|
|
|
it('uses externals for predefined list in server-external-packages.json', async () => {
|
|
const $ = await next.render$('/predefined')
|
|
|
|
const text = $('#directory').text()
|
|
expect(text).toBe(path.join(next.testDir, 'node_modules', 'sqlite3'))
|
|
})
|
|
|
|
// Inspect webpack server bundles
|
|
if (!isTurbopack) {
|
|
it('should externalize serverComponentsExternalPackages for server rendering layer', async () => {
|
|
await next.fetch('/client')
|
|
const ssrBundle = await next.readFile('.next/server/app/client/page.js')
|
|
expect(ssrBundle).not.toContain('external-package-mark:index')
|
|
expect(ssrBundle).not.toContain('external-package-mark:subpath')
|
|
|
|
await next.fetch('/')
|
|
const rscBundle = await next.readFile('.next/server/app/page.js')
|
|
expect(rscBundle).not.toContain('external-package-mark:index')
|
|
expect(rscBundle).not.toContain('external-package-mark:subpath')
|
|
})
|
|
}
|
|
}
|
|
)
|