Skip to content

Commit d439da6

Browse files
authored
Skip barrel optimization tests in Turbopack (vercel#61253)
## What? Barrel optimization will be added after Turbopack is stable. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-2266
1 parent ecef83a commit d439da6

File tree

1 file changed

+164
-159
lines changed

1 file changed

+164
-159
lines changed
Lines changed: 164 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,171 @@
11
import { join } from 'path'
22
import { createNextDescribe } from 'e2e-utils'
33
import { hasRedbox, shouldRunTurboDevTest } from 'next-test-utils'
4-
5-
createNextDescribe(
6-
'optimizePackageImports',
7-
{
8-
env: {
9-
NEXT_TEST_MODE: '1',
10-
},
11-
files: join(__dirname, 'fixture'),
12-
packageJson: {
13-
scripts: {
14-
setup: `cp -r ./node_modules_bak/* ./node_modules`,
15-
build: `yarn setup && next build`,
16-
dev: `yarn setup && next ${
17-
shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'
18-
}`,
19-
start: 'next start',
4+
// Skipped in Turbopack, will be added later.
5+
;(process.env.TURBOPACK ? describe.skip : describe)(
6+
'Skipped in Turbopack',
7+
() => {
8+
createNextDescribe(
9+
'optimizePackageImports',
10+
{
11+
env: {
12+
NEXT_TEST_MODE: '1',
13+
},
14+
files: join(__dirname, 'fixture'),
15+
packageJson: {
16+
scripts: {
17+
setup: `cp -r ./node_modules_bak/* ./node_modules`,
18+
build: `yarn setup && next build`,
19+
dev: `yarn setup && next ${
20+
shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'
21+
}`,
22+
start: 'next start',
23+
},
24+
},
25+
installCommand: 'yarn',
26+
startCommand: (global as any).isNextDev ? 'yarn dev' : 'yarn start',
27+
buildCommand: 'yarn build',
28+
dependencies: {
29+
'lucide-react': '0.264.0',
30+
'@headlessui/react': '1.7.17',
31+
'@heroicons/react': '2.0.18',
32+
'@visx/visx': '3.3.0',
33+
'recursive-barrel': '1.0.0',
34+
'@mui/material': '5.15.4',
35+
'@emotion/styled': '11.11.0',
36+
'@emotion/react': '11.11.1',
37+
},
2038
},
21-
},
22-
installCommand: 'yarn',
23-
startCommand: (global as any).isNextDev ? 'yarn dev' : 'yarn start',
24-
buildCommand: 'yarn build',
25-
dependencies: {
26-
'lucide-react': '0.264.0',
27-
'@headlessui/react': '1.7.17',
28-
'@heroicons/react': '2.0.18',
29-
'@visx/visx': '3.3.0',
30-
'recursive-barrel': '1.0.0',
31-
'@mui/material': '5.15.4',
32-
'@emotion/styled': '11.11.0',
33-
'@emotion/react': '11.11.1',
34-
},
35-
},
36-
({ next }) => {
37-
it('app - should render the icons correctly without creating all the modules', async () => {
38-
let logs = ''
39-
next.on('stdout', (log) => {
40-
logs += log
41-
})
42-
43-
const html = await next.render('/')
44-
45-
// Ensure the icons are rendered
46-
expect(html).toContain('<svg xmlns="http://www.w3.org/2000/svg"')
47-
48-
const modules = [
49-
...logs.matchAll(
50-
/Compiled (\/[\w-]*)*\s*in \d+(\.\d+)?(s|ms) \((\d+) modules\)/g
51-
),
52-
]
53-
54-
expect(modules.length).toBeGreaterThanOrEqual(1)
55-
for (const [, , , , moduleCount] of modules) {
56-
// Ensure that the number of modules is less than 1000 - otherwise we're
57-
// importing the entire library.
58-
expect(parseInt(moduleCount)).toBeLessThan(1000)
59-
}
60-
})
61-
62-
it('pages - should render the icons correctly without creating all the modules', async () => {
63-
let logs = ''
64-
next.on('stdout', (log) => {
65-
logs += log
66-
})
67-
68-
const html = await next.render('/pages-route')
69-
70-
// Ensure the icons are rendered
71-
expect(html).toContain('<svg xmlns="http://www.w3.org/2000/svg"')
72-
73-
const modules = [
74-
...logs.matchAll(
75-
/Compiled (\/[\w-]+)*\s*in \d+(\.\d+)?(s|ms) \((\d+) modules\)/g
76-
),
77-
]
78-
79-
expect(modules.length).toBeGreaterThanOrEqual(1)
80-
for (const [, , , , moduleCount] of modules) {
81-
// Ensure that the number of modules is less than 1000 - otherwise we're
82-
// importing the entire library.
83-
expect(parseInt(moduleCount)).toBeLessThan(1000)
84-
}
85-
})
86-
87-
it('app - should optimize recursive wildcard export mapping', async () => {
88-
let logs = ''
89-
next.on('stdout', (log) => {
90-
logs += log
91-
})
92-
93-
await next.render('/recursive-barrel-app')
94-
95-
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
96-
97-
expect(modules.length).toBeGreaterThanOrEqual(1)
98-
for (const [, moduleCount] of modules) {
99-
// Ensure that the number of modules is less than 1000 - otherwise we're
100-
// importing the entire library.
101-
expect(parseInt(moduleCount)).toBeLessThan(1000)
39+
({ next }) => {
40+
it('app - should render the icons correctly without creating all the modules', async () => {
41+
let logs = ''
42+
next.on('stdout', (log) => {
43+
logs += log
44+
})
45+
46+
const html = await next.render('/')
47+
48+
// Ensure the icons are rendered
49+
expect(html).toContain('<svg xmlns="http://www.w3.org/2000/svg"')
50+
51+
const modules = [
52+
...logs.matchAll(
53+
/Compiled (\/[\w-]*)*\s*in \d+(\.\d+)?(s|ms) \((\d+) modules\)/g
54+
),
55+
]
56+
57+
expect(modules.length).toBeGreaterThanOrEqual(1)
58+
for (const [, , , , moduleCount] of modules) {
59+
// Ensure that the number of modules is less than 1000 - otherwise we're
60+
// importing the entire library.
61+
expect(parseInt(moduleCount)).toBeLessThan(1000)
62+
}
63+
})
64+
65+
it('pages - should render the icons correctly without creating all the modules', async () => {
66+
let logs = ''
67+
next.on('stdout', (log) => {
68+
logs += log
69+
})
70+
71+
const html = await next.render('/pages-route')
72+
73+
// Ensure the icons are rendered
74+
expect(html).toContain('<svg xmlns="http://www.w3.org/2000/svg"')
75+
76+
const modules = [
77+
...logs.matchAll(
78+
/Compiled (\/[\w-]+)*\s*in \d+(\.\d+)?(s|ms) \((\d+) modules\)/g
79+
),
80+
]
81+
82+
expect(modules.length).toBeGreaterThanOrEqual(1)
83+
for (const [, , , , moduleCount] of modules) {
84+
// Ensure that the number of modules is less than 1000 - otherwise we're
85+
// importing the entire library.
86+
expect(parseInt(moduleCount)).toBeLessThan(1000)
87+
}
88+
})
89+
90+
it('app - should optimize recursive wildcard export mapping', async () => {
91+
let logs = ''
92+
next.on('stdout', (log) => {
93+
logs += log
94+
})
95+
96+
await next.render('/recursive-barrel-app')
97+
98+
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
99+
100+
expect(modules.length).toBeGreaterThanOrEqual(1)
101+
for (const [, moduleCount] of modules) {
102+
// Ensure that the number of modules is less than 1000 - otherwise we're
103+
// importing the entire library.
104+
expect(parseInt(moduleCount)).toBeLessThan(1000)
105+
}
106+
})
107+
108+
it('pages - should optimize recursive wildcard export mapping', async () => {
109+
let logs = ''
110+
next.on('stdout', (log) => {
111+
logs += log
112+
})
113+
114+
await next.render('/recursive-barrel')
115+
116+
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
117+
118+
expect(modules.length).toBeGreaterThanOrEqual(1)
119+
for (const [, moduleCount] of modules) {
120+
// Ensure that the number of modules is less than 1000 - otherwise we're
121+
// importing the entire library.
122+
expect(parseInt(moduleCount)).toBeLessThan(1000)
123+
}
124+
})
125+
126+
it('should handle recursive wildcard exports', async () => {
127+
const html = await next.render('/recursive')
128+
expect(html).toContain('<h1>42</h1>')
129+
})
130+
131+
it('should support visx', async () => {
132+
const html = await next.render('/visx')
133+
expect(html).toContain('<linearGradient')
134+
})
135+
136+
it('should support MUI', async () => {
137+
let logs = ''
138+
next.on('stdout', (log) => {
139+
logs += log
140+
})
141+
142+
// Ensure that MUI is working
143+
const $ = await next.render$('/mui')
144+
expect(await $('#button').text()).toContain('button')
145+
expect(await $('#typography').text()).toContain('typography')
146+
147+
const browser = await next.browser('/mui')
148+
expect(await hasRedbox(browser)).toBe(false)
149+
150+
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
151+
expect(modules.length).toBeGreaterThanOrEqual(1)
152+
for (const [, moduleCount] of modules) {
153+
// Ensure that the number of modules is less than 1500 - otherwise we're
154+
// importing the entire library.
155+
expect(parseInt(moduleCount)).toBeLessThan(1500)
156+
}
157+
})
158+
159+
it('should not break "use client" directive in optimized packages', async () => {
160+
const html = await next.render('/client')
161+
expect(html).toContain('this is a client component')
162+
})
163+
164+
it('should support "use client" directive in barrel file', async () => {
165+
const html = await next.render('/client-boundary')
166+
expect(html).toContain('<button>0</button>')
167+
})
102168
}
103-
})
104-
105-
it('pages - should optimize recursive wildcard export mapping', async () => {
106-
let logs = ''
107-
next.on('stdout', (log) => {
108-
logs += log
109-
})
110-
111-
await next.render('/recursive-barrel')
112-
113-
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
114-
115-
expect(modules.length).toBeGreaterThanOrEqual(1)
116-
for (const [, moduleCount] of modules) {
117-
// Ensure that the number of modules is less than 1000 - otherwise we're
118-
// importing the entire library.
119-
expect(parseInt(moduleCount)).toBeLessThan(1000)
120-
}
121-
})
122-
123-
it('should handle recursive wildcard exports', async () => {
124-
const html = await next.render('/recursive')
125-
expect(html).toContain('<h1>42</h1>')
126-
})
127-
128-
it('should support visx', async () => {
129-
const html = await next.render('/visx')
130-
expect(html).toContain('<linearGradient')
131-
})
132-
133-
it('should support MUI', async () => {
134-
let logs = ''
135-
next.on('stdout', (log) => {
136-
logs += log
137-
})
138-
139-
// Ensure that MUI is working
140-
const $ = await next.render$('/mui')
141-
expect(await $('#button').text()).toContain('button')
142-
expect(await $('#typography').text()).toContain('typography')
143-
144-
const browser = await next.browser('/mui')
145-
expect(await hasRedbox(browser)).toBe(false)
146-
147-
const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
148-
expect(modules.length).toBeGreaterThanOrEqual(1)
149-
for (const [, moduleCount] of modules) {
150-
// Ensure that the number of modules is less than 1500 - otherwise we're
151-
// importing the entire library.
152-
expect(parseInt(moduleCount)).toBeLessThan(1500)
153-
}
154-
})
155-
156-
it('should not break "use client" directive in optimized packages', async () => {
157-
const html = await next.render('/client')
158-
expect(html).toContain('this is a client component')
159-
})
160-
161-
it('should support "use client" directive in barrel file', async () => {
162-
const html = await next.render('/client-boundary')
163-
expect(html).toContain('<button>0</button>')
164-
})
169+
)
165170
}
166171
)

0 commit comments

Comments
 (0)