Revert "Fix esm property def in flight loader" (#66727)
This is causing unexpected errors. Reverts vercel/next.js#66286
This commit is contained in:
parent
0e582a9b59
commit
7b97f30c40
4 changed files with 15 additions and 16 deletions
|
@ -97,24 +97,21 @@ export default function transformSource(
|
|||
return
|
||||
}
|
||||
|
||||
// `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.
|
||||
let esmSource = `\
|
||||
import { createProxy } from "${MODULE_PROXY_PATH}"
|
||||
|
||||
const proxy = createProxy(String.raw\`${resourceKey}\`)
|
||||
`
|
||||
let cnt = 0
|
||||
for (const ref of clientRefs) {
|
||||
if (ref === '') {
|
||||
esmSource += `exports[''] = proxy['']\n`
|
||||
esmSource += `\nexports[''] = createProxy(String.raw\`${resourceKey}#\`);`
|
||||
} else if (ref === 'default') {
|
||||
esmSource += `export default createProxy(String.raw\`${resourceKey}#default\`);\n`
|
||||
esmSource += `\
|
||||
export default createProxy(String.raw\`${resourceKey}#default\`);
|
||||
`
|
||||
} else {
|
||||
esmSource += `const e${cnt} = proxy["${ref}"];\n`
|
||||
esmSource += `export { e${cnt++} as ${ref} };\n`
|
||||
esmSource += `
|
||||
const e${cnt} = createProxy(String.raw\`${resourceKey}#${ref}\`);
|
||||
export { e${cnt++} as ${ref} };`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ function convertModule<P>(
|
|||
// Cases:
|
||||
// mod: { default: Component }
|
||||
// mod: Component
|
||||
// mod: { default: proxy(Component) }
|
||||
// mod: { $$typeof, default: proxy(Component) }
|
||||
// mod: proxy(Component)
|
||||
const hasDefault = mod && 'default' in mod
|
||||
return {
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import { nextTestSetup } from 'e2e-utils'
|
||||
import { FileRef, nextTestSetup } from 'e2e-utils'
|
||||
import path from 'path'
|
||||
|
||||
describe('referencing a client component in an app route', () => {
|
||||
const { next } = nextTestSetup({
|
||||
files: __dirname,
|
||||
files: new FileRef(path.join(__dirname)),
|
||||
})
|
||||
|
||||
it('responds without error', async () => {
|
||||
expect(JSON.parse(await next.render('/runtime'))).toEqual({
|
||||
clientComponent: 'function',
|
||||
myModuleClientComponent: 'function',
|
||||
// Turbopack's proxy components are functions
|
||||
clientComponent: process.env.TURBOPACK ? 'function' : 'object',
|
||||
myModuleClientComponent: process.env.TURBOPACK ? 'function' : 'object',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ import dynamic from 'next/dynamic'
|
|||
|
||||
const Button = dynamic(() =>
|
||||
import('./client').then((mod) => {
|
||||
return { default: mod.Button }
|
||||
return mod.Button
|
||||
})
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue