Skip to content
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

How to import it while building? #89

Open
stratboy opened this issue Jan 17, 2023 · 2 comments
Open

How to import it while building? #89

stratboy opened this issue Jan 17, 2023 · 2 comments

Comments

@stratboy
Copy link

stratboy commented Jan 17, 2023

Hi, It's not clear to me how should I use it if not loading it via script tag. Or, how to build it into another js file.

I'm trying this:

import { crs } from '../node_modules/country-region-selector/dist/crs.min.js';

And it seems to work, but it's not really clear to me if it's the right way, and also why it's working, since if I then log the crs object, it's just undefined. Why? How to? Thank you.

@benkeen
Copy link
Member

benkeen commented Jan 18, 2023

This is a very old script! This is now 5 years old, before es6 was all that standard. Normally you'd have just included it in your HTML file. It was back in the day when Bower was a thing. What you're doing it fine, but you should be able to just do this:

import '../node_modules/country-region-selector/dist/crs.min.js';

btw, the way it works is that that script automatically parses the DOM and finds the elements and then dynamically applies the code. Again, old fashioned, but works. :)

@stratboy
Copy link
Author

It's a 'very' old script but still one of the best of this type, for sure.
Thank you very much for your suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants