-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix esm property def in flight loader (#66286)
### What Remove creating client proxy for each ESM export, instead for ESM we create a CJS module proxy for itself and access the property with export name as the actual export. ### Why `proxy` is the module proxy that we treat the module as a client boundary. For ESM, we access the property of the module proxy directly for each export. This is bit hacky that treating using a CJS like module proxy for ESM's exports, but this will avoid creating nested proxies for each export. It will be improved in the future. Notice that for `next/dynamic`, if you're doing a dynamic import of client component in server component, and trying to access the named export directly, it will error. Instead you need to align the dynamic import resolved value wrapping with a `default:` property (e.g. `{ default: resolved }`) like what `React.lazy` accepted. Revert #57301 Fixes #66212 x-ref: [slack](https://vercel.slack.com/archives/C04DUD7EB1B/p1716897764858829)
- Loading branch information
Showing
4 changed files
with
16 additions
and
15 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
10 changes: 4 additions & 6 deletions
10
test/e2e/app-dir/app-routes-client-component/app-routes-client-component.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import { FileRef, nextTestSetup } from 'e2e-utils' | ||
import path from 'path' | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('referencing a client component in an app route', () => { | ||
const { next } = nextTestSetup({ | ||
files: new FileRef(path.join(__dirname)), | ||
files: __dirname, | ||
}) | ||
|
||
it('responds without error', async () => { | ||
expect(JSON.parse(await next.render('/runtime'))).toEqual({ | ||
// Turbopack's proxy components are functions | ||
clientComponent: process.env.TURBOPACK ? 'function' : 'object', | ||
myModuleClientComponent: process.env.TURBOPACK ? 'function' : 'object', | ||
clientComponent: 'function', | ||
myModuleClientComponent: 'function', | ||
}) | ||
}) | ||
}) |
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