Skip to content

Commit

Permalink
feat: Support ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Diaz committed Aug 4, 2020
1 parent 64bb0da commit 2955830
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "@airgap/beacon-sdk",
"version": "1.1.0",
"description": "The beacon-sdk allows you to easily connect DApps with Wallets through P2P communication or a chrome extension.",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"unpkg": "dist/beacon.min.js",
"types": "dist/index.d.ts",
"types": "dist/cjs/index.d.ts",
"keywords": [
"airgap",
"beacon",
Expand All @@ -22,8 +23,8 @@
"url": "https://github.com/airgap-it/beacon-sdk"
},
"scripts": {
"build": "tsc && npm run browserify",
"browserify": "browserify ./dist/index.js -s beacon | uglifyjs > ./dist/beacon.min.js",
"build": "tsc -p tsconfig.json && tsc -p ./tsconfig-cjs.json && npm run browserify",
"browserify": "browserify ./dist/cjs/index.js -s beacon | uglifyjs > ./dist/beacon.min.js",
"prettier": "prettier --write 'src/**/*' 'docs/**/*.md'",
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "eslint 'src/**/*.ts' --fix",
Expand All @@ -35,7 +36,7 @@
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"docs:deploy": "./deploy-docs.sh",
"check-version": "ts-node scripts/check-sdk-version.ts"
"check-version": "ts-node --project tsconfig-cjs.json scripts/check-sdk-version.ts"
},
"author": "Papers GmbH <[email protected]> (https://papers.ch)",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/qr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as qrcode from 'qrcode-generator'
import qrcode from 'qrcode-generator'

export const getQrData = (payload: string, type?: 'data' | 'svg' | 'ascii'): string => {
const typeNumber: TypeNumber = 0
Expand Down
8 changes: 8 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist/cjs"
}
}
8 changes: 5 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"target": "ES2015",
"lib": ["es2015", "es2017.string", "dom"],
"module": "commonjs",
"module": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true,
"outDir": "./dist",
"outDir": "./dist/esm",
"typeRoots": ["./node_modules/@types", "./src/typings"],
"sourceMap": true,
/* Strict Type-Checking Options */
Expand Down

0 comments on commit 2955830

Please sign in to comment.