lindell / lindell/JsBarcode

Import part of the library in Typescript

Open
#247 4 comments 4 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.