Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: latest next version bug #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugin/checkNextVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const parseVersion = (version?: string) =>
?.map(Number)

type TMinorPatch = `.${number}`
type TVersion = `${number}` | `${number}${TMinorPatch}` | `${number}${TMinorPatch}${TMinorPatch}`
type TVersion = `${number}` | `${number}${TMinorPatch}` | `${number}${TMinorPatch}${TMinorPatch}` | 'latest'

export const checkNextVersion = (
/** Ex: '>=13.3.1', '!=12.2.4' */
Expand Down
3 changes: 2 additions & 1 deletion src/plugin/withTranslateRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const withTranslateRoutes = (userNextConfig: NextConfigWithNTR): NextConf
}

const hasOldRouterContextPath = checkNextVersion('<13.5.0')
const isLatestNextVersion = checkNextVersion('=latest')

return {
...nextConfig,
Expand All @@ -75,7 +76,7 @@ export const withTranslateRoutes = (userNextConfig: NextConfigWithNTR): NextConf
if (!config.plugins) {
config.plugins = []
}
const ROUTER_CONTEXT_PATH = hasOldRouterContextPath
const ROUTER_CONTEXT_PATH = (hasOldRouterContextPath && !isLatestNextVersion)
? "'next/dist/shared/lib/router-context'"
: "'next/dist/shared/lib/router-context.shared-runtime'"
config.plugins.push(new DefinePlugin({ ROUTER_CONTEXT_PATH }))
Expand Down