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

SyntaxError: Unexpected token 'export' when using import on javascript files #23

Open
animexxx opened this issue Jul 30, 2024 · 1 comment

Comments

@animexxx
Copy link

Hello everybody,
When i just put this code to assets/js/scripts.js
import moment from 'moment-timezone';
and try to build, it show the error
Uncaught SyntaxError: Unexpected token 'export' (at main-42e06ae1.js?ver=6.6.1:41:35449)
it work on the development mode, idk why? anyone have fix?

Thanks

@animexxx
Copy link
Author

animexxx commented Jul 30, 2024

update: replace the code in /inc/inc.vite.php to fix it
//wp_enqueue_script('main', DIST_URI . '/' . $js_file, JS_DEPENDENCY, '', JS_LOAD_IN_FOOTER); wp_enqueue_script_module('main', DIST_URI . '/' . $js_file, JS_DEPENDENCY, '');
it change type text/javascript to module
(wp_enqueue_script_module working from Wordpress 6.5)

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