google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.18k stars 580 forks source link

ReferenceError: System is not defined #1986

Open smrutirekhasamal opened 9 years ago

smrutirekhasamal commented 9 years ago

Hi, I have created build-module.js, which is a bundle of all the modules. However while trying to run in browser, it shows "ReferenceError: System is not defined" error. Please help me resolving this and to run in browser.

Thank you

johnjbarton commented 9 years ago

Did you bundle the runtime.js file? On Aug 20, 2015 4:15 AM, "smrutirekhasamal" notifications@github.com wrote:

Hi, I have created build-module.js, which is a bundle of all the modules. However while trying to run in browser, it shows "ReferenceError: System is not defined" error. Please help me resolving this and to run in browser.

Thank you

— Reply to this email directly or view it on GitHub https://github.com/google/traceur-compiler/issues/1986.

fritx commented 8 years ago

How to do it?

thenameishidden commented 7 years ago

My code from example/hello.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello, World!</title>
    <script src="../src/runtime/runtime.js"></script>
    <script src="../bin/traceur.js"></script>
    <script src="../src/bootstrap.js"></script>
  </head>
  <body>
    <script type="module">

      class Greeter {
        constructor(message) {
          this.message = message;
        }

        greet() {
          var element = document.querySelector('#message');
          element.innerHTML = this.message;
        }
      };

      document.addEventListener("DOMContentLoaded", function(event) { 
        var greeter = new Greeter('Hello, world!');
        greeter.greet();
      });

    </script>
    <h1 id="message"></h1>
  </body>
</html>

Uncaught ReferenceError: System is not defined at bootstrap.js:15 Now with runtime.js

I have this error also on this page http://google.github.io/traceur-compiler/example/hello.html (Last Chrome on Windows 10)

miodrag-manic-rs commented 7 years ago
<!DOCTYPE html>
<html>
  <head>
    <title>Hello, World!</title>
<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>
  </head>
  <body>
    <script type="module">

      class Greeter {
        constructor(message) {
          this.message = message;
        }

        greet() {
          var element = document.querySelector('#message');
          element.innerHTML = this.message;
       alert(message);
        }
      };

      //document.addEventListener("DOMContentLoaded", function(event) { 
        var greeter = new Greeter('Hello, world!');
        greeter.greet();
     // });

    </script>
    <h1 id="message"></h1>
  </body>
</html>
arv commented 7 years ago

As @miodrag-manic-rs code shows, adding BrowserSystem.js should do it IIRC. @johnjbarton

thenameishidden commented 7 years ago

Yes, this is solution, thanks!