Closed joepio closed 3 years ago
Hi @joepio , thanks for reporting this, and sorry for the delayed response !
I'm not familiar with Snowpack at all, so I'm really not sure how relevant my suggestions will be here. There are multiple dependencies on NodeJS modules that need to be polyfilled for solid-client-authn-browser
to run, in particular related to cryptography. Part of that is discussed in https://github.com/inrupt/solid-client-authn-js/pull/796, but basically we want to switch to a library for both solid-client-authn-browser
and solid-client-authn-node
, and we'll only be able to migrate the latter in April, after NodeJS 10 is no longer LTS.
However, it looks like the issue you're having is with the event
module, which is used by Session
in particular. So far, we did not have to polyfill it manually, which might mean that Webpack has been doing it implicitly and has hidden the problem until now. Unfortunately, that means I don't have an obvious solution, of a polyfill module to recommend that would fix the issue. I'll make sure we investigate this, and I'll update the issue as we make progress.
I'm sorry I don't have a more satisfactory answer!
Thanks for the reply and the help @NSeydoux!
I think for the the easiest fix is to switch to webpack for now, or are you saying that you'll remove the dependency on the Event module too in April?
If using webpack is a viable solution for you, I think that would be the easiest course of action for now. The event module isn't one of the Node builtins that we'll no longer depend on in April, since it is part of the API it's likely to stick around.
However, I'll experiment adding an explicit dependency on https://www.npmjs.com/package/events, which is a browser module providing the events API. We wouldn't rely on webpack's behaviour in that regard, so maybe that would fix your issue.
We just released version 1.9.0 which contains an updated version of jose
that no longer relies on native Node modules. The events
package is still in there, but as far as I'm aware that won't cause a problem if you pass the --polyfillNode
parameter, so as far as I know it should now at least by usable with Snowpack. We'll look at removing the dependency on Node's events
module later.
Since you mentioned switching to Webpack, I'm assuming you're not going to be checking whether Snowpack works now, but if you do encounter further issues, feel free to reopen or to open a new issue. Cheers!
First of all: thanks for creating and sharing this :)
And warning: this next issue might be a snowpack issue.
I've tried the JS example from the sandbox folder, and it works wonderfully in CodeSandbox. But if I try to run the same code in a SnowPack Typescript project, I first had to run with the
--polyfillNode
option (which kind of suprised me, since@inrupt/solid-client-authn-browser
is a browser library, right?).So I enable polyfilling node, and I get this:
This is the block that's throwing:
And that's a
node.util
function. Paired with the aforementioned required usage ofpolyfillNOde
, I suspect this is where things go wrong.When trying to find out what
superCtor
is:Is is weird that the browser plugin is using node modules? Or is that normal, and is there an issue with the snowpack node polyfiller?
Anyway, I didn't really know where to look next, so I created this issue.
Search terms you've used
superCtor.prototype, superCtor, util.inherits
Impacted package
Which packages do you think might be impacted by the bug ?