JsBarcode
JsBarcode copied to clipboard
Module export problem
In order to get a more small size of bundle file, I include the original JsBarcode library from src/JsBarcode.js
, but get the following error:
🚨 'default' is not exported by node_modules\jsbar
https://github.com/rollup/rollup/wiki/Troubleshootin
dule
src\index.js (1:7)
1: import JsBarcode from 'jsbarcode/src/JsBarcode';
After some tests, I found that it may be the problem of the last line in the JsBarcode.js:
module.exports = JsBarcode;
@fengyuanchen hi. Have you tried this?
import { JsBarcode } from 'jsbarcode/src/JsBarcode';
// or
import * as JsBarcode from 'jsbarcode/src/JsBarcode';
@SanichKotikov I had tried that, not work too.
try to add "allowSyntheticDefaultImports": true
, to your tsconfig.json
file. it worked for me
Can't import in Chrome browser if using it in ServiceWorker, tried
import "./JsBarcode.all.js";
import * as JsBarcode from "./JsBarcode.all.js";
import JsBarcode from "./JsBarcode.all.js";
It would have worked if there was a UDM module variant.