davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
263 stars 17 forks source link

warning Pattern ["buffer@^6.0.3"] is trying to unpack in the same destination #61

Closed nflaig closed 6 months ago

nflaig commented 7 months ago

Getting the following warning due to using this package

warning Pattern ["buffer@^6.0.3"] is trying to unpack in the same destination "/home/<user>/.cache/yarn/v6/npm-buffer-polyfill-6.0.3-2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6-integrity/node_modules/buffer-polyfill" as pattern ["buffer-polyfill@npm:buffer@^6.0.3"]. This could result in non-deterministic behavior, skipping.

likely related to

https://github.com/davidmyersdev/vite-plugin-node-polyfills/blob/bfb529025d722a49cf98c395550fd46454d0de39/package.json#L73

nflaig commented 6 months ago

Did some digging into the history of this package, looks like there was a similar issue with process-polyfill https://github.com/davidmyersdev/vite-plugin-node-polyfills/blob/bfb529025d722a49cf98c395550fd46454d0de39/shims/index.ts#L5-L9

Although I don't know if there is an actual runtime issue due to the buffer warning.

Potential workaround to get rid of the warning is to add custom resolution to install to different versions of buffer package, the only updates in 6.0.3 are type related (https://github.com/feross/buffer/pull/277) so I don't expect problems

"resolutions": {
    "buffer-polyfill": "npm:buffer@6.0.2"
  }

I am still curious, I haven't seen this before. Why is the renaming of the buffer package to buffer-polyfill required?

"dependencies": {
    "buffer-polyfill": "npm:buffer@^6.0.3",
  }
nflaig commented 6 months ago

Thanks @davidmyersdev for addressing this so quickly. We have updated the plugin to latest version and all warnings are resolved 🎉