Skip to content

Commit

Permalink
fix(gatsby): Partial hydration loader commented out directive case (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
tyhopp authored Nov 1, 2022
1 parent 7dfa673 commit 8b26fa0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export const c = {

exports[`covers cases shown in fixtures/cjs-module-exports.js 1`] = `""`;

exports[`covers cases shown in fixtures/commented-out-directive.js 1`] = `
"// \\"use client\\"
export default function () {}"
`;

exports[`covers cases shown in fixtures/esm-aggregation.js 1`] = `""`;

exports[`covers cases shown in fixtures/esm-declaration.js 1`] = `
Expand Down Expand Up @@ -153,6 +159,14 @@ export default {
}"
`;

exports[`covers cases shown in fixtures/no-client-export.js 1`] = `""`;
exports[`covers cases shown in fixtures/no-directive.js 1`] = `
"export function noClientExport() {
return \`No \\"use client\\" found in this file\`
}"
`;
exports[`covers cases shown in fixtures/no-client-export-no-export.js 1`] = `""`;
exports[`covers cases shown in fixtures/no-directive-and-no-export.js 1`] = `
"function noClientExport() {
return \`No \\"use client\\" found in this file, and the function itself is not exported\`
}"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// "use client"

export default function () {}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const partialHydrationReferenceLoader: LoaderDefinitionFunction<
},
})

return references.join(`\n`)
return hasClientExportDirective ? references.join(`\n`) : content
}

module.exports = partialHydrationReferenceLoader

0 comments on commit 8b26fa0

Please sign in to comment.