I am trying to port my code from ES5
to ES6
and use babel
. I use the module template quite a bit in my code, so if I have a module like apple
, I will do something like this:
var appleModule = (function() {
var yummy = true;
var eat = function() { }
return { "eat": eat }
})();
and then log in appleModule
to another file. However, moving all of this:
<script type="text/javascript" src="/scripts/apple.js"></script>
<script type="text/javascript" src="/scripts/banana.js"></script>
:
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser.js"></script>
<script type="text/babel" src="/scripts/apple.js"></script>
<script type="text/babel" src="/scripts/banana.js"></script>
I can no longer access appleModule
in different files. I get ReferenceError
by saying that it does not exist. How to access variables in files using babel and ES6?
source
share