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

Add globalObject to webpack config output #64

Merged

Conversation

jasonbarry
Copy link
Contributor

This PR fixes #38 by adding the globalObject output setting in the common webpack config. Per webpack's docs:

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.

This change replaces the instance of self in the built output to become this, which works in both node and browser environments.

@jasonbarry
Copy link
Contributor Author

jasonbarry commented Jul 7, 2021

This also fixes #56 by letting you import the library like this:

import QRCodeStyling from 'qr-code-styling'

@cayasso
Copy link

cayasso commented Nov 1, 2021

Any update on this?

@KiT-Maverik
Copy link

Any updates on this?

cogoo added a commit to cogoo/qr-code-styling that referenced this pull request Feb 1, 2022
Implement PR from: kozakdenys#64

> 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.
@kozakdenys kozakdenys merged commit 4c16b4b into kozakdenys:master Oct 13, 2024
@github-actions github-actions bot mentioned this pull request Oct 13, 2024
@kozakdenys kozakdenys added the reviewed Temporary label to review all open and closed PR label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed Temporary label to review all open and closed PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing QRCodeStyling into NextJS immediately fails
4 participants