Skip to content

Instantly share code, notes, and snippets.

@joliss
Last active December 18, 2015 14:49
Show Gist options
  • Save joliss/5799831 to your computer and use it in GitHub Desktop.
Save joliss/5799831 to your computer and use it in GitHub Desktop.
  1. We talked about modules exporting their objects, rather than tacking them onto some global namespace object (window.Ember) as a side effect of loading the module. Do we have any nice patterns to translate a modules that register stuff (e.g. https://github.com/SlexAxton/require-handlebars-plugin/blob/master/demo/template/helpers/yeller.js) into a side-effect-free syntax?

  2. Let's assume module "foo" registers something global as a side effect. Do I read http://wiki.ecmascript.org/doku.php?id=harmony:modules#external_module_load correctly that import "foo" will not only fetch "foo" at compile time, but also run the "foo" module at run time, if it hasn't already run? (So any global side effects will have happened after import "foo".)

  3. Rails auto-loads all my Ruby files. That's super-convenient. Also for JavaScript, the Rails asset pipeline not only has //= require foo (which becomes import "foo"), but //= require_tree .. Obviously there is no 1:1 equivalent for require_tree, but do we have any kind of strategy/story for this?

@joliss
Copy link
Author

joliss commented Jun 17, 2013

@wycats Any ideas? ^

@stefanpenner
Copy link

@joliss i have had success making the resolver module aware. This prevents lots of the extra import boiler plate in large apps.

@joliss
Copy link
Author

joliss commented Jun 18, 2013

Just had a conversation with Stefan. Summary re the questions in this gist:

  1. Handlebars templates might look up the helper on the container, which in turn can automatically load the module. (There's probably still some stuff to be figured out, but it's a first step.)
  2. Still waiting for @wycats on this one.
  3. It seems that in a lot of cases we can go without auto-loading everything (like Rails does), without having imports all over the place. And in cases where we do need to load things, perhaps the build tool can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment