klaro-org / klaro-js

Klaro Privacy Manager. An open-source, privacy-friendly & compliant consent manager for your website.
https://klaro.org
Other
1.18k stars 249 forks source link

Klaro lazy-loading #286

Closed sowinski closed 4 years ago

sowinski commented 4 years ago

Hi,

I use webpack and try to load klaro lazy. (Because I have my own cookiebanner implementation and only want to show klaro while a user ticks "Settings" on my cookie banner).

My code looks like that. (Realized with webpack)

$("#cookie-settings").on( "click", function() {
  import('./loadklaro.js');
});

In my loadklaro.js file I have only this line of code: import * as Klaro from "klaro/dist/klaro-no-css";

In Google Chrome browser it works. But with Firefox 79.0 (64-Bit) it throws this error.

Uncaught (in promise) TypeError: In is null
    <anonymous> webpack:///./node_modules/klaro/dist/klaro-no-css.js?:1

1) Any idea what could be wrong? 2) Do you have an idea how to debug this problem? Because the file has only one line, I do not know where the error comes from. 3) Can I import the source instead of the minified file somehow?

Thank you :)

EDIT: Current Chrome, Microsoft Edge and Google Chrome for Android are working fine. It is just Firefox :(

adewes commented 4 years ago

Hi @sowinski! That's weird, maybe Webpack has an issue with the already processed code or the transpiling of our ES6 code causes some incompatibilities?

We also ship the source code now with the NPM bundle, so you can import the ES6 modules (e.g. klaro/src/klaro), which might be a better choice when using Webpack anyway. Just remember to install necessary peer dependencies like React manually.

adewes commented 4 years ago

Did that solve your issue @sowinski?

adewes commented 4 years ago

Hey @sowinski, I'll close this for now, if your problem isn't solve let me know and we'll reopen it.