-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LichuAcu
committed
Aug 20, 2024
1 parent
1776af0
commit 1495563
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
test/integration/module-id-strategies/module-with-long-name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
foo: 'a very long module name!', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
bundlePagesRouterDependencies: true, | ||
serverExternalPackages: ['opted-out-external-package'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { foo } from '../module-with-long-name' | ||
|
||
export default function Index() { | ||
return <div>{foo}</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* eslint-env jest */ | ||
|
||
import fs from 'fs-extra' | ||
import { join } from 'path' | ||
import { | ||
killApp, | ||
findPort, | ||
launchApp, | ||
nextBuild, | ||
renderViaHTTP, | ||
} from 'next-test-utils' | ||
|
||
const appDir = join(__dirname, '../') | ||
|
||
let appPort | ||
let app | ||
|
||
describe('minified module ids', () => { | ||
;(!process.env.TURBOPACK || process.env.TURBOPACK_DEV | ||
? describe.skip | ||
: describe)('production mode', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir, []) | ||
}) | ||
|
||
it('should have no long module ids', async () => { | ||
const ssrPath = join(appDir, '.next/server/chunks/ssr') | ||
const pageBundleBasenames = (await fs.readdir(ssrPath)).filter((p) => | ||
p.match(/\.js$/) | ||
) | ||
expect(pageBundleBasenames).not.toBeEmpty() | ||
let allBundles = '' | ||
for (const basename of pageBundleBasenames) { | ||
const output = await fs.readFile(join(ssrPath, basename), 'utf8') | ||
allBundles += output | ||
} | ||
|
||
expect(allBundles).not.toContain('module-with-long-name') | ||
}) | ||
}) | ||
;(!process.env.TURBOPACK || process.env.TURBOPACK_BUILD | ||
? describe.skip | ||
: describe)('development mode', () => { | ||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
it('should have long module ids', async () => { | ||
await renderViaHTTP(appPort, '/') | ||
|
||
const ssrPath = join(appDir, '.next/server/chunks/ssr') | ||
const pageBundleBasenames = (await fs.readdir(ssrPath)).filter((p) => | ||
p.match(/\.js$/) | ||
) | ||
expect(pageBundleBasenames).not.toBeEmpty() | ||
let allBundles = '' | ||
for (const basename of pageBundleBasenames) { | ||
const output = await fs.readFile(join(ssrPath, basename), 'utf8') | ||
allBundles += output | ||
} | ||
|
||
expect(allBundles).toContain('module-with-long-name') | ||
}) | ||
}) | ||
}) |