-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29587 from storybookjs/yann/next-15-support
Next.js: Add support for Next 15
- Loading branch information
Showing
45 changed files
with
643 additions
and
265 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import type { Configuration as WebpackConfig } from 'webpack'; | ||
|
||
import { configureCompatibilityAliases } from '../compatibility/compatibility-map'; | ||
import { configureNextExportMocks } from '../export-mocks/webpack'; | ||
|
||
export const configureAliases = (baseConfig: WebpackConfig): void => { | ||
configureNextExportMocks(baseConfig); | ||
configureCompatibilityAliases(baseConfig); | ||
|
||
baseConfig.resolve = { | ||
...(baseConfig.resolve ?? {}), | ||
alias: { | ||
...(baseConfig.resolve?.alias ?? {}), | ||
'@opentelemetry/api': 'next/dist/compiled/@opentelemetry/api', | ||
}, | ||
}; | ||
|
||
// remove warnings regarding compatibility paths | ||
baseConfig.ignoreWarnings = [ | ||
...(baseConfig.ignoreWarnings ?? []), | ||
(warning) => | ||
warning.message.includes("export 'draftMode'") && | ||
warning.message.includes('next/dist/server/request/headers'), | ||
]; | ||
}; |
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
2 changes: 2 additions & 0 deletions
2
code/frameworks/nextjs/src/compatibility/draft-mode.compat.ts
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,2 @@ | ||
// Compatibility for Next 14 | ||
export { draftMode } from 'next/dist/client/components/headers'; |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { fn } from '@storybook/test'; | ||
|
||
import * as originalHeaders from 'next/dist/client/components/headers'; | ||
// This export won't exist in Next.js 14 but it's safe because we ignore it in Webpack when applicable | ||
import { draftMode as originalDraftMode } from 'next/dist/server/request/draft-mode'; | ||
import * as headers from 'next/dist/server/request/headers'; | ||
|
||
// re-exports of the actual module | ||
export * from 'next/dist/client/components/headers'; | ||
export * from 'next/dist/server/request/headers'; | ||
|
||
// mock utilities/overrides (as of Next v14.2.0) | ||
export { headers } from './headers'; | ||
export { cookies } from './cookies'; | ||
|
||
// passthrough mocks - keep original implementation but allow for spying | ||
const draftMode = fn(originalHeaders.draftMode).mockName('draftMode'); | ||
const draftMode = fn(originalDraftMode ?? (headers as any).draftMode).mockName('draftMode'); | ||
export { draftMode }; |
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
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
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
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
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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Font from './Font'; | ||
|
||
export default { | ||
component: Font, | ||
} as Meta<typeof Font>; | ||
|
||
type Story = StoryObj<typeof Font>; | ||
|
||
export const WithClassName: Story = { | ||
args: { | ||
variant: 'className', | ||
}, | ||
}; | ||
|
||
export const WithStyle: Story = { | ||
args: { | ||
variant: 'style', | ||
}, | ||
}; | ||
|
||
export const WithVariable: Story = { | ||
args: { | ||
variant: 'variable', | ||
}, | ||
}; |
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
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
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
Oops, something went wrong.