Skip to content

Commit

Permalink
Use broadcast-channel with fixes ESM bundle
Browse files Browse the repository at this point in the history
added test:bundle:esm:node:app
  • Loading branch information
denysoblohin-okta committed Jun 1, 2022
1 parent e79b294 commit 4f0e39f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion jest.esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
restoreMocks: true,
moduleNameMapper: {
'^@okta/okta-auth-js$': OktaAuth,
'^broadcast-channel$': '<rootDir>/node_modules/broadcast-channel/dist/es5node/index.js'
'^broadcast-channel$': '<rootDir>/node_modules/broadcast-channel/dist/esnode/index.mjs'
},
extensionsToTreatAsEsm: ['.ts'],
testPathIgnorePatterns: [],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"test:integration": "jest --config ./jest.integration.js",
"test:bundle:esm:browser": "cross-env BUNDLE_ENV=browser NODE_OPTIONS=--experimental-vm-modules jest --config ./jest.esm.mjs",
"test:bundle:esm:node": "cross-env BUNDLE_ENV=node NODE_OPTIONS=--experimental-vm-modules jest --config ./jest.esm.mjs",
"test:bundle:esm:node:app": "yarn workspace @okta/test.app.node-esm start",
"test:bundle:cjs": "cross-env BUNDLE_ENV=node jest --config ./jest.cjs.js",
"test:types": "jest --config ./jest.tsd.js --runInBand",
"build": "node scripts/build.js",
Expand Down Expand Up @@ -89,7 +90,7 @@
"@peculiar/webcrypto": "1.1.6",
"Base64": "1.1.0",
"atob": "^2.1.2",
"broadcast-channel": "^4.10.0",
"broadcast-channel": "^4.12.0",
"btoa": "^1.2.1",
"core-js": "^3.6.5",
"cross-fetch": "^3.1.5",
Expand Down
5 changes: 5 additions & 0 deletions scripts/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if ! yarn test:bundle:esm:node; then
exit ${TEST_FAILURE}
fi

if ! yarn test:bundle:esm:node:app; then
echo "ESM node app failed to start! Exiting..."
exit ${TEST_FAILURE}
fi

if ! yarn test:bundle:cjs; then
echo "validate cjs bundle failed! Exiting..."
exit ${TEST_FAILURE}
Expand Down
3 changes: 2 additions & 1 deletion test/validate-bundles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ describe('OktaAuth (api)', function() {
});

it('can updateAuthState', () => {
auth.authStateManager.updateAuthState();
const promise = auth.authStateManager.updateAuthState();
expect(auth.authStateManager._pending.updateAuthStatePromise).toBeInstanceOf(PCancelable);
return promise;
});

describe('Storage', () => {
Expand Down
54 changes: 27 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6402,11 +6402,6 @@ bfj@^7.0.2:
hoopy "^0.1.4"
tryer "^1.0.1"

big-integer@^1.6.16:
version "1.6.51"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
Expand Down Expand Up @@ -6581,16 +6576,15 @@ braces@^3.0.1, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

broadcast-channel@^4.10.0:
version "4.10.0"
resolved "https://registry.yarnpkg.com/broadcast-channel/-/broadcast-channel-4.10.0.tgz#d19fb902df227df40b1b580351713d30c302d198"
integrity sha512-hOUh312XyHk6JTVyX9cyXaH1UYs+2gHVtnW16oQAu9FL7ALcXGXc/YoJWqlkV8vUn14URQPMmRi4A9q4UrwVEQ==
broadcast-channel@^4.12.0:
version "4.12.0"
resolved "https://registry.yarnpkg.com/broadcast-channel/-/broadcast-channel-4.12.0.tgz#891876c5262376ab714b33a0d9e9d87a894b5bcb"
integrity sha512-hfb0L2P2CEsdM5nSqlRiZ2gQFHPdJNs1VU4rTLnFPYtq5vQAnyOdjIx+04KCWfFfRhfP3OEbxxQmnouSi8WCbQ==
dependencies:
"@babel/runtime" "^7.16.0"
detect-node "^2.1.0"
microseconds "0.2.0"
nano-time "1.0.0"
oblivious-set "1.0.0"
microtime "3.0.0"
oblivious-set "1.1.1"
p-queue "6.6.2"
rimraf "3.0.2"
unload "2.3.1"
Expand Down Expand Up @@ -15892,10 +15886,13 @@ micromatch@^4.0.2, micromatch@^4.0.4:
braces "^3.0.1"
picomatch "^2.2.3"

[email protected]:
version "0.2.0"
resolved "https://registry.yarnpkg.com/microseconds/-/microseconds-0.2.0.tgz#233b25f50c62a65d861f978a4a4f8ec18797dc39"
integrity sha512-n7DHHMjR1avBbSpsTBj6fmMGh2AGrifVV4e+WYc3Q9lO+xnSZ3NyhcBND3vzzatt05LFhoKFRxrIyklmLlUtyA==
[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/microtime/-/microtime-3.0.0.tgz#d140914bde88aa89b4f9fd2a18620b435af0f39b"
integrity sha512-SirJr7ZL4ow2iWcb54bekS4aWyBQNVcEDBiwAz9D/sTgY59A+uE8UJU15cp5wyZmPBwg/3zf8lyCJ5NUe1nVlQ==
dependencies:
node-addon-api "^1.2.0"
node-gyp-build "^3.8.0"

miller-rabin@^4.0.0:
version "4.0.1"
Expand Down Expand Up @@ -16218,13 +16215,6 @@ nan@^2.12.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/nano-time/-/nano-time-1.0.0.tgz#b0554f69ad89e22d0907f7a12b0993a5d96137ef"
integrity sha1-sFVPaa2J4i0JB/ehKwmTpdlhN+8=
dependencies:
big-integer "^1.6.16"

nanoid@^3.1.23:
version "3.1.23"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
Expand Down Expand Up @@ -16301,6 +16291,11 @@ no-case@^3.0.4:
lower-case "^2.0.2"
tslib "^2.0.3"

node-addon-api@^1.2.0:
version "1.7.2"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.2.tgz#3df30b95720b53c24e59948b49532b662444f54d"
integrity sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==

node-cache@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/node-cache/-/node-cache-5.1.2.tgz#f264dc2ccad0a780e76253a694e9fd0ed19c398d"
Expand All @@ -16327,6 +16322,11 @@ node-forge@^0.10.0:
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==

node-gyp-build@^3.8.0:
version "3.9.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-3.9.0.tgz#53a350187dd4d5276750da21605d1cb681d09e25"
integrity sha512-zLcTg6P4AbcHPq465ZMFNXx7XpKKJh+7kkN699NiQWisR2uWYOWNWqRHAmbnmKiL4e9aLSlmy5U7rEMUXV59+A==

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -16737,10 +16737,10 @@ object.values@^1.1.5:
define-properties "^1.1.3"
es-abstract "^1.19.1"

oblivious-set@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/oblivious-set/-/oblivious-set-1.0.0.tgz#c8316f2c2fb6ff7b11b6158db3234c49f733c566"
integrity sha512-z+pI07qxo4c2CulUHCDf9lcqDlMSo72N/4rLUpRXf6fu+q8vjt8y0xS+Tlf8NTJDdTXHbdeO1n3MlbctwEoXZw==
oblivious-set@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/oblivious-set/-/oblivious-set-1.1.1.tgz#d9d38e9491d51f27a5c3ec1681d2ba40aa81e98b"
integrity sha512-Oh+8fK09mgGmAshFdH6hSVco6KZmd1tTwNFWj35OvzdmJTMZtAkbn05zar2iG3v6sDs1JLEtOiBGNb6BHwkb2w==

obuf@^1.0.0, obuf@^1.1.2:
version "1.1.2"
Expand Down

0 comments on commit 4f0e39f

Please sign in to comment.