Giter Site home page Giter Site logo

Comments (9)

renato-zannon avatar renato-zannon commented on May 28, 2024

Oops, seems like I spoke too soon: the problem isn't just about amd vs globals, but also with <script type="module"> vs traceur-compiled modules.

The es6.js file above compiles in runtime, with <script type="module"> to:

(function(global
/**/) {
    var __moduleName = "es6";
    with (global) {
        var amdAnswer = __moduleDependency0["default"];
        console.log(amdAnswer());
        var globalAnswer = __moduleDependency1["default"];
        console.log(globalAnswer());
    }
})

And, with traceur --modules=amd to:

define(["amd", "global"], function($__0,$__1) {
  "use strict";
  var __moduleName = "es6";
  var amdAnswer = ($__0).default;
  console.log(amdAnswer());
  var globalAnswer = ($__1).default;
  console.log(globalAnswer());
  return {};
});

While using the system.js file, the <script type="module"> works fine, but the traceur one doesn't work at all (not even with the amd module). The behavior I described earlier (only amd working) happens when using system-amd-production.

Am I using the wrong command-line switches, or doing something overall stupid? :)

from systemjs.

guybedford avatar guybedford commented on May 28, 2024

Yeah globals only create a Module object when there are multiple globals written.

Yes there is a compatibility issue in the modules output for Traceur.

We've been working on this here - google/traceur-compiler#785

Once that pull request is in (hopefully today or tomorrow) I will update the compatibility layer and we should be good.

from systemjs.

renato-zannon avatar renato-zannon commented on May 28, 2024

Once that pull request is in (hopefully today or tomorrow) I will update the compatibility layer and we should be good.

Great to hear! Let me know if I can help with something.

Yeah globals only create a Module object when there are multiple globals written.

Interestingly, with a system.js-compiled es6 module (be it via <script type="module"> or via System.import()), both amd.js and globals.js load as expected.

The issue happens only when loading a traceur-compiled module with system-amd-production.js. The amd module loads okay, but the global value isn't wrapped.

I can setup a repository to reproduce this if you think it helps.

from systemjs.

guybedford avatar guybedford commented on May 28, 2024

Yes this is completely an ES6 / transpiled ES6 interop issue which we've sorted (at least unless I've completely overlooked something).

Help testing this stuff out is amazing, so thanks for that.

from systemjs.

guybedford avatar guybedford commented on May 28, 2024

@Riccieri this has been fixed now in the latest versions of SystemJS (0.5.0), ES6 Module Loader (0.5.1) and Traceur (master branch).

For AMD compilation, until Traceur release 0.0.26, you will need to use the master branch of traceur, by cloning the repo, and running make, then using the traceur executable from the bin folder.

If you have any problems at all please let me know.

from systemjs.

renato-zannon avatar renato-zannon commented on May 28, 2024

That's great to hear, thanks! I will try the latest versions and report back.

this has been fixed now in the latest versions of SystemJS (0.5.0), (...)

Could you add a tag to github for SystemJS 0.5.0? It makes it easier to manage with bower. Thanks!

from systemjs.

guybedford avatar guybedford commented on May 28, 2024

Thanks for reminding me - I've tagged it now.

from systemjs.

renato-zannon avatar renato-zannon commented on May 28, 2024

From my testing, there aren't any issues anymore, so I'm closing this issue.

Thanks for the great work!

from systemjs.

guybedford avatar guybedford commented on May 28, 2024

Great to hear that, thanks.

from systemjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.