Skip to content

Commit

Permalink
refactor: Silence Rollup warnings regarding source maps & use directi…
Browse files Browse the repository at this point in the history
…ves (#150)
  • Loading branch information
rschristian authored Jan 1, 2025
1 parent b49447b commit d12a511
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,23 @@ function preactPlugin({
build: {
rollupOptions: {
onwarn(warning, warn) {
// Silence Rollup's module-level directive warnings -- they're likely
// to all come from `node_modules` (RSCs) and won't be actionable.
if (warning.code === "MODULE_LEVEL_DIRECTIVE") return;
// Silence Rollup's module-level directive warnings re:"use client".
// They're likely to come from `node_modules` and won't be actionable.
if (
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
warning.message.includes("use client")
)
return;
// ESBuild seemingly doesn't include mappings for directives, causing
// Rollup to emit warnings about missing source locations. This too is
// likely to come from `node_modules` and won't be actionable.
// evanw/esbuild#3548
if (
warning.code === "SOURCEMAP_ERROR" &&
warning.message.includes("resolve original location") &&
warning.pos === 0
)
return;
warn(warning);
},
},
Expand Down

0 comments on commit d12a511

Please sign in to comment.