Skip to content

Commit 7a623e0

Browse files
committed
Update Rollup config
1 parent 9d659f7 commit 7a623e0

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

rollup.config.mjs

+13-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
import externals from "rollup-plugin-node-externals";
22
import resolve from "@rollup/plugin-node-resolve";
3-
import commonjs from "@rollup/plugin-commonjs";
43
import typescript from "@rollup/plugin-typescript";
5-
6-
import pkg from "./package.json" assert { type: "json" };
7-
8-
const createOutput = (config) => ({
9-
sourcemap: true,
10-
banner: "'use client';",
11-
...(config || {}),
12-
});
4+
import preserveDirectives from "rollup-plugin-preserve-directives";
135

146
/**
157
* @type {import('rollup').RollupOptions}
168
*/
179
const config = {
1810
input: "src/index.ts",
19-
output: [
20-
{
21-
file: pkg.main,
22-
format: "cjs",
23-
},
24-
{
25-
file: pkg.module,
26-
format: "esm",
27-
},
28-
].map(createOutput),
29-
plugins: [externals(), resolve(), commonjs(), typescript()],
11+
output: {
12+
format: "esm",
13+
sourcemap: false,
14+
preserveModules: true,
15+
preserveModulesRoot: "src",
16+
dir: "lib",
17+
},
18+
plugins: [externals(), resolve(), preserveDirectives(), typescript()],
19+
onwarn(warning, warn) {
20+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes(`use client`)) return;
21+
warn(warning);
22+
},
3023
};
3124

3225
export default config;

0 commit comments

Comments
 (0)