Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EventEmitter import for es module compatibility #1295

Closed
wants to merge 1 commit into from

Conversation

LukasBudach
Copy link

What's Changing and Why

Changed the packages/core/src/index.js import of the EventEmitter class.

Was: import EventEmitter from "events"

Now: import * as EventEmitter from "events"

This change was required for building a project utilizing Jimp custom to build a slimmer version of the library. The project is built as a module with target esnext on Node20 and Typescript using Vite.
Without this fix, vite build will produce the following error:

error during build:
RollupError: node_modules/@jimp/core/es/index.js (29:7): "default" is not exported by "node_modules/events/events.js", imported by "node_modules/@jimp/core/es/index.js".
file: [...]/node_modules/@jimp/core/es/index.js:29:7

The events package is not an es module yet, see Issue 86 and converting it to one is not on the roadmap as far as I can tell. Therefore, this fix should be applied to Jimp directly.

What else might be affected

Compatibility may be affected when building Jimp not as an es module.

Tasks

The events library does not support the es module type yet, making this import format change necessary browserify/events#86
@hipstersmoothie
Copy link
Collaborator

event emitter usage has been removed, it never really made sense for this library (unless someone convinces me)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants