-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import Next's CJS AsyncLocalStorage modules (vercel/turborepo#3634)
The node evaluation always renders with `type: "commonjs"` and `require()` calls, so we'll always import the CJS files. But here we're importing the ESM files. That means we have 2 distinct instances of `requestAsyncStorage` in our node instance, and they cannot properly communicate with the other. Fixes WEB-543
- Loading branch information
1 parent
38c78b6
commit 9694fc4
Showing
8 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/next-swc/crates/next-core/js/src/entry/edge-bootstrap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
declare module "next/dist/esm/client/components/static-generation-async-storage.js"; | ||
declare module "next/dist/esm/client/components/request-async-storage.js"; | ||
declare module "next/dist/esm/client/components/hooks-server-context.js"; | ||
declare module "next/dist/client/components/static-generation-async-storage.js"; | ||
declare module "next/dist/client/components/request-async-storage.js"; | ||
declare module "next/dist/client/components/hooks-server-context.js"; | ||
declare module "next/dist/compiled/react-server-dom-webpack/server.browser"; |
12 changes: 12 additions & 0 deletions
12
...crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
export default function RootLayout({ children }: { children: any }) { | ||
return ( | ||
<html> | ||
<body> | ||
{JSON.stringify(cookies(), null, 2)} | ||
{children} | ||
</body> | ||
</html> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
...c/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Test from "./test"; | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Test /> | ||
</div> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
...c/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
|
||
export default function Test() { | ||
useEffect(() => { | ||
import("@turbo/pack-test-harness").then(() => { | ||
it("should run", () => {}); | ||
}); | ||
return () => {}; | ||
}, []); | ||
} |
5 changes: 5 additions & 0 deletions
5
...crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
}; |