From d2bbeafbd2d77308f12d73f952b0b9940431dd83 Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Thu, 13 Oct 2022 14:39:06 +0200 Subject: [PATCH] fix: add esm wrapper instead of double transpile BREAKING CHANGE: ESM is only supported through a wrapper --- esm/index.js | 3 ++ esm/package.json | 3 ++ package.json | 17 ++++++----- src/__tests__/nonce.test.ts | 60 +++++++++++++------------------------ 4 files changed, 36 insertions(+), 47 deletions(-) create mode 100644 esm/index.js create mode 100644 esm/package.json diff --git a/esm/index.js b/esm/index.js new file mode 100644 index 00000000..526d4507 --- /dev/null +++ b/esm/index.js @@ -0,0 +1,3 @@ +import cjsModule from '../lib/index.js'; + +export default cjsModule diff --git a/esm/package.json b/esm/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/esm/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/package.json b/package.json index bc27bef8..10bb2ce6 100644 --- a/package.json +++ b/package.json @@ -3,16 +3,15 @@ "version": "6.2.4-alpha.1", "description": "Resolve DID documents for ethereum addresses and public keys", "type": "module", - "source": "src/index.ts", - "main": "./lib/index.cjs", - "module": "./lib/index.module.js", - "unpkg": "./lib/index.umd.js", + "source": "./src/index.ts", + "main": "./lib/index.js", + "module": "./esm/index.js", "types": "./lib/index.d.ts", - "umd:main": "./lib/index.umd.js", "exports": { ".": { - "require": "./lib/index.cjs", - "import": "./lib/index.modern.js" + "types": "./lib/index.d.ts", + "import": "./esm/index.js", + "require": "./lib/index.js" } }, "typesVersions": { @@ -31,6 +30,7 @@ }, "files": [ "lib", + "esm", "src", "LICENSE" ], @@ -59,7 +59,8 @@ "scripts": { "test": "jest", "test:ci": "jest --coverage", - "build": "microbundle --compress=false", + "build": "tsc", + "clean": "rm -rf ./lib", "format": "prettier --write \"src/**/*.[jt]s\"", "lint": "eslint --ignore-pattern \"src/**/*.test.[jt]s\" \"src/**/*.[jt]s\"", "prepublishOnly": "yarn test:ci && yarn format && yarn lint", diff --git a/src/__tests__/nonce.test.ts b/src/__tests__/nonce.test.ts index 93f3ce67..e1deef33 100644 --- a/src/__tests__/nonce.test.ts +++ b/src/__tests__/nonce.test.ts @@ -87,26 +87,20 @@ describe('nonce tracking', () => { const hash = await ethrController.createChangeOwnerHash(nextOwner) const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash) - await ethrController.changeOwnerSigned( - nextOwner, - { - sigV: signature.v, - sigR: signature.r, - sigS: signature.s, - } - ) + await ethrController.changeOwnerSigned(nextOwner, { + sigV: signature.v, + sigR: signature.r, + sigS: signature.s, + }) const hash2 = await ethrController.createChangeOwnerHash(finalOwner) const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2) - await ethrController.changeOwnerSigned( - finalOwner, - { - sigV: signature2.v, - sigR: signature2.r, - sigS: signature2.s, - } - ) + await ethrController.changeOwnerSigned(finalOwner, { + sigV: signature2.v, + sigR: signature2.r, + sigS: signature2.s, + }) const originalNonce = await registryContract.functions.nonce(originalOwner) const signerNonce = await registryContract.functions.nonce(nextOwner) @@ -143,32 +137,20 @@ describe('nonce tracking', () => { const hash = await ethrController.createChangeOwnerHash(nextOwner) const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash) - await ethrController.changeOwnerSigned( - nextOwner, - { - sigV: signature.v, - sigR: signature.r, - sigS: signature.s, - } - ) + await ethrController.changeOwnerSigned(nextOwner, { + sigV: signature.v, + sigR: signature.r, + sigS: signature.s, + }) - const hash2 = await ethrController.createSetAttributeHash( - attributeName, - attributeValue, - attributeExpiration - ) + const hash2 = await ethrController.createSetAttributeHash(attributeName, attributeValue, attributeExpiration) const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2) - await ethrController.setAttributeSigned( - attributeName, - attributeValue, - attributeExpiration, - { - sigV: signature2.v, - sigR: signature2.r, - sigS: signature2.s, - } - ) + await ethrController.setAttributeSigned(attributeName, attributeValue, attributeExpiration, { + sigV: signature2.v, + sigR: signature2.r, + sigS: signature2.s, + }) const originalNonce = await registryContract.functions.nonce(originalOwner) const signerNonce = await registryContract.functions.nonce(nextOwner)