Skip to content

Conversation

@alxndrsn
Copy link
Contributor

@alxndrsn alxndrsn commented Nov 20, 2025

This seems to be a common issue:

I think it was introduced by 404346b, which upgrade from webpack 1 to webpack 5. From the webpack docs:

Webpack 5 no longer polyfills Node.js core modules automatically which means if you use them in your code running in browsers or alike, you will have to install compatible modules from npm and include them yourself.

Alternatively, it may come from rollup.

Hopefully:

Closes #8968
Closes #8985
Closes #8989
Closes #9072
Closes #9078

@alxndrsn
Copy link
Contributor Author

Less convinced now:

> e1 = require('node:events'); e2 = require('./node_modules/events');
<ref *1> [Function: EventEmitter] {
  once: [Function: once],
  EventEmitter: [Circular *1],
  defaultMaxListeners: [Getter/Setter],
  init: [Function (anonymous)],
  listenerCount: [Function (anonymous)]
}
> e1
<ref *1> [Function: EventEmitter] {
  addAbortListener: [Function: addAbortListener],
  once: [AsyncFunction: once],
  on: [Function: on],
  getEventListeners: [Function: getEventListeners],
  getMaxListeners: [Function: getMaxListeners],
  EventEmitter: [Circular *1],
  usingDomains: true,
  captureRejectionSymbol: Symbol(nodejs.rejection),
  captureRejections: [Getter/Setter],
  EventEmitterAsyncResource: [Getter],
  errorMonitor: Symbol(events.errorMonitor),
  defaultMaxListeners: [Getter/Setter],
  setMaxListeners: [Function (anonymous)],
  init: [Function (anonymous)],
  listenerCount: [Function (anonymous)]
}
> e2
<ref *1> [Function: EventEmitter] {
  once: [Function: once],
  EventEmitter: [Circular *1],
  defaultMaxListeners: [Getter/Setter],
  init: [Function (anonymous)],
  listenerCount: [Function (anonymous)]
}
> e1.EventEmitter === e2.EventEmitter
false

TODO

  • handle this like other browser-specific polyfills, using import 'events' vs import 'node:events'

@alxndrsn alxndrsn marked this pull request as draft November 20, 2025 11:15
@alxndrsn alxndrsn marked this pull request as ready for review November 20, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment