Skip to content

Commit

Permalink
revert react changes and make await client entry
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed May 6, 2024
1 parent 8883aa7 commit 6ac3434
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export default function transformSource(
// Otherwise, we use eager mode with webpackExports to only include the necessary exports.
// If we have '*' in the ids, we include all the imports
if (ids.length === 0 || ids.includes('*')) {
return `import(/* webpackMode: "eager" */ ${importPath});\n`
return `await import(/* webpackMode: "eager" */ ${importPath});\n`
} else {
return `import(/* webpackMode: "eager", webpackExports: ${JSON.stringify(
return `await import(/* webpackMode: "eager", webpackExports: ${JSON.stringify(
ids
)} */ ${importPath});\n`
}
Expand All @@ -65,5 +65,13 @@ export default function transformSource(
type: RSC_MODULE_TYPES.client,
}

return code
const asyncModuleCode = `
async function deps() {
${code}
}
export const __client = await deps()
`
return asyncModuleCode
// return code
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function resolveClientReference(bundlerConfig, metadata) {
name = metadata[NAME];
}

if (resolvedModuleData.async || isAsyncImport(metadata)) {
if (isAsyncImport(metadata)) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
/* async */
];
Expand Down

0 comments on commit 6ac3434

Please sign in to comment.