Skip to content

Fix js-cookie importing issues

Yasha requested to merge fix-js-cookie-importing-issues into trunk

Changes

  • Revert js-cookie v3 (back to v2.2.1)
  • Revert import Cookies from 'js-cookie' as import * as Cookies for now
  • Remove getJSON (use get and JSON.parse())

The code changes on this pull request should work both in js-cookie v2.2.1 and v3.x. However, in js-cookie v3, the importing way of modules has been changed.

It seems that we still cannot update js-cookie v3 due to the importing incompatibilities between test (js-test) and build because of difference how we compile modules. If we could update TypeScript 4.5 for supporting .mjs (by module: node12 option), then it perhups may be fixed.

// We need to do this, this works by upgrading v3
import Cookies from 'js-cookie';

// but test (ts-jest), we cannot import it and have to do this
import * as Cookies from 'js-cookie';

Notes

We have following options in tsconfig.json.

allowSyntheticDefaultImports: true
esModuleInterop: false

Links

Merge request reports