You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref(nextjs): Make build-time value injection turbopack compatible (#14081)
Ref: #8105
To inject build-time variables, in addition to doing so via a custom
loader, we will be injecting them via the `env` option.
Caveat: We are currently using the Next.js build ID as a release name.
This build id is passed to the `webpack` option. Since the `webpack`
option doesn't exist for turbopack we don't have access to the build ID.
For now we will simply not inject a release name, which may be better
anyhow since turbopack is currently only stable for dev.
Copy file name to clipboardExpand all lines: packages/nextjs/src/config/webpack.ts
+6-4
Original file line number
Diff line number
Diff line change
@@ -562,6 +562,8 @@ function setUpModuleRules(newConfig: WebpackConfigObject): WebpackConfigObjectWi
562
562
/**
563
563
* Adds loaders to inject values on the global object based on user configuration.
564
564
*/
565
+
// TODO(v9): Remove this loader and replace it with a nextConfig.env (https://web.archive.org/web/20240917153554/https://nextjs.org/docs/app/api-reference/next-config-js/env) or define based (https://github.com/vercel/next.js/discussions/71476) approach.
566
+
// In order to remove this loader though we need to make sure the minimum supported Next.js version includes this PR (https://github.com/vercel/next.js/pull/61194), otherwise the nextConfig.env based approach will not work, as our SDK code is not processed by Next.js.
565
567
functionaddValueInjectionLoader(
566
568
newConfig: WebpackConfigObjectWithModuleRules,
567
569
userNextConfig: NextConfigObject,
@@ -572,7 +574,7 @@ function addValueInjectionLoader(
572
574
573
575
constisomorphicValues={
574
576
// `rewritesTunnel` set by the user in Next.js config
// Add the `clientTraceMetadata` experimental option based on Next.js version. The option got introduced in Next.js version 15.0.0 (actually 14.3.0-canary.64).
@@ -253,6 +256,43 @@ function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: s
253
256
};
254
257
}
255
258
259
+
// TODO(v9): Inject the release into all the bundles. This is breaking because grabbing the build ID if the user provides
260
+
// it in `generateBuildId` (https://nextjs.org/docs/app/api-reference/next-config-js/generateBuildId) is async but we do
261
+
// not turn the next config function in the type it was passed.
0 commit comments