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

window -> self for Web Worker #7

Closed
wants to merge 1 commit into from

Conversation

hata6502
Copy link
Contributor

@hata6502 hata6502 commented Dec 29, 2020

Thank you for maintaining sudachi-synonyms-dictionary and textlint-rule-no-synonyms!
By using self instead of window, it can supports both window and Web Worker.

https://developer.mozilla.org/ja/docs/Web/API/Window/self

@hata6502 hata6502 marked this pull request as ready for review December 29, 2020 16:07
@azu
Copy link
Owner

azu commented Jan 6, 2021

I think that self is similar one of window.
Probably, globalThis is suitable, but some browser does not support it yet.

Maybe, emurating all globals like this is best, but It's still unclear.

const getDictionaryURLFromGlobal = function () {
  if (typeof self !== 'undefined') { return selfsudachi-synonyms-dictionary; }
  if (typeof window !== 'undefined') { return windowsudachi-synonyms-dictionary; }
  if (typeof global !== 'undefined') { return globalsudachi-synonyms-dictionary; }
  throw new Error('unable to locate global object');
};

webpack can do workaround like it, but webpack has not suitable option.

azu added a commit that referenced this pull request May 13, 2021
@azu azu mentioned this pull request May 13, 2021
@azu azu closed this in #8 May 13, 2021
azu added a commit that referenced this pull request May 13, 2021
BREAKING CHANGE: support ESM and remove options

This version make `sudachi-synonyms-dictionary` simple ESM/CommonJS module

fix #7
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