Mock for __dirname (#261)

* Mock for __dirname

* undefined

* CHANGELOG
This commit is contained in:
Jaco
2021-12-31 10:43:30 +01:00
committed by GitHub
parent 96d016f0a4
commit a03283fe32
5 changed files with 18 additions and 1 deletions

View File

@@ -4,7 +4,8 @@
Changes:
- Adjust ed25519 internals (speed & size)
- Adjust ed25519 internals, consistency in code
- Ensure package path is availble under ESM & CJS
- JS wrapped bytes interoperability test

View File

@@ -0,0 +1,6 @@
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
declare const __dirname: string | undefined;
export default __dirname;

View File

@@ -0,0 +1,6 @@
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = typeof __dirname === 'string'
? __dirname.replace('/cjs', '')
: undefined;

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@@ -5,6 +5,7 @@ import { detectPackage } from '@polkadot/util';
import { packageInfo as asmInfo } from '@polkadot/wasm-crypto-asmjs/packageInfo';
import { packageInfo as wasmInfo } from '@polkadot/wasm-crypto-wasm/packageInfo';
import __dirname from './cjs/dirname';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [asmInfo, wasmInfo]);