qr-code icon indicating copy to clipboard operation
qr-code copied to clipboard

Compatibility issue with Sentry + Next.js

Open rnbrady opened this issue 1 year ago • 3 comments

When using with Next.js 15, if Sentry is added to the project then rendering fails with Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

The error can be resolved by upgrading Stencil. PR to follow shortly.

See rnbrady/qrcode-sentry-issue for reproduction. Before vs after adding Sentry:

Screenshot 2025-01-07 at 14 06 39

The issue seems to be specific to Next.js or React as I'm unable to reproduce it by adding Sentry to the vanilla HTML + Js demo pages.

rnbrady avatar Jan 07 '25 14:01 rnbrady

Hey @rnbrady

Since the PR hasn’t been merged in over 3 months, would you consider publishing your fork to npm?

Right now the GitHub repo is missing the dist/ folder, so it can’t be used directly as a dependency.

frederichoule avatar Apr 20 '25 03:04 frederichoule

@frederichoule the best solution is to vendor the package with the changes you want. You build the package (npm run build) and compress it (npm pack) into a tarball which you copy into your project (e.g. in a top level vendor folder) and commit to git.

Then you npm install or pnpm add that tarball, after which you package.json will look like this:

"dependencies": {
    "@bitjson/qr-code": "file:vendor/bitjson-qr-code.tar.gz",
}

Your package manager extracts the tarball into node_modules.

rnbrady avatar Apr 23 '25 11:04 rnbrady

@frederichoule the best solution is to vendor the package with the changes you want. You build the package (npm run build) and compress it (npm pack) into a tarball which you copy into your project (e.g. in a top level vendor folder) and commit to git.

Then you npm install or pnpm add that tarball, after which you package.json will look like this:

"dependencies": {
    "@bitjson/qr-code": "file:vendor/bitjson-qr-code.tar.gz",
}

Your package manager extracts the tarball into node_modules.

Thanks! I will try that.

frederichoule avatar Apr 23 '25 13:04 frederichoule