fixed bug in browser ESM
This commit is contained in:
parent
0d4f0abfd6
commit
0fd1912394
|
@ -81,7 +81,6 @@ export default [
|
||||||
browser: true,
|
browser: true,
|
||||||
exportConditions: ['browser', 'default']
|
exportConditions: ['browser', 'default']
|
||||||
}),
|
}),
|
||||||
compileDts(),
|
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
json()
|
json()
|
||||||
]
|
]
|
||||||
|
@ -172,6 +171,7 @@ export default [
|
||||||
browser: false,
|
browser: false,
|
||||||
exportConditions: ['node']
|
exportConditions: ['node']
|
||||||
}),
|
}),
|
||||||
|
compileDts(),
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
json()
|
json()
|
||||||
]
|
]
|
||||||
|
|
|
@ -63,7 +63,7 @@ export default class TestsBuilder extends Builder {
|
||||||
tsConfig.compilerOptions.sourceMap = true
|
tsConfig.compilerOptions.sourceMap = true
|
||||||
|
|
||||||
// This prevents SyntaxError: Cannot use import statement outside a module
|
// This prevents SyntaxError: Cannot use import statement outside a module
|
||||||
// tsConfig.compilerOptions.module = 'commonjs'
|
tsConfig.compilerOptions.module = 'commonjs'
|
||||||
|
|
||||||
// Removed typeroots (it causes issues)
|
// Removed typeroots (it causes issues)
|
||||||
tsConfig.compilerOptions.typeRoots = undefined
|
tsConfig.compilerOptions.typeRoots = undefined
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
16
docs/API.md
16
docs/API.md
|
@ -155,7 +155,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/isProbablyPrime.ts#L21)
|
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/isProbablyPrime.ts#L21)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ A promise that resolves to a bigint probable prime of bitLength bits.
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/prime.ts:29](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/prime.ts#L29)
|
[src/ts/prime.ts:29](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/prime.ts#L29)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ A bigint probable prime of bitLength bits.
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/prime.ts:107](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/prime.ts#L107)
|
[src/ts/prime.ts:107](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/prime.ts#L107)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ A cryptographically secure random bigint between [min,max]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/randBetween.ts#L15)
|
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/randBetween.ts#L15)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/randBits.ts#L14)
|
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/randBits.ts#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/randBits.ts#L45)
|
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/randBits.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/randBytes.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/randBytes.ts#L14)
|
[src/ts/randBytes.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/randBytes.ts#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/6143973/src/ts/randBytes.ts#L46)
|
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/0d4f0ab/src/ts/randBytes.ts#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -396,9 +396,9 @@ export function _isProbablyPrimeWorkerUrl (): string {
|
||||||
return _workerUrl(workerCode)
|
return _workerUrl(workerCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!IS_BROWSER && _useWorkers) { // node.js with support for workers
|
||||||
|
try {
|
||||||
var workerThreads = await import('worker_threads') // eslint-disable-line no-var
|
var workerThreads = await import('worker_threads') // eslint-disable-line no-var
|
||||||
if (!IS_BROWSER && _useWorkers) { // node.js with support for workers
|
|
||||||
const isWorker = !(workerThreads.isMainThread)
|
const isWorker = !(workerThreads.isMainThread)
|
||||||
if (isWorker && workerThreads.parentPort !== null) { // worker
|
if (isWorker && workerThreads.parentPort !== null) { // worker
|
||||||
const parentPort = workerThreads.parentPort
|
const parentPort = workerThreads.parentPort
|
||||||
|
@ -412,5 +412,5 @@ try {
|
||||||
parentPort.postMessage(msg)
|
parentPort.postMessage(msg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {}
|
||||||
} catch (error) {}
|
}
|
||||||
|
|
Loading…
Reference in New Issue