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

TypeError: (0 , _bwipJs.qrcode) is not a function #334

Open
MarianoFacundoArch opened this issue May 6, 2024 · 10 comments
Open

TypeError: (0 , _bwipJs.qrcode) is not a function #334

MarianoFacundoArch opened this issue May 6, 2024 · 10 comments

Comments

@MarianoFacundoArch
Copy link

I am using version 4.3.2

However I get that qrcode and drawingSVG are undefined, the import I am using is:

import { qrcode, drawingSVG } from "bwip-js";
@metafloor
Copy link
Owner

Are you planning to provide some code to reproduce the issue?

@metafloor
Copy link
Owner

Actually, I think this is not a bwip-js issue but whatever bundler you are using. Is this typescript or some other framework?

@MarianoFacundoArch
Copy link
Author

Hi @metafloor ,
The code is what I provided,

import { qrcode, drawingSVG } from "bwip-js";
console.log(qrcode)

Returns undefined. drawingSVG exists, but not qrcode as if it was not exported.
I took the import from the readme that says to use

import { qrcode, drawingSVG } from 'bwip-js';

But qrcode is not exported?

@metafloor
Copy link
Owner

As I mentioned above, what platform/bundler/framework are you using? This is not a bwip-js error but a problem with the underlying framework.

@MarianoFacundoArch
Copy link
Author

Hi @metafloor ,
I am using parcel bundler

@metafloor
Copy link
Owner

You need to enable package.json exports:

https://parceljs.org/features/dependency-resolution/#enabling-package-exports

@MarianoFacundoArch
Copy link
Author

It completely breaks my code and stops working if I enable it.
Thank you though.
Isn't possible to proxy the export in the bwip-js directly so it works in any scenario? I am sure that would greatly benefit compatibility.

@MarianoFacundoArch
Copy link
Author

@metafloor Is this something we can do?

@metafloor
Copy link
Owner

metafloor commented May 7, 2024

Any kind of "proxy" would break static analysis and tree-shaking done by typescript and other bundlers. The exports map is how packages are supposed to structure their exports for modern build tools.

Is it possible to set per-package (per import) configuration settings with parcel? I had never heard of it before, so know nothing about it.

@MarianoFacundoArch
Copy link
Author

I can change my bundler and do more tests.
What bundlers have you tested with and work perfectly without any further config? Or if so, it is it documented on a per-packet basis?

Thanks
@metafloor

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

No branches or pull requests

2 participants