Skip to content

Commit d84d421

Browse files
fix: mismatched ethers types when in esm project
Fix mismatch of ethers/lib.commonjs Provider with ethers/lib.esm Provider. This has been an issue when attempting to construct configuration driven provider fallbacks for did-resolver Drilling down to the Provider type via this package within an esm package yielded a `lib.commonjs` `Provider` that did not match the esm ethers `Provider`. Restructure build directories into `lib.commonjs` and `lib.esm`. Matches structure in ethers.js Adjust .gitignore to exclude new out directories Separated into two tsconfig files named `tsconfig.{common,esm}.json` [package.json] Removed `source` [not in spec] Removed `type`, `module`, and `types` from top level Added `import` and `require` to `exports` and re-added `types` Modified `files` to point to new out dirs, removed LICENSE (included by default), and src (no utility). Modified script `clean` Added new `build:` scripts both called from `build`
1 parent df859be commit d84d421

File tree

6 files changed

+46
-50
lines changed

6 files changed

+46
-50
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
lib/
1+
lib.commonjs/
2+
lib.esm/
23

34
# Created by https://www.gitignore.io/api/node,linux,macos,windows,intellij
45
# Edit at https://www.gitignore.io/?templates=node,linux,macos,windows,intellij
@@ -224,4 +225,4 @@ $RECYCLE.BIN/
224225
# Windows shortcuts
225226
*.lnk
226227

227-
# End of https://www.gitignore.io/api/node,linux,macos,windows,intellij
228+
# End of https://www.gitignore.io/api/node,linux,macos,windows,intellij

esm/index.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

esm/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@
22
"name": "ethr-did-resolver",
33
"version": "11.0.4",
44
"description": "Resolve DID documents for ethereum addresses and public keys",
5-
"type": "commonjs",
6-
"source": "./src/index.ts",
7-
"main": "./lib/index.js",
8-
"module": "./esm/index.js",
9-
"types": "./lib/index.d.ts",
5+
"main": "./lib.commonjs/index.js",
106
"exports": {
11-
".": {
12-
"types": "./lib/index.d.ts",
13-
"import": "./esm/index.js",
14-
"require": "./lib/index.js"
7+
"import": {
8+
"types": "./lib.esm/index.d.ts",
9+
"default": "./lib.esm/index.js"
10+
},
11+
"require": {
12+
"types": "./lib.commonjs/index.d.ts",
13+
"default": "./lib.commonjs/index.js"
1514
}
1615
},
1716
"repository": {
1817
"type": "git",
1918
"url": "[email protected]:decentralized-identity/ethr-did-resolver.git"
2019
},
2120
"files": [
22-
"lib",
23-
"esm",
24-
"src",
25-
"LICENSE"
21+
"lib.commonjs",
22+
"lib.esm"
2623
],
2724
"author": "Pelle Braendgaard",
2825
"contributors": [
@@ -49,8 +46,10 @@
4946
"scripts": {
5047
"test": "jest",
5148
"test:ci": "jest --coverage",
52-
"build": "tsc",
53-
"clean": "rm -rf ./lib",
49+
"build": "yarn run build:common && yarn run build:esm",
50+
"build:common": "tsc --project tsconfig.common.json",
51+
"build:esm": "tsc --project tsconfig.esm.json",
52+
"clean": "rm -rf ./lib.commonjs ./lib.esm",
5453
"format": "prettier --write \"src/**/*.[jt]s\"",
5554
"lint": "eslint --ignore-pattern \"src/**/*.test.[jt]s\" \"src/**/*.[jt]s\"",
5655
"prepublishOnly": "yarn test:ci && yarn format && yarn lint",

tsconfig.json renamed to tsconfig.common.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"declaration": true,
1111
"declarationMap": true,
1212
"sourceMap": true,
13-
"outDir": "lib",
13+
"outDir": "lib.commonjs",
1414
"strict": true,
1515
"skipLibCheck": true,
1616
"noImplicitThis": false,
@@ -22,7 +22,8 @@
2222
"exclude": [
2323
"**/__tests__/*",
2424
"node_modules",
25-
"lib"
25+
"lib.commonjs",
26+
"lib.esm"
2627
],
2728
"include": [
2829
"src"

tsconfig.esm.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "nodenext",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"sourceMap": true,
8+
"outDir": "lib.esm",
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"noImplicitThis": false,
12+
"moduleResolution": "nodenext",
13+
"allowSyntheticDefaultImports": true,
14+
"resolveJsonModule": true,
15+
"esModuleInterop": true
16+
},
17+
"exclude": [
18+
"**/__tests__/*",
19+
"node_modules",
20+
"lib.commonjs",
21+
"lib.esm"
22+
],
23+
"include": [
24+
"src"
25+
]
26+
}

0 commit comments

Comments
 (0)