How to load Javascript ES6 Class in view?

Posted 1 year ago by jvv8

Is there a requirement that I'm missing to have ES6 classes available for use in the view? If I declare the following in public/js/person.js:

Class Person {
        name = data.name;
export default Person;

Then somewhere in my mix file I have: mix.babel(['public/js/person.js'],'public/js/person.min.js'); Then in the view:

<script src="{{ mix('js/person.min.js') }}"></script>
<script>var bob = new Person({name: "Bob"});</script>

I get the error: Uncaught ReferenceError: Person is not defined

Am I missing something? L5.4 [email protected]

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.