From d5a3dc75fc231654f5cba59240b92ede8fac0c73 Mon Sep 17 00:00:00 2001 From: aidanCQ Date: Wed, 20 Dec 2023 13:03:06 +0000 Subject: [PATCH] fix(): Suppress module directive warnings and export sourcemap. --- rollup.config.js | 63 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index faaf440..c30dd73 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,34 +6,37 @@ import peerDepsExternal from "rollup-plugin-peer-deps-external"; import preserveDirectives from "rollup-plugin-preserve-directives"; import { terser } from "rollup-plugin-terser"; -export default [ - { - input: "src/index.ts", - output: [ - { - dir: "dist/", - format: "esm", - preserveModules: true, - }, - ], - plugins: [ - peerDepsExternal(), - // Locate modules using the Node resolution algorithm - resolve(), - // Convert CommonJS modules to ES6. - commonjs(), - // Create typescript definitions. - typescript({ - tsconfig: "./tsconfig.json", - declarationDir: "./dist/types", - }), - // CSS vendor prefixing etc. - copy({ - targets: [{ src: "./src/tokens.css", dest: "./dist" }], - }), - // Minify output. - terser({ compress: { directives: false } }), - preserveDirectives(), - ], +export default { + onwarn(warning, warn) { + if ( + warning.code === "MODULE_LEVEL_DIRECTIVE" && + warning.message.includes(`'use client'`) + ) { + return; + } + warn(warning); }, -]; + input: "src/index.ts", + output: [ + { + dir: "dist/", + format: "esm", + preserveModules: true, + sourcemap: true, + }, + ], + plugins: [ + peerDepsExternal(), + resolve(), + commonjs(), + typescript({ + tsconfig: "./tsconfig.json", + declarationDir: "./dist/types", + }), + copy({ + targets: [{ src: "./src/tokens.css", dest: "./dist" }], + }), + terser({ compress: { directives: false } }), + preserveDirectives(), + ], +};