In the process of trying to have a more debuggable build (given that, by default, the minified version is included - #753) I tried to instruct my webpack build to directly import index.js instead, like so:
This works insofar as that it compiles, but it fails at runtime. The reason for this appears to be that index.js provides a default export of an object, whereas index.d.ts indicates that there should be a named export of the individual classes / interfaces. Or in code:
import { WebStorageStateStore } from 'oidc-client';
works according to the type definition, but in reality one would have to do:
import * as oidc from 'oidc-client';
oidc.WebStorageStateStore
To achieve the correct result, though this doesn't type check. This appears to be remedied by doing an export { ... } instead of an export default { ... } in index.js (at least that worked for my local build).
I'm not going to say this is a bug, because it does seem like I'm using the library in a different way than currently intended. That being said, I'm still curious as to why this discrepancy exists, and whether this is on your radar for v2.0.0.
PS: thanks for building and maintaining this library 🎉
Yea, I know there are some oddities around this area, but this style of export was setup a long time ago and I've just never had a chance to rework it. That'd be a v2 since it's a breaking change.
In the process of trying to have a more debuggable build (given that, by default, the minified version is included - #753) I tried to instruct my webpack build to directly import
index.js
instead, like so:This works insofar as that it compiles, but it fails at runtime. The reason for this appears to be that
index.js
provides a default export of an object, whereasindex.d.ts
indicates that there should be a named export of the individual classes / interfaces. Or in code:works according to the type definition, but in reality one would have to do:
To achieve the correct result, though this doesn't type check. This appears to be remedied by doing an
export { ... }
instead of anexport default { ... }
inindex.js
(at least that worked for my local build).I'm not going to say this is a bug, because it does seem like I'm using the library in a different way than currently intended. That being said, I'm still curious as to why this discrepancy exists, and whether this is on your radar for v2.0.0.
PS: thanks for building and maintaining this library 🎉