Skip to content

Commit

Permalink
Merge branch 'canary' into test/separate-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 26, 2024
2 parents 562059e + 14e93ed commit 819c112
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export default function ExampleClientComponent() {
In addition, the new `useRouter` hook has the following changes:
- `isFallback` has been removed because `fallback` has [been replaced](#replacing-fallback).
- The `locale`, `locales`, `defaultLocales`, `domainLocales` values have been removed because built-in i18n Next.js features are no longer necessary in the `app` directory. [Learn more about i18n](/docs/pages/building-your-application/routing/internationalization).
- The `locale`, `locales`, `defaultLocales`, `domainLocales` values have been removed because built-in i18n Next.js features are no longer necessary in the `app` directory. [Learn more about i18n](/docs/app/building-your-application/routing/internationalization).
- `basePath` has been removed. The alternative will not be part of `useRouter`. It has not yet been implemented.
- `asPath` has been removed because the concept of `as` has been removed from the new router.
- `isReady` has been removed because it is no longer necessary. During [static rendering](/docs/app/building-your-application/rendering/server-components#static-rendering-default), any component that uses the [`useSearchParams()`](/docs/app/api-reference/functions/use-search-params) hook will skip the prerendering step and instead be rendered on the client at runtime.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { join } from 'path'
import { createNextDescribe } from 'e2e-utils'
import { hasRedbox } from 'next-test-utils'
// Skipped in Turbopack, will be added later.
;(process.env.TURBOPACK ? describe.skip : describe)(
'Skipped in Turbopack',
() => {
createNextDescribe(
'optimizePackageImports - mui',
{
env: {
NEXT_TEST_MODE: '1',
},
files: join(__dirname, 'fixture'),

dependencies: {
'@mui/material': '5.15.4',
'@emotion/react': '11.11.1',
'@emotion/styled': '11.11.0',
},
},
({ next }) => {
it('should support MUI', async () => {
let logs = ''
next.on('stdout', (log) => {
logs += log
})

// Ensure that MUI is working
const $ = await next.render$('/mui')
expect(await $('#button').text()).toContain('button')
expect(await $('#typography').text()).toContain('typography')

const browser = await next.browser('/mui')
expect(await hasRedbox(browser)).toBe(false)

const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
expect(modules.length).toBeGreaterThanOrEqual(1)
for (const [, moduleCount] of modules) {
// Ensure that the number of modules is less than 1500 - otherwise we're
// importing the entire library.
expect(parseInt(moduleCount)).toBeLessThan(1500)
}
})
}
)
}
)
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
import { join } from 'path'
import { createNextDescribe } from 'e2e-utils'
import { hasRedbox, shouldRunTurboDevTest } from 'next-test-utils'
// Skipped in Turbopack, will be added later.
;(process.env.TURBOPACK ? describe.skip : describe)(
'Skipped in Turbopack',
() => {
createNextDescribe(
'optimizePackageImports',
'optimizePackageImports - basic',
{
env: {
NEXT_TEST_MODE: '1',
},
files: join(__dirname, 'fixture'),
packageJson: {
scripts: {
build: `next build`,
dev: `next ${shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'}`,
start: 'next start',
},
},
installCommand: 'pnpm i',
startCommand: (global as any).isNextDev
? 'pnpm run dev'
: 'pnpm run start',
buildCommand: 'pnpm run build',
dependencies: {
'lucide-react': '0.264.0',
'@headlessui/react': '1.7.17',
'@heroicons/react': '2.0.18',
'@visx/visx': '3.3.0',
'recursive-barrel': '1.0.0',
'@mui/material': '5.15.4',
'@emotion/styled': '11.11.0',
'@emotion/react': '11.11.1',
},
},
({ next }) => {
Expand Down Expand Up @@ -132,29 +116,6 @@ import { hasRedbox, shouldRunTurboDevTest } from 'next-test-utils'
expect(html).toContain('<linearGradient')
})

it('should support MUI', async () => {
let logs = ''
next.on('stdout', (log) => {
logs += log
})

// Ensure that MUI is working
const $ = await next.render$('/mui')
expect(await $('#button').text()).toContain('button')
expect(await $('#typography').text()).toContain('typography')

const browser = await next.browser('/mui')
expect(await hasRedbox(browser)).toBe(false)

const modules = [...logs.matchAll(/\((\d+) modules\)/g)]
expect(modules.length).toBeGreaterThanOrEqual(1)
for (const [, moduleCount] of modules) {
// Ensure that the number of modules is less than 1500 - otherwise we're
// importing the entire library.
expect(parseInt(moduleCount)).toBeLessThan(1500)
}
})

it('should not break "use client" directive in optimized packages', async () => {
const html = await next.render('/client')
expect(html).toContain('this is a client component')
Expand Down

0 comments on commit 819c112

Please sign in to comment.