Skip to content

Commit

Permalink
Merge pull request #48 from ensdomains/fix/types
Browse files Browse the repository at this point in the history
hotfix: types
  • Loading branch information
TateB authored Sep 6, 2022
2 parents 5e79424 + fbf5417 commit f92715e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
run: pnpm -F @ensdomains/ensjs lint

- name: Type check
run: pnpm -F @ensdomains/ensjs exec tsc --project tsconfig.esm.json --noEmit --emitDeclarationOnly false
run: pnpm -F @ensdomains/ensjs exec tsc --project tsconfig.build.json --noEmit --emitDeclarationOnly false
24 changes: 22 additions & 2 deletions packages/ensjs/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const base = {
}),
],
bundle: false,
sourcemap: true,
sourcemap: false,
}

const esmDeclarations = glob.sync('./dist/esm/**/*.d.ts')
Expand All @@ -29,7 +29,9 @@ esbuild.build({
setup(build) {
build.onResolve({ filter: /.*/ }, (args) => {
if (args.importer) {
if (args.path.startsWith('./'))
if (args.path.startsWith('ethers/'))
return { path: args.path + '.js', external: true }
if (args.path.startsWith('./') || args.path.startsWith('../'))
return { path: args.path + '.mjs', external: true }
return { path: args.path, external: true }
}
Expand All @@ -47,6 +49,24 @@ esbuild.build({

esbuild.build({
...base,
plugins: [
{
name: 'add-js',
setup(build) {
build.onResolve({ filter: /.*/ }, (args) => {
if (args.importer) {
if (
args.path.startsWith('ethers/') ||
args.path.startsWith('./') ||
args.path.startsWith('../')
)
return { path: args.path + '.js', external: true }
return { path: args.path, external: true }
}
})
},
},
],
outdir: 'dist/cjs',
format: 'cjs',
target: ['esnext'],
Expand Down
42 changes: 29 additions & 13 deletions packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,41 @@
"version": "3.0.0-alpha.18",
"description": "ENS javascript library for contract interaction",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"module": "./dist/esm/index.mjs",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
"default": "./dist/esm/index.mjs"
},
"./utils/*": {
"import": "./dist/esm/utils/*",
"require": "./dist/cjs/utils/*",
"default": "./dist/esm/utils/*"
"./*.js": {
"import": "./dist/esm/*.mjs",
"require": "./dist/cjs/*.js",
"default": "./dist/esm/*.mjs"
},
"./functions/*": {
"import": "./dist/esm/functions/*",
"require": "./dist/cjs/functions/*",
"default": "./dist/esm/functions/*"
"./*.mjs": {
"import": "./dist/esm/*.mjs",
"require": "./dist/cjs/*.js",
"default": "./dist/esm/*.mjs"
},
"./*": {
"default": "./*"
"import": "./dist/esm/*.mjs",
"require": "./dist/cjs/*.js",
"default": "./dist/esm/*.mjs"
}
},
"typesVersions": {
"*": {
"contracts/*": [
"./dist/types/contracts/*"
],
"functions/*": [
"./dist/types/functions/*"
],
"utils/*": [
"./dist/types/utils/*"
]
}
},
"files": [
Expand All @@ -43,7 +59,7 @@
"test:specific": "ts-node --files ",
"clean": "rm -rf ./dist ./README.md ./LICENSE",
"lint": "eslint ./src/* --no-error-on-unmatched-pattern",
"build:types": "tsc --emitDeclarationOnly --project tsconfig.cjs.json && tsc --emitDeclarationOnly --project tsconfig.esm.json",
"build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json",
"build": "pnpm clean && pnpm lint && pnpm build:types && pnpm node esbuild.js",
"prepublish": "pnpm build && cp ../../README.md ../../LICENSE ./",
"enode": "ganache --wallet.mnemonic=\"test test test test test test test test test test test junk\" --chain.chainId 1337 --chain.networkId 1337 --chain.time 1659500634000",
Expand Down
2 changes: 1 addition & 1 deletion packages/ensjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { JsonRpcSigner } from '@ethersproject/providers'
import { ContractTransaction, ethers, PopulatedTransaction } from 'ethers'
import ContractManager from './contracts'
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress'
import ContractManager from './contracts/index'
import { SupportedNetworkId } from './contracts/types'
import type batch from './functions/batch'
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "dist/esm",
"outDir": "dist/types",
"declaration": true,
"emitDeclarationOnly": true
},
Expand Down
12 changes: 0 additions & 12 deletions packages/ensjs/tsconfig.cjs.json

This file was deleted.

0 comments on commit f92715e

Please sign in to comment.