-
-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: esm version has no cookieConsent variable #656
Comments
I'm not sure I understand the issue. The UMD version is attached to the window object and is globally accessible. The ESM version is imported in the current context only, which is the expected behavior of ESM, afaik. |
@dreinon there is no default export so that won't work. You should use the import * as CookieConsent from 'vanilla-cookieconsent'; |
Right, it might be a good idea to also export it as default, since linters recommend you import as default instead of with "*" |
It mostly boils down to personal preference. This clearly conveys that you are willingfully loading everything: import * as CookieConsent from 'vanilla-cookieconsent'; I would have used a default export if there was only one function exported. |
I agree with you.
…On Wed, 13 Mar 2024, 23:20 Orest Bida, ***@***.***> wrote:
It mostly boils down to personal preference.
I like the explicitness of named exports. They are more flexible and
clearer to me.
This clearly conveys that you are willingfully loading everything:
import * as CookieConsent from 'vanilla-cookieconsent';
I would have used a default export if there was only one function exported.
—
Reply to this email directly, view it on GitHub
<#656 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARKPJ2HCBMZOXWY5S5SUOTYYDGLZAVCNFSM6AAAAABEAW234OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVHE4TAOJSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Expected Behavior
after importing the esm version I get an error message that cookieConsent is not defined which is true. As a result I was forced to use the umd version.
I much prefer using the esm as I use ES6 vanilla javascript
Current Behavior
cookieConsent missing when using https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@3.0.0/dist/cookieconsent.esm.js
Steps to reproduce
just open the file
Proposed fix or additional info.
export the cookieConsent variable as u=in the umd version
Version
3.0.0
On which browser do you see the issue?
Firefox
The text was updated successfully, but these errors were encountered: