I add babel compiler in my page to use ES6 syntax by below:
<script src="babel.min.js"></script>
And create a simple module in M.js as below:
export var M={
p:3
};
And use it in my page:
<script type="text/babel">
import {M} from './M';
console.log(M.p);
</script>
But meet below error in console:
Uncaught ReferenceError: require is not defined
How can I make module works in browser? Does babel.js support module or not? If not, if there's other way I can make ES6 module syntax works in browser.