The new Glimmer.js

https://www.glimmerjs.com/

Really looking forward to using this! :slight_smile:

Interesting. So it’s view layer only, like react or vue?

I’ve given it a try but I can’t manage to drop a Glimmer-style component in an existing Ember app. Did anyone manage to get it working? I’ve asked on StackOverflow if you’d like to reply there.

I’ve been thinking a lot about this myself after the announcement - I’d guess a quick n dirty “conceptual” look at the problem (in ember today) could involve a simple beforeModel $.getScript (to fetch a pre-compiled glimmerJS addon full of your components/ then in something like afterModel you could kick off the render/draw step to construct those glimmer component classes)

Spike -something like so (note: would require a named AMD compile of the glimmerJS code to work with loaderJS and ember-cli)

// js/app/routes/reports.js

var ReportsRoute = Ember.Route.extend({
    beforeModel: function() {
        return $.getScript('js/lazy/reporting.js');
    },
    afterModel: function() {
        var Foo = require('vendor/foo')['default'].create();
        Foo.get('help');
    }
});

// js/lazy/reporting.js

define("vendor/foo",
  ["exports"],
  function(__exports__) {
    "use strict";
    var Foo = Ember.Object.extend({
        help: function() {
            console.log('inside the help property');
        }.property()
    });
    __exports__["default"] = Foo;
});

full disclosure -this was taken from work I did pre ember-cli to show how one might “lazy load” by URL in ember

http://toranbillups.com/blog/archive/2014/10/02/Lazy-loading-es6-modules-with-emberjs/

Unfortunately I am not familiar enough with Ember to completely understand your sample, but since you mentioned precompiled Glimmer components, it seems that it would work with jany JavaScript component, while Glimmer promises specific Ember integration. I was comparing the Ember cli configuration in an a default Ember template with the default Glimmer blueprint, and I wonder whether you could not get it to work by adding an additional step to the embe-cli compilation pipeline? One comment on Stack overflow suggests just using the latest Ember canary so I could give that a try.

That won’t work for a while yet, as the integration isn’t done.

The first step is landing Module Unification RFC in Ember, which is close to being completed :smiley: The next step is the Custom Component RFC, which introduces the primitive necessary to then start thinking about angle bracket components.

We will be making the roadmap more explicit in the near future.

1 Like