cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.67k stars 606 forks source link

ES6 Module support #111

Open rjcorwin opened 5 years ago

rjcorwin commented 5 years ago

I'm importing this library into a Polyer 3 Web Component which uses rollup for module path resolution and expects the modules to be in ES 6 module standard. I see dist/jsQR.js uses webpackUniversalModuleDefinition which sounds cool unless you're not in a Webpack setup :).

rjcorwin commented 5 years ago

Ah, interesting... import * as jsQR from "jsqr"; works.

rjcorwin commented 5 years ago

No wait, ok it imports something but not what we want.

screen shot 2019-02-02 at 12 43 55 pm
rjcorwin commented 5 years ago

Trying to build it from TS source I get...

➜  jsQR git:(master) ✗ tsc --target es6 --module es6
src/decoder/decoder.ts:3:49 - error TS2307: Cannot find module './decodeData'.

3 import { decode as decodeData, DecodedQR } from "./decodeData";
                                                  ~~~~~~~~~~~~~~

src/decoder/decoder.ts:4:36 - error TS2307: Cannot find module './reedsolomon'.

4 import { decode as rsDecode } from "./reedsolomon";
                                     ~~~~~~~~~~~~~~~

src/index.ts:1:24 - error TS2307: Cannot find module './binarizer'.

1 import {binarize} from "./binarizer";
                         ~~~~~~~~~~~~~

src/index.ts:3:22 - error TS2307: Cannot find module './decoder/decodeData'.

3 import {Chunks} from "./decoder/decodeData";
                       ~~~~~~~~~~~~~~~~~~~~~~

src/index.ts:5:23 - error TS2307: Cannot find module './extractor'.

5 import {extract} from "./extractor";
                        ~~~~~~~~~~~~~

src/index.ts:6:29 - error TS2307: Cannot find module './locator'.

6 import {locate, Point} from "./locator";
                              ~~~~~~~~~~~

Found 6 errors.
rjcorwin commented 5 years ago

I'm a n00b when it comes to configuring tsc, I must be doing something wrong.