Skip to content

Commit

Permalink
fix: add missing 'use client' in chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprevot committed Apr 12, 2024
1 parent 0d7809e commit 4bcf61e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/fractal/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ async function addDirectivesToChunkFiles(distPath = DIST_PATH) {

// eslint-disable-next-line no-await-in-loop -- We need to wait for each file to be read
const data = await fs.readFile(filePath, 'utf8')
if (data.startsWith("'use client';")) {
// eslint-disable-next-line no-console -- We need to log the result
console.log(`Directive already exists in ${file}`)
continue
}

const updatedContent = `'use client';\n${data}`

Expand Down Expand Up @@ -46,6 +51,9 @@ const commonConfig: Options = {
external: ['react', 'react-dom', '@iconscout/react-unicons'],
format: 'esm',
minify: true,
async onSuccess() {
await addDirectivesToChunkFiles()
},
outDir: DIST_PATH,
replaceNodeEnv: true,
sourcemap: true,
Expand Down Expand Up @@ -76,8 +84,5 @@ export default defineConfig([
'./src/hooks/*.ts',
'./src/components/**/index.ts',
],
async onSuccess() {
await addDirectivesToChunkFiles()
},
},
])

0 comments on commit 4bcf61e

Please sign in to comment.