From 21e83d38deda982cbfff480af0cbb3aa159eee06 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Wed, 2 Aug 2023 14:25:22 +0200 Subject: [PATCH] fix: publish types * 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 --- .gitignore | 3 ++- package.json | 16 ++++++++++++---- src/BarcodeDetector.ts | 4 ++-- src/BarcodeDetectorJsqr.ts | 8 ++++---- src/BarcodeDetectorZXing.ts | 4 ++-- tsconfig.json | 8 ++++++++ 6 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 325e612..41b087f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/node_modules/ .DS_Store inline-worker.js -dist/ \ No newline at end of file +dist/ +*.tgz diff --git a/package.json b/package.json index 2f6a846..f551605 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -31,5 +33,11 @@ "devDependencies": { "microbundle": "^0.13.3", "semantic-release": "^17.4.3" - } + }, + "files": [ + "dist", + "example_codes", + "src", + "!src/worker/node_modules" + ] } diff --git a/src/BarcodeDetector.ts b/src/BarcodeDetector.ts index edf55aa..7e6ee10 100644 --- a/src/BarcodeDetector.ts +++ b/src/BarcodeDetector.ts @@ -1,3 +1,3 @@ -import BarcodeDetector from "./BarcodeDetectorJsqr" +import BarcodeDetector from "./BarcodeDetectorJsqr.js"; -export default BarcodeDetector \ No newline at end of file +export default BarcodeDetector diff --git a/src/BarcodeDetectorJsqr.ts b/src/BarcodeDetectorJsqr.ts index 33c790a..2cf807a 100644 --- a/src/BarcodeDetectorJsqr.ts +++ b/src/BarcodeDetectorJsqr.ts @@ -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" ] diff --git a/src/BarcodeDetectorZXing.ts b/src/BarcodeDetectorZXing.ts index af37add..843f14c 100644 --- a/src/BarcodeDetectorZXing.ts +++ b/src/BarcodeDetectorZXing.ts @@ -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([ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..3b35a5c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "ESNext", + "target": "ESNext" + }, + "include": ["src"], + "exclude": ["src/worker"] +}