Skip to content

Commit

Permalink
simplify and update test
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 7, 2022
1 parent 406dea0 commit df3ba30
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
12 changes: 5 additions & 7 deletions packages/next/build/webpack/loaders/next-flight-server-loader.ts
Expand Up @@ -121,9 +121,9 @@ async function parseModuleInfo({
// have to be imported from either server or client components.
if (
isServerComponent(importSource) ||
hasFlightLoader(importSource, 'server') // ||
hasFlightLoader(importSource, 'server') ||
// TODO: support handling RSC components from node_modules
// isNodeModuleImport
isNodeModuleImport
) {
continue
}
Expand Down Expand Up @@ -195,11 +195,12 @@ export default async function transformSource(
const hasAppliedFlightServerLoader = this.loaders.some((loader: any) => {
return hasFlightLoader(loader.path, 'server')
})
const isServerExt = isServerComponent(resourcePath)

if (!isClientCompilation) {
// We only apply the loader to server components, or shared components that
// are imported by a server component.
if (!isServerComponent(resourcePath) && !hasAppliedFlightServerLoader) {
if (!isServerExt && !hasAppliedFlightServerLoader) {
return source
}
}
Expand Down Expand Up @@ -238,7 +239,7 @@ export default async function transformSource(
_: () => {
${imports.map((source) => `require('${source}');`).join('\n')}
},
server: ${isServerComponent(resourcePath) ? 'true' : 'false'}
server: ${isServerExt ? 'true' : 'false'}
}`,
}

Expand All @@ -260,8 +261,5 @@ export default async function transformSource(
}

const output = transformedSource + '\n' + buildExports(rscExports, isEsm)
// if (resourcePath.includes('external-imports')) {
// console.log(isClientCompilation ? 'client' : 'server', '\n' ,output)
// }
return output
}

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -18,7 +18,6 @@ export default function (context, { runtime, env }) {
expect(homeHTML).toContain('component:index.server')
expect(homeHTML).toContain('env:env_var_test')
expect(homeHTML).toContain('header:test-util')
expect(homeHTML).toContain('nav-title')
expect(homeHTML).toContain('path:/')
})

Expand Down

0 comments on commit df3ba30

Please sign in to comment.