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

Change globalObject to globalThis #1725

Merged
merged 1 commit into from
Oct 25, 2022
Merged

Change globalObject to globalThis #1725

merged 1 commit into from
Oct 25, 2022

Conversation

kkocdko
Copy link
Contributor

@kkocdko kkocdko commented Oct 21, 2022

I want to run docs.js in some embed js engine which have not this defined in global namespace (and es module also haven't).

Compatibility: not a problem, globalThis was added in ES6, and this project's tsconfig.json also uses ES6 target.

https://github.com/dolanmiu/docx/blob/master/tsconfig.json#L3

@codecov-commenter
Copy link

Codecov Report

Base: 99.70% // Head: 99.70% // No change to project coverage 👍

Coverage data is based on head (482ea1b) compared to base (7e5e2ba).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1725   +/-   ##
=======================================
  Coverage   99.70%   99.70%           
=======================================
  Files         319      319           
  Lines        3704     3704           
  Branches      405      405           
=======================================
  Hits         3693     3693           
  Misses         11       11           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dolanmiu
Copy link
Owner

I am not sure about this, this will break docx on the web:

Docs from webpack:

https://webpack.js.org/configuration/output/#outputglobalobject

To make UMD build available on both browsers and Node.js, set output.globalObject option to 'this'

@kkocdko
Copy link
Contributor Author

kkocdko commented Oct 23, 2022

Webpack doc: To make UMD build available on both browsers and Node.js, set output.globalObject option to 'this'

I think this description is just for legacy. I have tried on Chrome, Firefox, Deno, Node, QuickJS and their ESModule enviroument. There's no reason that globalThis will break on web environment. And,

MDN: this will be undefined in Modules

So the most important problem is compatibility. Chrome >= 71, Firefox >= 65, no IE supports. But I'm not sure what target docx.js supports before? If you prefer to keep compatibility, fell free to close this PR, I'll just patch it in my enviroument.

@dolanmiu
Copy link
Owner

Ok, sounds good, I will double check tomorrow, if its good, I will merge

@dolanmiu
Copy link
Owner

Looks good to me, merging

@dolanmiu dolanmiu merged commit efd853d into dolanmiu:master Oct 25, 2022
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.

3 participants