Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
fix: publish types
Browse files Browse the repository at this point in the history
* Ignore *.tgz files
* Add extensions to import paths
* Add tsconfig.json to help microbundle decide what types to add
* Fix incorrect order of exports, add main types entry to package.json
* Don't include .github and test directories when packing

Closes #10
  • Loading branch information
wojtekmaj authored Aug 2, 2023
1 parent 0fe0e64 commit 21e83d3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/node_modules/
.DS_Store
inline-worker.js
dist/
dist/
*.tgz
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"main": "dist/barcode-detector.js",
"exports": {
".": {
"import": "./dist/barcode-detector.js",
"types": "./dist/BarcodeDetector.d.ts"
"types": "./dist/BarcodeDetector.d.ts",
"import": "./dist/barcode-detector.mjs",
"require": "./dist/barcode-detector.js"
}
},
"module": "dist/barcode-detector.module.js",
"types": "dist/BarcodeDetector.d.ts",
"module": "dist/barcode-detector.mjs",
"unpkg": "dist/barcode-detector.umd.js",
"amdName": "BarcodeDetectorPolyfill",
"scripts": {
Expand All @@ -31,5 +33,11 @@
"devDependencies": {
"microbundle": "^0.13.3",
"semantic-release": "^17.4.3"
}
},
"files": [
"dist",
"example_codes",
"src",
"!src/worker/node_modules"
]
}
4 changes: 2 additions & 2 deletions src/BarcodeDetector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import BarcodeDetector from "./BarcodeDetectorJsqr"
import BarcodeDetector from "./BarcodeDetectorJsqr.js";

export default BarcodeDetector
export default BarcodeDetector
8 changes: 4 additions & 4 deletions src/BarcodeDetectorJsqr.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// spec: https://wicg.github.io/shape-detection-api/#barcode-detection-api

import { BarcodeDetectorOptions, BarcodeFormat, DetectedBarcode } from "./basic-types"
import { imageDataFrom } from "./image-data"
import SleepyWorker from "./SleepyWorker"
import inlineWorkerCode from "./worker/inline-worker"
import { BarcodeDetectorOptions, BarcodeFormat, DetectedBarcode } from "./basic-types.js"
import { imageDataFrom } from "./image-data.js"
import SleepyWorker from "./SleepyWorker.js"
import inlineWorkerCode from "./worker/inline-worker.js"

const allSupportedFormats : BarcodeFormat[] = [ "qr_code" ]

Expand Down
4 changes: 2 additions & 2 deletions src/BarcodeDetectorZXing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// spec: https://wicg.github.io/shape-detection-api/#barcode-detection-api

import { BarcodeDetectorOptions, BarcodeFormat, DetectedBarcode } from "./basic-types"
import { imageDataFrom } from "./image-data"
import { BarcodeDetectorOptions, BarcodeFormat, DetectedBarcode } from "./basic-types.js"
import { imageDataFrom } from "./image-data.js"
import * as ZXing from "@zxing/library"

const mapFormat = new Map<BarcodeFormat, ZXing.BarcodeFormat>([
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext"
},
"include": ["src"],
"exclude": ["src/worker"]
}

0 comments on commit 21e83d3

Please sign in to comment.