Adjust detectPackage for direct dependencies (#3227)

* Dependency detection

* packageInfo imports

* Dependency array

* Bump common

* Remove detectPackage comments (available in util)

* Bump
This commit is contained in:
Jaco Greeff
2021-02-27 15:25:05 +01:00
committed by GitHub
parent 7d11e6f9a5
commit 3ebf7eb424
29 changed files with 310 additions and 243 deletions
+5 -5
View File
@@ -15,15 +15,15 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.13.7",
"@babel/runtime": "^7.13.8",
"@polkadot/metadata": "3.10.3-12",
"@polkadot/util": "^5.8.1",
"@polkadot/util-crypto": "^5.8.1",
"@polkadot/x-rxjs": "^5.8.1",
"@polkadot/util": "^5.8.2-5",
"@polkadot/util-crypto": "^5.8.2-5",
"@polkadot/x-rxjs": "^5.8.2-5",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.8.1"
"@polkadot/keyring": "^5.8.2-5"
}
}
+2 -16
View File
@@ -1,23 +1,9 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
//
// new URL(import.meta.url).pathname)
//
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
// there is a complete dead end with usage thereof
//
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
//
// cjs: util.detectPackage(packageInfo, () => __dirname);
// esm: detectPackage(packageInfo, () => import.meta.url);
//
// With the above we additionally need a .d.ts to just export the packageInfo
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
import { detectPackage } from '@polkadot/util';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [metaInfo]);
+1
View File
@@ -6,3 +6,4 @@ import './detectPackage';
export * from './codec';
export * from './create';
export * from './index.types';
export { packageInfo } from './packageInfo';