Import part of the library in Typescript
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
First of all, thanks for the awesome library !
Is there a way to import a section of the library ? I'm integrating JsBarcode in a widget, and JsBarcode ends up taking more space than my source code.
I'd like to either be able to import like such:
`import { Code128 } from 'jsbarcode';`
Or be able to use the minified versions for the web:
JsBarcode.code128.min.js
I tried importing JsBarcode.code128.min.js with the following statements:
`import * as JsBarcode from './JsBarcode.code128.min.js'`
`import JsBarcode from './JsBarcode.code128.min.js'`
But the first gives a {} object, and the second makes the compiler fail with a `Error: 'default' is not exported by ./JsBarcode.code128.min.js`.
What's the best way to go about that ?
I'm using Rollup.js to bundle everything into a single file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the JsBarcode.code128.min.js entry point and how Rollup.js handles the two import forms shown in the issue. Done means a consumer can import only the Code128 section or successfully import the minified browser module without the reported empty-object or missing-default-export errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rollup, typescript
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100