Skip to content

Commit 7116058

Browse files
committed
Get rid of weird replacement in Webpack
1 parent 9cbe274 commit 7116058

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/next/src/build/define-env.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ export function getDefineEnv({
337337
!isTurbopack || (config.experimental.turbopackPersistentCaching ?? false),
338338
'process.env.__NEXT_OPTIMIZE_ROUTER_SCROLL':
339339
config.experimental.optimizeRouterScrolling ?? false,
340-
__next__clear_chunk_cache__: JSON.stringify(null),
341340
}
342341

343342
const userDefines = config.compiler?.define ?? {}

packages/next/src/server/app-render/entry-base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ if (process.env.NODE_ENV === 'development') {
6161
// For hot-reloader
6262
declare global {
6363
var __next__clear_chunk_cache__: (() => void) | null | undefined
64+
var __turbopack_clear_chunk_cache__: () => void | null | undefined
6465
}
6566
// hot-reloader modules are not bundled so we need to inject `__next__clear_chunk_cache__`
6667
// into globalThis from this file which is bundled.
67-
globalThis.__next__clear_chunk_cache__ = __next__clear_chunk_cache__
68+
if (process.env.TURBOPACK) {
69+
globalThis.__next__clear_chunk_cache__ = __turbopack_clear_chunk_cache__
70+
} else {
71+
// Webpack does not have chunks on the server
72+
globalThis.__next__clear_chunk_cache__ = null
73+
}
6874

6975
// patchFetch makes use of APIs such as `React.unstable_postpone` which are only available
7076
// in the experimental channel of React, so export it from here so that it comes from the bundled runtime

turbopack/crates/turbopack-ecmascript/src/runtime_functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ pub const TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS: [(&str, &TurbopackRuntimeFunctio
111111
("__turbopack_refresh__", TURBOPACK_REFRESH),
112112
("__turbopack_require_stub__", TURBOPACK_REQUIRE_STUB),
113113
("__turbopack_require_real__", TURBOPACK_REQUIRE_REAL),
114-
("__next__clear_chunk_cache__", TURBOPACK_CLEAR_CHUNK_CACHE),
114+
("__turbopack_clear_chunk_cache__", TURBOPACK_CLEAR_CHUNK_CACHE),
115115
];

0 commit comments

Comments
 (0)