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
+3 -16
View File
@@ -1,23 +1,10 @@
// Copyright 2017-2021 @polkadot/metadata 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 typesInfo } from '@polkadot/types/packageInfo';
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
import { detectPackage } from '@polkadot/util';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo, knownInfo]);
+1
View File
@@ -5,3 +5,4 @@ import './detectPackage';
export { Metadata } from './Metadata';
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
export { packageInfo } from './packageInfo';