Skip to content
Merged
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
4 changes: 2 additions & 2 deletions crates/next-core/src/base_loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl BaseLoaderTreeBuilder {
self.imports.push(
formatdoc!(
r#"
import * as {} from "MODULE_{}";
const {} = () => require("MODULE_{}");
"#,
identifier,
i
Expand All @@ -118,7 +118,7 @@ impl BaseLoaderTreeBuilder {
let module_path = module.ident().path().to_string().await?;

Ok(format!(
"[() => {identifier}, {path}]",
"[{identifier}, {path}]",
path = StringifyJs(&module_path),
))
}
Expand Down
7 changes: 0 additions & 7 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,6 @@ export default class NextNodeServer extends BaseServer<
// otherwise if the fetch is patched by user code, we will be patching it
// too late and there won't be any caching behaviors
ComponentMod.patchFetch()

const webpackRequire = ComponentMod.__next_app__.require
if (webpackRequire?.m) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses webpack internals and it's unclear to me why it's here in the first place. It breaks with these changes for Turbopack because the modules get too eagerly executed, before a global that is required to run is available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this is also important to make sure Next.js behaves roughly the same in all environments

for (const id of Object.keys(webpackRequire.m)) {
await webpackRequire(id)
}
}
} catch (_err) {
// Intentionally ignored because this is a preload step.
}
Expand Down
1 change: 0 additions & 1 deletion test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ describe('Error overlay for hydration errors in App router', () => {
<SegmentTrieNode>
<script>
<script>
<script>
<ClientSegmentRoot Component={function Root} slots={{...}} params={{}}>
<Root params={Promise}>
<html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,6 @@ describe('Cache Components Errors', () => {
"stack": [
"{module evaluation} app/use-cache-private-in-unstable-cache/page.tsx (21:38)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
Expand Down Expand Up @@ -2754,7 +2753,6 @@ describe('Cache Components Errors', () => {
"Error: "use cache: private" must not be used within \`unstable_cache()\`.
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
at a (<next-dist-dir>)
at b (<next-dist-dir>)
19 | }
20 |
> 21 | const getCachedData = unstable_cache(async () => {
Expand All @@ -2772,7 +2770,6 @@ describe('Cache Components Errors', () => {
expect(output).toMatchInlineSnapshot(`
"Error: "use cache: private" must not be used within \`unstable_cache()\`.
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
at a (<next-dist-dir>)
19 | }
20 |
> 21 | const getCachedData = unstable_cache(async () => {
Expand Down Expand Up @@ -2841,7 +2838,6 @@ describe('Cache Components Errors', () => {
"stack": [
"{module evaluation} app/use-cache-private-in-use-cache/page.tsx (15:1)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
Expand Down Expand Up @@ -2898,7 +2894,6 @@ describe('Cache Components Errors', () => {
"Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
at a (<next-dist-dir>)
at b (<next-dist-dir>)
13 | }
14 |
> 15 | async function Private() {
Expand All @@ -2908,8 +2903,7 @@ describe('Cache Components Errors', () => {
18 | return <p>Private</p>
Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
at c (<next-dist-dir>)
at d (<next-dist-dir>)
at b (<next-dist-dir>)
13 | }
14 |
> 15 | async function Private() {
Expand All @@ -2927,7 +2921,6 @@ describe('Cache Components Errors', () => {
expect(output).toMatchInlineSnapshot(`
"Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
at a (<next-dist-dir>)
13 | }
14 |
> 15 | async function Private() {
Expand All @@ -2937,7 +2930,6 @@ describe('Cache Components Errors', () => {
18 | return <p>Private</p>
Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
at b (<next-dist-dir>)
13 | }
14 |
> 15 | async function Private() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ describe('app-dir - server source maps', () => {
"{module evaluation} app/module-evaluation/module.js (1:22)",
"{module evaluation} app/module-evaluation/page.js (1:1)",
"{module evaluation} app/module-evaluation/page.js (6:1)",
"<FIXME-next-dist-dir>",
"Array.map <anonymous>",
"Function.all <anonymous>",
"Page <anonymous>",
],
}
Expand Down Expand Up @@ -515,9 +516,8 @@ describe('app-dir - server source maps', () => {
expect(normalizeCliOutput(next.cliOutput)).toContain(
'' +
'\nError: module-evaluation' +
'\n at __TURBOPACK__module__evaluation__ (bundler:///app/module-evaluation/module.js:1:22)' +
// TODO(veil): Turbopack internals. Feel free to update. Tracked in https://linear.app/vercel/issue/NEXT-4362
'\n at Object.<anonymous>'
'\n at __TURBOPACK__module__evaluation__ (bundler:///app/module-evaluation/module.js:1:22)'
)
expect(normalizeCliOutput(next.cliOutput)).toContain(
'' +
Expand Down
Loading