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

fix: set webpack global Object to "this" #115

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

Sembauke
Copy link
Member

@Sembauke Sembauke commented Jan 17, 2024

When targeting a library, especially when libraryTarget is 'umd', this option indicates what global object will be used to mount the library. To make UMD build available on both browsers and Node.js, set output.globalObject option to 'this'. Defaults to self for Web-like targets.

The return value of your entry point will be assigned to the global object using the value of output.library.name. Depending on the value of the target option, the global object could change respectively, e.g., self, global, or globalThis.

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

We should probably set the other values as well?

@Sembauke Sembauke requested a review from a team as a code owner January 17, 2024 11:55
@ShaunSHamilton
Copy link
Member

I have read that a few times, but still do not understand what this does/changes.

@Sembauke
Copy link
Member Author

Sembauke commented Jan 17, 2024

Hey @ShaunSHamilton,

I am not sure either, it's a bit of a shot in the dark. But this sentence made the most sense to me:

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

Currently the global-object is "self" and this will change it to "this" to make it work in browsers.

Currently the mobile app does not work with this version and I was hoping this would fix it.

Copy link
Member

@ShaunSHamilton ShaunSHamilton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works 👍

@ShaunSHamilton ShaunSHamilton merged commit 3ab7270 into main Jan 17, 2024
3 checks passed
@ShaunSHamilton ShaunSHamilton deleted the fix/webpack-config-globalObject branch January 17, 2024 14:21
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