This commit is contained in:
Jaco Greeff
2020-12-18 11:33:28 +01:00
parent 7dadac7344
commit 33fd09c053
24 changed files with 187 additions and 191 deletions
+1 -2
View File
@@ -63,8 +63,7 @@ function initType<T extends Codec = Codec, K extends string = string> (registry:
// An unsafe version of the `createType` below. It's unsafe because the `type`
// argument here can be any string, which, when it cannot parse, will yield a
// runtime error.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: any[] = [], { isPedantic, withoutLog }: UnsafeOptions = {}): T {
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: any[] = [], { withoutLog }: UnsafeOptions = {}): T {
try {
// Circle back to isPedantic when it handles all cases 100% - as of now,
// it provides false warning which is more hinderance than help
-6
View File
@@ -1,6 +0,0 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import packageInfo from './package-info.json';
export { packageInfo };
-10
View File
@@ -1,10 +0,0 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
const util = require('@polkadot/util');
const packageInfo = require('./package-info.json');
util.detectPackage(packageInfo, () => __dirname);
exports.packageInfo = packageInfo;
-10
View File
@@ -1,10 +0,0 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { detectPackage } from '@polkadot/util';
import packageInfo from './package-info.json';
detectPackage(packageInfo, () => import.meta.url);
export { packageInfo };
+25
View File
@@ -0,0 +1,25 @@
// Copyright 2017-2020 @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 { detectPackage } from '@polkadot/util';
import packageInfo from './package-info.json';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
export { packageInfo };