zxing-js/library

Rollup Build Errors: "this" has been rewritten to "undefined" and Circular Dependencies

ophiryaniv-ts opened this issue · 1 comments

Hi,
First of all, I want to thank you for the amazing work you’ve done with this library. It's been a fantastic tool for my project.

I'm new to JavaScript and TypeScript and I'm using the zxing-js/library package in my project. When I try to build my project with Rollup, I'm encountering the following errors:

(!) "this" has been rewritten to "undefined"
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules/@zxing/browser/esm/readers/BrowserDatamatrixCodeReader.js
1: var __extends = (this && this.__extends) || (function () {
                    ^
2:     var extendStatics = function (d, b) {
3:         extendStatics = Object.setPrototypeOf ||
...and 1 other occurrence
node_modules/@zxing/browser/esm/readers/BrowserPDF417Reader.js
1: var __extends = (this && this.__extends) || (function () {
                    ^
2:     var extendStatics = function (d, b) {
3:         extendStatics = Object.setPrototypeOf ||
...and 1 other occurrence
node_modules/@zxing/browser/esm/readers/BrowserMultiFormatReader.js
1: var __extends = (this && this.__extends) || (function () {
                    ^
2:     var extendStatics = function (d, b) {
3:         extendStatics = Object.setPrototypeOf ||
...and 1 other occurrence

...and 112 other files
(!) Circular dependencies
node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/ASCIIEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js
node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/Base256Encoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js
node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/C40Encoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js
node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/EdifactEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js
node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/X12Encoder.js -> node_modules/@zxing/library/esm/core/datamatrix/encoder/HighLevelEncoder.js

Could you please assist me in resolving these errors?

Thank you!

Hey, I just look into it, the thing is that the code doesn't contain the source that is causing the problem, so the TypeScript compiler is creating that code... I'm wondering about the import as the ESM module is used. How do you import ZXing into your project?