fixed bug in browser ESM

This commit is contained in:
Juanra Dikal 2022-08-01 21:53:46 +02:00
parent 0d4f0abfd6
commit 0fd1912394
12 changed files with 473 additions and 715 deletions

View File

@ -81,7 +81,6 @@ export default [
browser: true,
exportConditions: ['browser', 'default']
}),
compileDts(),
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
json()
]
@ -172,6 +171,7 @@ export default [
browser: false,
exportConditions: ['node']
}),
compileDts(),
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
json()
]

View File

@ -63,7 +63,7 @@ export default class TestsBuilder extends Builder {
tsConfig.compilerOptions.sourceMap = true
// This prevents SyntaxError: Cannot use import statement outside a module
// tsConfig.compilerOptions.module = 'commonjs'
tsConfig.compilerOptions.module = 'commonjs'
// Removed typeroots (it causes issues)
tsConfig.compilerOptions.typeRoots = undefined

7
dist/bundles/esm.js vendored

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

2
dist/bundles/umd.js vendored

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

View File

@ -155,7 +155,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe
#### 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
[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
[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
[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
[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
[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
[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
[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)
___

1118
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -396,9 +396,9 @@ export function _isProbablyPrimeWorkerUrl (): string {
return _workerUrl(workerCode)
}
try {
var workerThreads = await import('worker_threads') // eslint-disable-line no-var
if (!IS_BROWSER && _useWorkers) { // node.js with support for workers
if (!IS_BROWSER && _useWorkers) { // node.js with support for workers
try {
var workerThreads = await import('worker_threads') // eslint-disable-line no-var
const isWorker = !(workerThreads.isMainThread)
if (isWorker && workerThreads.parentPort !== null) { // worker
const parentPort = workerThreads.parentPort
@ -412,5 +412,5 @@ try {
parentPort.postMessage(msg)
})
}
}
} catch (error) {}
} catch (error) {}
}