Skip to content

Commit 9bf3edf

Browse files
committed
Ensure the predefined onwarn handler is called when present
1 parent 42a6bb1 commit 9bf3edf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const nodePolyfills = (options: PolyfillOptions = {}): Plugin => {
179179

180180
return {
181181
name: 'vite-plugin-node-polyfills',
182-
config: (_config, env) => {
182+
config: (config, env) => {
183183
const isDev = env.mode === 'development'
184184
const polyfills = (Object.entries(stdLibBrowser) as Array<[ModuleName, string]>).reduce<Record<ModuleName, string>>((included, [name, value]) => {
185185
if (!optionsResolved.protocolImports) {
@@ -199,8 +199,10 @@ export const nodePolyfills = (options: PolyfillOptions = {}): Plugin => {
199199
build: {
200200
rollupOptions: {
201201
onwarn: (warning, rollupWarn) => {
202-
const warningHandler = _config.build?.rollupOptions?.onwarn ?? rollupWarn
203-
handleCircularDependancyWarning(warning, warningHandler)
202+
handleCircularDependancyWarning(warning, rollupWarn)
203+
204+
// Make sure the predefined `onwarn` handler is called too.
205+
config.build?.rollupOptions?.onwarn?.(warning, rollupWarn)
204206
},
205207
plugins: [
206208
{

0 commit comments

Comments
 (0)