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 the event-target-shim dependency #30

Open
jaydenseric opened this issue Apr 20, 2021 · 0 comments
Open

Update the event-target-shim dependency #30

jaydenseric opened this issue Apr 20, 2021 · 0 comments

Comments

@jaydenseric
Copy link

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
├─┬ [email protected]
│ └── [email protected]
└── [email protected]

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');
}
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

No branches or pull requests

1 participant