-
-
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 #24239 from storybookjs/norbert/fix-nextjs-13-5-co…
…mpatibility NextJS: Add compatibility with nextjs `13.5`
- Loading branch information
Showing
4 changed files
with
52 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Configuration as WebpackConfig } from 'webpack'; | ||
import semver from 'semver'; | ||
import { getNextjsVersion, addScopedAlias } from './utils'; | ||
|
||
const mapping: Record<string, Record<string, string>> = { | ||
'<11.1.0': { | ||
'next/dist/next-server/lib/router-context': 'next/dist/next-server/lib/router-context', | ||
}, | ||
'>=11.1.0': { | ||
'next/dist/shared/lib/router-context': 'next/dist/shared/lib/router-context', | ||
}, | ||
'>=13.5.0': { | ||
'next/dist/shared/lib/router-context': 'next/dist/shared/lib/router-context.shared-runtime', | ||
'next/dist/shared/lib/head-manager-context': | ||
'next/dist/shared/lib/head-manager-context.shared-runtime', | ||
'next/dist/shared/lib/app-router-context': | ||
'next/dist/shared/lib/app-router-context.shared-runtime', | ||
'next/dist/shared/lib/hooks-client-context': | ||
'next/dist/shared/lib/hooks-client-context.shared-runtime', | ||
}, | ||
}; | ||
|
||
export const configureAliasing = (baseConfig: WebpackConfig): void => { | ||
const version = getNextjsVersion(); | ||
const result: Record<string, string> = {}; | ||
|
||
Object.keys(mapping).forEach((key) => { | ||
if (semver.intersects(version, key)) { | ||
Object.assign(result, mapping[key]); | ||
} | ||
}); | ||
|
||
Object.entries(result).forEach(([name, alias]) => { | ||
addScopedAlias(baseConfig, name, alias); | ||
}); | ||
}; |
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 was deleted.
Oops, something went wrong.