Skip to content

Commit

Permalink
fix(build): include default export to work around some bundler issues (
Browse files Browse the repository at this point in the history
…#205)

* fix(build): include default export to work around some bundler issues

fixes #186

* chore(build): upgrade linters

* chore: specify extension for relative imports
  • Loading branch information
mirceanis authored Sep 30, 2024
1 parent c5b4d33 commit 1e9e4ef
Show file tree
Hide file tree
Showing 14 changed files with 2,726 additions and 6,135 deletions.
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

40 changes: 40 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import jest from "eslint-plugin-jest";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
jest,
},

languageOptions: {
globals: {
...globals.node,
...jest.environments.globals.globals,
},

parser: tsParser,
ecmaVersion: 2020,
sourceType: "module",
},

rules: {},
}];
40 changes: 40 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defaults } from 'jest-config'

// @type {import('jest-config').InitialOptions}
const config = {
rootDir: './',
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mts'],
collectCoverage: false,
collectCoverageFrom: [
'packages/**/src/**/*.ts',
'!**/examples/**',
'!packages/cli/**',
'!**/types/**',
'!**/build/**',
'!**/node_modules/**',
'!packages/test-react-app/**',
'!packages/test-utils/**',
],
coverageReporters: ['json'],
coverageDirectory: './coverage',
coverageProvider: 'v8',
testMatch: ['**/__tests__/**/*.test.ts'],
automock: false,
// // typescript 5 removes the need to specify relative imports as .js, so we should no longer need this workaround
// // but webpack still requires .js specifiers, so we are keeping it for now
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
extensionsToTreatAsEsm: ['.ts'],
testEnvironment: 'node',
}

export default config
38 changes: 9 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
"require": "./lib/index.js"
}
},
"typesVersions": {
"*": {
"lib/index.d.ts": [
"lib/index.d.ts"
],
"*": [
"./lib/index.d.js"
]
}
},
"repository": {
"type": "git",
"url": "[email protected]:decentralized-identity/ethr-did-resolver.git"
Expand All @@ -36,7 +26,7 @@
],
"author": "Pelle Braendgaard",
"contributors": [
"Mircea Nistor <[email protected]>"
"Mircea Nistor"
],
"license": "Apache-2.0",
"keywords": [
Expand Down Expand Up @@ -66,42 +56,32 @@
"prepublishOnly": "yarn test:ci && yarn format && yarn lint",
"release": "semantic-release --debug"
},
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
"!src/**/*.d.ts",
"!**/node_modules/**",
"!**/__tests__/**"
],
"testEnvironment": "node",
"testMatch": [
"**/__tests__/**/*.test.[jt]s"
]
},
"devDependencies": {
"@babel/core": "7.25.2",
"@babel/preset-env": "7.25.4",
"@babel/preset-typescript": "7.24.7",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@ethers-ext/provider-ganache": "6.0.0-beta.2",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/jest": "29.5.12",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@typescript-eslint/eslint-plugin": "8.7.0",
"@typescript-eslint/parser": "8.7.0",
"babel-jest": "29.7.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "27.9.0",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
"microbundle": "0.15.1",
"prettier": "3.3.3",
"semantic-release": "22.0.12",
"ts-jest": "^29.2.5",
"typescript": "5.5.4"
},
"dependencies": {
"did-resolver": "^4.1.0",
"ethers": "^6.8.1"
}
},
"packageManager": "[email protected]"
}
27 changes: 0 additions & 27 deletions src/__tests__/networks.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,6 @@ describe('ethrResolver (alt-chains)', () => {
})
})

it('resolves on linea:goerli when configured', async () => {
const did = 'did:ethr:linea:goerli:' + addr
const ethr = getResolver({
infuraProjectId: '6b734e0b04454df8a6ce234023c04f26',
})
const resolver = new Resolver(ethr)
const result = await resolver.resolve(did)
expect(result).toEqual({
didDocumentMetadata: {},
didResolutionMetadata: { contentType: 'application/did+ld+json' },
didDocument: {
'@context': expect.anything(),
id: did,
verificationMethod: [
{
id: `${did}#controller`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: `eip155:59140:${checksumAddr}`,
},
],
authentication: [`${did}#controller`],
assertionMethod: [`${did}#controller`],
},
})
})

it('resolves on sepolia when configured', async () => {
const did = 'did:ethr:sepolia:' + addr
const ethr = getResolver({
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Contract, ContractFactory, ethers, SigningKey, Wallet } from 'ethers'
import { GanacheProvider } from '@ethers-ext/provider-ganache'
import { Resolver } from 'did-resolver'
import { getResolver } from '../resolver'
import { default as EthereumDIDRegistry } from '../config/EthereumDIDRegistry.json'
import { EthereumDIDRegistry } from '../config/EthereumDIDRegistry'

export async function deployRegistry(): Promise<{
registryContract: Contract
Expand Down
Loading

0 comments on commit 1e9e4ef

Please sign in to comment.