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

Dependency error: ReferenceError: self is not defined for qr-code-styling #39

Closed
KunalBagaria opened this issue Feb 1, 2022 · 7 comments · Fixed by #40
Closed

Dependency error: ReferenceError: self is not defined for qr-code-styling #39

KunalBagaria opened this issue Feb 1, 2022 · 7 comments · Fixed by #40
Labels
bug Something isn't working

Comments

@KunalBagaria
Copy link

Dependency (qr-code-styling) error while trying to use the package in Next.js@12.0.0

image

Server Error

ReferenceError: self is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.

It's the same even if I only use the encodeURL method.

Linking to a issue and PR for this error in their repository:
kozakdenys/qr-code-styling#38
kozakdenys/qr-code-styling#64

@jordaaash
Copy link
Collaborator

Thanks for the report, Next.js is really important to support. Do you happen to have a repo that reproduces the issue? Happy to take a look.

@jordaaash jordaaash added the bug Something isn't working label Feb 1, 2022
@KunalBagaria
Copy link
Author

Yeah, just made one: https://github.com/kb24x7/solana-pay-next

@jordaaash
Copy link
Collaborator

Ah, I see the issue. I had to use this for Jest to run the tests: https://github.com/solana-labs/solana-pay/blob/d7e21ab3da5ac1ed110ba48375e0800a0fc4f8d5/core/jest.config.json#L3

I think the issue is that the QR code library accesses this, https://developer.mozilla.org/en-US/docs/Web/API/Window/self, probably to make UMD build.

While this workaround is an option, disabling SSR is kind of a drag.

If that library is no longer maintained, we should fork it and fix this.

@jordaaash
Copy link
Collaborator

This is fixed in @solana/pay@0.1.0-alpha.7, I tested it with your Next app:
Screen Shot 2022-02-01 at 3 42 14 PM

@KunalBagaria
Copy link
Author

Great! Thanks for the quick fix, actually I did make myself a fork as well 😄

@zhen1asemen1uk
Copy link

Help please with this problem 😥
I don't see solving

@zholadev
Copy link

import through next/dynamic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants