Skip to content

Commit

Permalink
Update newNextLinkBehavior logic to match Next's
Browse files Browse the repository at this point in the history
  • Loading branch information
kylegach committed Nov 18, 2022
1 parent 58090fe commit 223f969
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion code/frameworks/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ const setupRuntimeConfig = (baseConfig: WebpackConfig, nextConfig: NextConfig):
}),
};

if (semver.gte(version, '13.0.0') || nextConfig.experimental?.newNextLinkBehavior) {
/**
* In Next12.2, the `newNextLinkBehavior` option was introduced, defaulted to
* falsy in the Next app (`undefined` in the config itself), and `next/link`
* was engineered to opt *in* to it
*
* In Next13, the `newNextLinkBehavior` option now defaults to truthy (still
* `undefined` in the config), and `next/link` was engineered to opt *out*
* of it
*/
const newNextLinkBehavior = nextConfig.experimental?.newNextLinkBehavior;
if (
(semver.gte(version, '13.0.0') && newNextLinkBehavior !== false) ||
(semver.gte(version, '12.2.0') && newNextLinkBehavior)
) {
definePluginConfig['process.env.__NEXT_NEW_LINK_BEHAVIOR'] = true;
}

Expand Down

0 comments on commit 223f969

Please sign in to comment.