Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SemVer cyclic dependency issues with some hacks #209

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
**/dist
**/.eslintrc.js
**/jest.config.ts
**/babel.config.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@types/whatwg-url": "^6.4.0",
"@typescript-eslint/eslint-plugin": "~3.4.0",
"auto": "^10.31.0",
"babel-jest": "^27.0.6",
"chalk": "~4.1.2",
"eslint": "~7.3.1",
"eslint-import-resolver-typescript": "~2.0.0",
Expand Down Expand Up @@ -72,7 +73,7 @@
]
},
"resolutions": {
"@rollup/plugin-commonjs": "18.1.0"
"@rollup/plugin-commonjs": "^17.0.0"
},
"repository": "magiclabs/magic-js",
"author": "Magic Labs <team@magic.link>",
Expand Down
7 changes: 7 additions & 0 deletions packages/@magic-sdk/provider/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
13 changes: 12 additions & 1 deletion packages/@magic-sdk/provider/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export { default } from '../../../jest.config';
import baseJestConfig from '../../../jest.config';
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
...baseJestConfig,
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
'\\.(ts|tsx)$': 'ts-jest',
},
};

export default config;
3 changes: 1 addition & 2 deletions packages/@magic-sdk/provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
"module": "./dist/es/index.js",
"types": "./dist/types/index.d.ts",
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/plugin-transform-runtime": "^7.9.6",
"@peculiar/webcrypto": "^1.1.7",
"@types/semver": "^7.3.4",
"eventemitter3": "^4.0.4",
"localforage": "^1.7.4",
"localforage-driver-memory": "^1.0.5",
"semver": "^7.3.2",
"tslib": "^2.3.1",
"web3-core": "1.5.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-sdk/provider/src/core/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { EthNetworkConfiguration, QueryParameters, SupportedLocale } from '@magic-sdk/types';
import type { AbstractProvider } from 'web3-core';
import { SemVer, coerce, satisfies } from '../util/semver';
import { coerce, satisfies } from '../util/semver';
import { encodeJSON } from '../util/base64-json';
import {
createMissingApiKeyError,
Expand All @@ -25,7 +25,7 @@ import { SDKEnvironment, sdkNameToEnvName } from './sdk-environment';
function checkExtensionCompat(ext: Extension<string>) {
if (ext.compat && ext.compat[SDKEnvironment.sdkName] != null) {
return typeof ext.compat[SDKEnvironment.sdkName] === 'string'
? satisfies(coerce(SDKEnvironment.version) as SemVer, ext.compat[SDKEnvironment.sdkName] as string)
? satisfies(coerce(SDKEnvironment.version), ext.compat[SDKEnvironment.sdkName] as string)
: !!ext.compat[SDKEnvironment.sdkName];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@magic-sdk/provider/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from './base64-json';
export * from './events';
export * from './get-payload-id';
export * from './promise-tools';
export * from './semver';
export * as semver from './semver';
export * as storage from './storage';
export * from './type-guards';
export * from './url';
Expand Down
15 changes: 15 additions & 0 deletions packages/@magic-sdk/provider/src/util/semver.js

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions packages/@magic-sdk/provider/src/util/semver.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/@magic-sdk/react-native/babel.config.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/@magic-sdk/react-native/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": ["@babel/plugin-transform-flow-strip-types"]
}
23 changes: 12 additions & 11 deletions packages/@magic-sdk/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,30 @@
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"types": "./dist/types/index.d.ts",
"devDependencies": {
"dependencies": {
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
"@babel/core": "~7.10.4",
"@babel/plugin-transform-flow-strip-types": "^7.14.5",
"@babel/runtime": "~7.10.4",
"@magic-sdk/commons": "^2.0.0",
"@magic-sdk/provider": "^6.0.0",
"@magic-sdk/types": "^5.0.0",
"@react-native-async-storage/async-storage": "^1.15.5",
"@types/lodash": "^4.14.158",
"babel-jest": "^27.0.6",
"buffer": "~5.6.0",
"localforage": "^1.7.4",
"localforage-driver-memory": "^1.0.5",
"lodash": "^4.17.19",
"metro-react-native-babel-preset": "^0.66.2",
"process": "~0.11.10",
"react": "^16.13.1",
"react-native": "^0.62.2",
"react-native-webview": "8.1.2",
"tslib": "^2.0.3",
"whatwg-url": "~8.1.0"
},
"dependencies": {
"@magic-sdk/commons": "^2.0.0",
"@magic-sdk/provider": "^6.0.0",
"@magic-sdk/types": "^5.0.0"
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-transform-flow-strip-types": "^7.14.5",
"metro-react-native-babel-preset": "^0.66.2",
"react": "^16.13.1",
"react-native": "^0.62.2",
"react-native-webview": "8.1.2"
},
"peerDependencies": {
"react": ">=16",
Expand Down
File renamed without changes.
85 changes: 27 additions & 58 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/core@npm:7.15.5, @babel/core@npm:^7.12.10":
"@babel/core@npm:7.15.5, @babel/core@npm:^7.12.10, @babel/core@npm:^7.15.0":
version: 7.15.5
resolution: "@babel/core@npm:7.15.5"
dependencies:
Expand Down Expand Up @@ -215,30 +215,6 @@ __metadata:
languageName: node
linkType: hard

"@babel/core@npm:~7.10.4":
version: 7.10.5
resolution: "@babel/core@npm:7.10.5"
dependencies:
"@babel/code-frame": ^7.10.4
"@babel/generator": ^7.10.5
"@babel/helper-module-transforms": ^7.10.5
"@babel/helpers": ^7.10.4
"@babel/parser": ^7.10.5
"@babel/template": ^7.10.4
"@babel/traverse": ^7.10.5
"@babel/types": ^7.10.5
convert-source-map: ^1.7.0
debug: ^4.1.0
gensync: ^1.0.0-beta.1
json5: ^2.1.2
lodash: ^4.17.19
resolve: ^1.3.2
semver: ^5.4.1
source-map: ^0.5.0
checksum: 30e479edc6b5f505a6e6b8331ff135192a28bdb9ccf3ed9fa91d0da5817523ea1594d6ded6e5077fd043f27ebc9037cce973c57f33a6284d9f344d1dc94ba303
languageName: node
linkType: hard

"@babel/generator@npm:^7.10.4, @babel/generator@npm:^7.4.0, @babel/generator@npm:^7.5.0":
version: 7.10.4
resolution: "@babel/generator@npm:7.10.4"
Expand All @@ -251,7 +227,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/generator@npm:^7.10.5, @babel/generator@npm:^7.15.0, @babel/generator@npm:^7.7.2":
"@babel/generator@npm:^7.15.0, @babel/generator@npm:^7.7.2":
version: 7.15.0
resolution: "@babel/generator@npm:7.15.0"
dependencies:
Expand Down Expand Up @@ -637,7 +613,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-module-transforms@npm:^7.10.5, @babel/helper-module-transforms@npm:^7.14.5, @babel/helper-module-transforms@npm:^7.15.0":
"@babel/helper-module-transforms@npm:^7.14.5, @babel/helper-module-transforms@npm:^7.15.0":
version: 7.15.0
resolution: "@babel/helper-module-transforms@npm:7.15.0"
dependencies:
Expand Down Expand Up @@ -984,7 +960,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.10.5, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.15.0, @babel/parser@npm:^7.7.2":
"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.15.0, @babel/parser@npm:^7.7.2":
version: 7.15.2
resolution: "@babel/parser@npm:7.15.2"
bin:
Expand Down Expand Up @@ -1947,7 +1923,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-modules-commonjs@npm:^7.15.4":
"@babel/plugin-transform-modules-commonjs@npm:^7.15.4, @babel/plugin-transform-modules-commonjs@npm:^7.9.6":
version: 7.15.4
resolution: "@babel/plugin-transform-modules-commonjs@npm:7.15.4"
dependencies:
Expand Down Expand Up @@ -2624,7 +2600,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.10.5, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.14.5, @babel/traverse@npm:^7.14.8, @babel/traverse@npm:^7.15.0, @babel/traverse@npm:^7.7.2":
"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.14.5, @babel/traverse@npm:^7.14.8, @babel/traverse@npm:^7.15.0, @babel/traverse@npm:^7.7.2":
version: 7.15.0
resolution: "@babel/traverse@npm:7.15.0"
dependencies:
Expand Down Expand Up @@ -2669,7 +2645,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/types@npm:^7.10.5, @babel/types@npm:^7.14.5, @babel/types@npm:^7.14.8, @babel/types@npm:^7.14.9, @babel/types@npm:^7.15.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3":
"@babel/types@npm:^7.14.5, @babel/types@npm:^7.14.8, @babel/types@npm:^7.14.9, @babel/types@npm:^7.15.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3":
version: 7.15.0
resolution: "@babel/types@npm:7.15.0"
dependencies:
Expand Down Expand Up @@ -4142,30 +4118,29 @@ __metadata:
languageName: node
linkType: hard

"@magic-sdk/commons@^1.2.1, @magic-sdk/commons@workspace:packages/@magic-sdk/commons":
"@magic-sdk/commons@^2.0.0, @magic-sdk/commons@workspace:packages/@magic-sdk/commons":
version: 0.0.0-use.local
resolution: "@magic-sdk/commons@workspace:packages/@magic-sdk/commons"
dependencies:
"@magic-sdk/provider": ">=4.3.0"
"@magic-sdk/types": ">=3.1.1"
"@magic-sdk/provider": ^6.0.0
"@magic-sdk/types": ^5.0.0
peerDependencies:
"@magic-sdk/provider": ">=4.3.0"
"@magic-sdk/types": ">=3.1.1"
languageName: unknown
linkType: soft

"@magic-sdk/provider@>=4.3.0, @magic-sdk/provider@^5.1.0, @magic-sdk/provider@workspace:packages/@magic-sdk/provider":
"@magic-sdk/provider@^6.0.0, @magic-sdk/provider@workspace:packages/@magic-sdk/provider":
version: 0.0.0-use.local
resolution: "@magic-sdk/provider@workspace:packages/@magic-sdk/provider"
dependencies:
"@babel/plugin-transform-modules-commonjs": ^7.9.6
"@babel/plugin-transform-runtime": ^7.9.6
"@magic-sdk/types": ^4.0.0
"@magic-sdk/types": ^5.0.0
"@peculiar/webcrypto": ^1.1.7
"@types/semver": ^7.3.4
eventemitter3: ^4.0.4
localforage: ^1.7.4
localforage-driver-memory: ^1.0.5
semver: ^7.3.2
tslib: ^2.3.1
web3-core: 1.5.2
peerDependencies:
Expand All @@ -4178,15 +4153,14 @@ __metadata:
resolution: "@magic-sdk/react-native@workspace:packages/@magic-sdk/react-native"
dependencies:
"@aveq-research/localforage-asyncstorage-driver": ^3.0.1
"@babel/core": ~7.10.4
"@babel/core": ^7.15.0
"@babel/plugin-transform-flow-strip-types": ^7.14.5
"@babel/runtime": ~7.10.4
"@magic-sdk/commons": ^1.2.1
"@magic-sdk/provider": ^5.1.0
"@magic-sdk/types": ^4.0.0
"@magic-sdk/commons": ^2.0.0
"@magic-sdk/provider": ^6.0.0
"@magic-sdk/types": ^5.0.0
"@react-native-async-storage/async-storage": ^1.15.5
"@types/lodash": ^4.14.158
babel-jest: ^27.0.6
buffer: ~5.6.0
localforage: ^1.7.4
localforage-driver-memory: ^1.0.5
Expand All @@ -4196,6 +4170,7 @@ __metadata:
react: ^16.13.1
react-native: ^0.62.2
react-native-webview: 8.1.2
tslib: ^2.0.3
whatwg-url: ~8.1.0
peerDependencies:
react: ">=16"
Expand All @@ -4204,7 +4179,7 @@ __metadata:
languageName: unknown
linkType: soft

"@magic-sdk/types@>=3.1.1, @magic-sdk/types@^4.0.0, @magic-sdk/types@workspace:packages/@magic-sdk/types":
"@magic-sdk/types@^5.0.0, @magic-sdk/types@workspace:packages/@magic-sdk/types":
version: 0.0.0-use.local
resolution: "@magic-sdk/types@workspace:packages/@magic-sdk/types"
languageName: unknown
Expand Down Expand Up @@ -4720,9 +4695,9 @@ __metadata:
languageName: node
linkType: hard

"@rollup/plugin-commonjs@npm:18.1.0":
version: 18.1.0
resolution: "@rollup/plugin-commonjs@npm:18.1.0"
"@rollup/plugin-commonjs@npm:^17.0.0":
version: 17.1.0
resolution: "@rollup/plugin-commonjs@npm:17.1.0"
dependencies:
"@rollup/pluginutils": ^3.1.0
commondir: ^1.0.1
Expand All @@ -4733,7 +4708,7 @@ __metadata:
resolve: ^1.17.0
peerDependencies:
rollup: ^2.30.0
checksum: 7bb553119b0dcc1860e1c0b74ccc81b9519f5163c15660649191622e5911c6d3a1b1ecd743c510dcc28b8c88cd6c3df4776131a384719b9502328ff5f30cb8d6
checksum: b83f05c7923ecc0f946eef3ef63b7cde090a7205b06aa7f43d29c06823c9848243691f4a799da9d6f07fb4915a9b12c66261c60913ea6f48441ff0715fb689a9
languageName: node
linkType: hard

Expand Down Expand Up @@ -5189,13 +5164,6 @@ __metadata:
languageName: node
linkType: hard

"@types/semver@npm:^7.3.4":
version: 7.3.4
resolution: "@types/semver@npm:7.3.4"
checksum: 577dc7f607fbf46cf185f61ba726e4cfecea41c4b17e55069e70a64b6cd92658f8286aa075a607303455658e87ed045d3d14c32a513c0eff381d64aecd7b72a7
languageName: node
linkType: hard

"@types/stack-utils@npm:^1.0.1":
version: 1.0.1
resolution: "@types/stack-utils@npm:1.0.1"
Expand Down Expand Up @@ -13734,6 +13702,7 @@ fsevents@^1.2.7:
"@types/whatwg-url": ^6.4.0
"@typescript-eslint/eslint-plugin": ~3.4.0
auto: ^10.31.0
babel-jest: ^27.0.6
chalk: ~4.1.2
eslint: ~7.3.1
eslint-import-resolver-typescript: ~2.0.0
Expand Down Expand Up @@ -13778,9 +13747,9 @@ fsevents@^1.2.7:
"@babel/core": ^7.9.6
"@babel/plugin-proposal-optional-chaining": ^7.9.0
"@babel/runtime": ^7.9.6
"@magic-sdk/commons": ^1.2.1
"@magic-sdk/provider": ^5.1.0
"@magic-sdk/types": ^4.0.0
"@magic-sdk/commons": ^2.0.0
"@magic-sdk/provider": ^6.0.0
"@magic-sdk/types": ^5.0.0
localforage: ^1.7.4
localforage-driver-memory: ^1.0.5
languageName: unknown
Expand Down