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 can be imported as module in an html page? #180

Open
yourchoice opened this issue Mar 11, 2024 · 0 comments
Open

How can be imported as module in an html page? #180

yourchoice opened this issue Mar 11, 2024 · 0 comments

Comments

@yourchoice
Copy link

How can be imported as module in html pages ?

I tried:

In main html I load script main.js with click listener to an input :

document.querySelector('.dpr-input')?.addEventListener("click", event => {
       const el = event.target;
	(async () => {
		const { Datepicker } =  await import('/assets/plugins/vanillajs-datepicker/index.es.js');
		
		new DateRangePicker( .... );
	})();
});

And index.es.js file

import Datepicker from './js/Datepicker.js';
export Datepicker;// I tried and export default Datepicker;

But i get errors like: The requested module './Datepicker.js' does not provide an export named 'default' (at index.es.js) or Uncaught (in promise) SyntaxError: Unexpected token 'export' (at index.es.js)

Please if somebody can help me how to import - export without errors.

Thank You!

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

1 participant