Skip to content

Commit e773c31

Browse files
committed
Turbopack: Change eager import to lazy import for loader_tree
1 parent c4738f7 commit e773c31

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

crates/next-core/src/base_loader_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl BaseLoaderTreeBuilder {
9999
self.imports.push(
100100
formatdoc!(
101101
r#"
102-
import * as {} from "MODULE_{}";
102+
const {} = () => import("MODULE_{}");
103103
"#,
104104
identifier,
105105
i
@@ -118,7 +118,7 @@ impl BaseLoaderTreeBuilder {
118118
let module_path = module.ident().path().to_string().await?;
119119

120120
Ok(format!(
121-
"[() => {identifier}, {path}]",
121+
"[{identifier}, {path}]",
122122
path = StringifyJs(&module_path),
123123
))
124124
}

packages/next/src/server/next-server.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,6 @@ export default class NextNodeServer extends BaseServer<
387387
// otherwise if the fetch is patched by user code, we will be patching it
388388
// too late and there won't be any caching behaviors
389389
ComponentMod.patchFetch()
390-
391-
const webpackRequire = ComponentMod.__next_app__.require
392-
if (webpackRequire?.m) {
393-
for (const id of Object.keys(webpackRequire.m)) {
394-
await webpackRequire(id)
395-
}
396-
}
397390
} catch (_err) {
398391
// Intentionally ignored because this is a preload step.
399392
}

test/development/acceptance-app/hydration-error.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ describe('Error overlay for hydration errors in App router', () => {
228228
<SegmentTrieNode>
229229
<script>
230230
<script>
231-
<script>
232231
<ClientSegmentRoot Component={function Root} slots={{...}} params={{}}>
233232
<Root params={Promise}>
234233
<html

test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,7 @@ describe('Cache Components Errors', () => {
27732773
"Error: "use cache: private" must not be used within \`unstable_cache()\`.
27742774
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
27752775
at a (<next-dist-dir>)
2776+
at b (<next-dist-dir>)
27762777
19 | }
27772778
20 |
27782779
> 21 | const getCachedData = unstable_cache(async () => {
@@ -2928,6 +2929,7 @@ describe('Cache Components Errors', () => {
29282929
"Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
29292930
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
29302931
at a (<next-dist-dir>)
2932+
at b (<next-dist-dir>)
29312933
13 | }
29322934
14 |
29332935
> 15 | async function Private() {
@@ -2937,7 +2939,8 @@ describe('Cache Components Errors', () => {
29372939
18 | return <p>Private</p>
29382940
Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
29392941
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
2940-
at b (<next-dist-dir>)
2942+
at c (<next-dist-dir>)
2943+
at d (<next-dist-dir>)
29412944
13 | }
29422945
14 |
29432946
> 15 | async function Private() {

test/e2e/app-dir/server-source-maps/server-source-maps.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ describe('app-dir - server source maps', () => {
485485
"{module evaluation} app/module-evaluation/page.js (1:1)",
486486
"{module evaluation} app/module-evaluation/page.js (6:1)",
487487
"<FIXME-next-dist-dir>",
488+
"Function.all <anonymous>",
489+
"Function.all <anonymous>",
488490
"Page <anonymous>",
489491
],
490492
}
@@ -515,9 +517,8 @@ describe('app-dir - server source maps', () => {
515517
expect(normalizeCliOutput(next.cliOutput)).toContain(
516518
'' +
517519
'\nError: module-evaluation' +
518-
'\n at __TURBOPACK__module__evaluation__ (bundler:///app/module-evaluation/module.js:1:22)' +
519520
// TODO(veil): Turbopack internals. Feel free to update. Tracked in https://linear.app/vercel/issue/NEXT-4362
520-
'\n at Object.<anonymous>'
521+
'\n at __TURBOPACK__module__evaluation__ (bundler:///app/module-evaluation/module.js:1:22)'
521522
)
522523
expect(normalizeCliOutput(next.cliOutput)).toContain(
523524
'' +

0 commit comments

Comments
 (0)