Skip to content

Commit

Permalink
fix: correctly import EventEmitter to prevent errors with bundlers
Browse files Browse the repository at this point in the history
Importing EventEmitter like `const EventEmitter  = require('events')` creates errors with bundlers like esbuild, vite and so on: `TypeError: EventEmitter2 is not a constructor`
  • Loading branch information
robertsLando committed Nov 7, 2023
1 parent b526219 commit 67ea463
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion generate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const writeToStream = require('./writeToStream')
const EventEmitter = require('events')
const { EventEmitter } = require('events')
const { Buffer } = require('buffer')

function generate (packet, opts) {
Expand Down
2 changes: 1 addition & 1 deletion parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const bl = require('bl')
const EventEmitter = require('events')
const { EventEmitter } = require('events')
const Packet = require('./packet')
const constants = require('./constants')
const debug = require('debug')('mqtt-packet:parser')
Expand Down

0 comments on commit 67ea463

Please sign in to comment.