Define global values in Traceur on the fly compilation

时间:2016-07-11 23:28:13

标签: javascript traceur

I am trying traceur hello world example from their Getting Started page. Here's my code.

<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<script type="module">
  import 'main.js';
</script>

And main.js has this:

window.a = 10;
function foo() {}

Now when I check value of a in console, it shows correctly But foo is undefined. I understand what's happening here, the main.js file is not being executed in global scope so function declarations don't register for global scope either.

I would like to be able to declare global classes and functions from within included files.

1 个答案:

答案 0 :(得分:0)

我可以通过一个简单的

解决这个问题
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;