Skip to content

Commit

Permalink
only apply to page or layout files
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 30, 2022
1 parent dedbfa1 commit 5df6115
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -24,13 +24,15 @@ export default async function transformSource(

const appDir = path.join(this.rootContext, 'app')
const isUnderAppDir = containsPath(appDir, this.resourcePath)
const filename = path.basename(this.resourcePath)
const isPageOrLayoutFile = /^(page|layout)\.client\.\w+$/.test(filename)

const createError = (name: string) =>
new Error(
`${name} is not supported in client components.\nFrom: ${this.resourcePath}`
)

if (isUnderAppDir) {
if (isUnderAppDir && isPageOrLayoutFile) {
const swcAST = await parse(source, {
filename: this.resourcePath,
isModule: 'unknown',
Expand Down

0 comments on commit 5df6115

Please sign in to comment.