davidmyersdev/vite-plugin-node-polyfills

events.js does not provide an export named 'default'

nazarhussain opened this issue · 3 comments

I am trying to use this plugin along with vitest and it's causing following errors for the events polyfill.

SyntaxError: The requested module '/@fs/..../node_modules/events/events.js?v=f72cd9a9' does not provide an export named 'default'

Here are my configurations

export default defineConfig({
  plugins: [
    topLevelAwait(),
    nodePolyfills({
      include: ["buffer", "process", "util", "string_decoder", "url", "querystring"],
      globals: {Buffer: true, process: true},
      protocolImports: true,
    }),
  ],
});

Events package resolved to following:

├─ events@3.3.0

And environment details are following:

  System:
    OS: macOS 14.0
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 212.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.7.0 - ~/.asdf/installs/nodejs/20.7.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/20.7.0/bin/yarn
    npm: 10.1.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Brave Browser: 118.1.59.120
    Chrome: 118.0.5993.88
    Firefox: 112.0.1
    Safari: 17.0

I found a workaround for now by adding following configuration, but this issue should be addressed in this package.

resolve: {
    alias: {
      events: "eventemitter3",
    },
  },

Would you mind adding a StackBlitz or CodeSandbox reproduction of this issue for me to debug?

Closing due to lack of activity/reproduction.