Skip to content

Commit

Permalink
feat(rollup): add 'use client' directive and enable named exports (#38)
Browse files Browse the repository at this point in the history
* to adapting nextjs
  • Loading branch information
keiko233 authored Dec 3, 2024
1 parent cd24609 commit ab3553a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import dts from "rollup-plugin-dts";
import external from "rollup-plugin-peer-deps-external";
import postcss from "rollup-plugin-postcss";

const addUseClient = () => ({
name: "add-use-client",
renderChunk(code) {
return `'use client';\n${code}`;
},
});

const globals = { react: "React" };

export default defineConfig([
Expand All @@ -14,6 +21,7 @@ export default defineConfig([
output: {
dir: "dist/cjs",
format: "cjs",
exports: "named",
sourcemap: true,
globals,
preserveModules: true,
Expand All @@ -23,21 +31,23 @@ export default defineConfig([
external(),
nodeResolve(),
commonjs(),
postcss(),
addUseClient(),
typescript({
tsconfig: "./tsconfig.json",
compilerOptions: {
outDir: "dist/cjs",
declarationDir: "dist/cjs",
},
}),
postcss(),
],
},
{
input: "src/index.ts",
output: {
dir: "dist/esm",
format: "esm",
exports: "named",
sourcemap: true,
globals,
preserveModules: true,
Expand All @@ -47,14 +57,15 @@ export default defineConfig([
external(),
nodeResolve(),
commonjs(),
postcss(),
addUseClient(),
typescript({
tsconfig: "./tsconfig.json",
compilerOptions: {
outDir: "dist/esm",
declarationDir: "dist/esm",
},
}),
postcss(),
],
},
{
Expand Down

0 comments on commit ab3553a

Please sign in to comment.