JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

Module export problem

Open fengyuanchen opened this issue 7 years ago • 5 comments

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'; 

fengyuanchen avatar Apr 28 '17 09:04 fengyuanchen

After some tests, I found that it may be the problem of the last line in the JsBarcode.js:

module.exports = JsBarcode;

fengyuanchen avatar Apr 28 '17 09:04 fengyuanchen

@fengyuanchen hi. Have you tried this?

import { JsBarcode } from 'jsbarcode/src/JsBarcode';
// or
import * as JsBarcode from 'jsbarcode/src/JsBarcode';

SanichKotikov avatar May 13 '17 14:05 SanichKotikov

@SanichKotikov I had tried that, not work too.

fengyuanchen avatar May 14 '17 06:05 fengyuanchen

try to add "allowSyntheticDefaultImports": true, to your tsconfig.json file. it worked for me

yacaeh avatar Feb 22 '20 09:02 yacaeh

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.

0xE1 avatar Aug 23 '23 22:08 0xE1