Skip to content

Commit d12a511

Browse files
authored
refactor: Silence Rollup warnings regarding source maps & use directives (#150)
1 parent b49447b commit d12a511

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/index.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,23 @@ function preactPlugin({
153153
build: {
154154
rollupOptions: {
155155
onwarn(warning, warn) {
156-
// Silence Rollup's module-level directive warnings -- they're likely
157-
// to all come from `node_modules` (RSCs) and won't be actionable.
158-
if (warning.code === "MODULE_LEVEL_DIRECTIVE") return;
156+
// Silence Rollup's module-level directive warnings re:"use client".
157+
// They're likely to come from `node_modules` and won't be actionable.
158+
if (
159+
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
160+
warning.message.includes("use client")
161+
)
162+
return;
163+
// ESBuild seemingly doesn't include mappings for directives, causing
164+
// Rollup to emit warnings about missing source locations. This too is
165+
// likely to come from `node_modules` and won't be actionable.
166+
// evanw/esbuild#3548
167+
if (
168+
warning.code === "SOURCEMAP_ERROR" &&
169+
warning.message.includes("resolve original location") &&
170+
warning.pos === 0
171+
)
172+
return;
159173
warn(warning);
160174
},
161175
},

0 commit comments

Comments
 (0)