Skip to content

Update the event-target-shim dependency #30

Open
@jaydenseric

Description

@jaydenseric

The event-target-shim dependency is a major version out of date, resulting in duplicate installation headaches for projects that actually need the newer event-target-shim version to polyfill event related globals (the old version doesn't export the needed classes) at the same time as the abort-controller/polyfill.

For example, in graphql-react-examples:

npm ls event-target-shim
graphql-react-examples@ /[redacted]/graphql-react-examples
├─┬ abort-controller@3.0.0
│ └── event-target-shim@5.0.1
└── event-target-shim@6.0.2

https://github.com/jaydenseric/graphql-react-examples/blob/4b732478987ea452acfb43c752ab99512463d9b2/utils/nodePolyfills.js#L1-L22

if (typeof window === 'undefined') {
  if (!('performance' in global))
    global.performance = require('perf_hooks').performance;

  if (!('EventTarget' in global))
    global.EventTarget =
      require('events').EventTarget || require('event-target-shim').EventTarget;

  if (!('Event' in global))
    global.Event =
      require('events').Event || require('event-target-shim').Event;

  if (!('CustomEvent' in global))
    global.CustomEvent = class CustomEvent extends Event {
      constructor(eventName, { detail, ...eventOptions } = {}) {
        super(eventName, eventOptions);
        this.detail = detail;
      }
    };

  require('abort-controller/polyfill');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions