These are chat archives for systemjs/systemjs

22nd
Jan 2015
Ben Monro
@benmonro
Jan 22 2015 05:35 UTC
am i missing something? I want to add a plugin to SystemJS that uses the fetch hook. Once i define a module that uses exports.fetch, how do I register my plugin so that calls to System.import will hit my plugin first?
Guy Bedford
@guybedford
Jan 22 2015 08:20 UTC
if you want to link a browserify bundle into SystemJS it may be better to reconstruct the bundle as a System-compatible bundle
that will use System.register calls to define in the System's registry
if you wanted to make a custom interface you could do something like
System.set('some/module', System.newModule(require('some/browserify/module')));
but it's not advisable
plugins load when you use the ! syntax
you're right there is lacking documentation on this topic
that is, how to install a plugin
Lucas Heymès
@lovethebomb
Jan 22 2015 11:10 UTC
Hello! First of all, nice projects (jspm and systemjs)! I was testing around two or three things based on an old requirejs project, and I was wondering what would be the best move to use shim (as defined by requirejs http://requirejs.org/docs/api.html#config-shim), especially for old 'exotic' libraries?
thinking of Zepto for instance, that need to define another shim like 'zepto': { exports: '$' }
Lucas Heymès
@lovethebomb
Jan 22 2015 13:44 UTC
Didn't see this old issue, systemjs/systemjs#171, will act according to it!
Matthew Phillips
@matthewp
Jan 22 2015 14:05 UTC
Hey @guybedford I'm trying to reconstruct a "clone" for SystemJS. I thought simply calling upgradeSystemLoader (and swapping out the global.System) would be enough to do this but I get a maximum call-stack error when I try to import something with either the originally or "cloned" loader. Have any ideas what I am doing wrong?
Guy Bedford
@guybedford
Jan 22 2015 14:15 UTC
@lovethebomb glad to hear you found a solution, docs on shim can be found at https://github.com/systemjs/systemjs/wiki/Module-Format-Support#globals-global.
@matthewp see https://github.com/systemjs/builder/blob/master/index.js#L21 for an example of how to clone System
Matthew Phillips
@matthewp
Jan 22 2015 14:18 UTC
Thanks, won't, for example, loader.map be undefined since you're not running the map extension against the cloned loader?
Guy Bedford
@guybedford
Jan 22 2015 14:19 UTC
The extensions are all designed to do this check - https://github.com/systemjs/systemjs/blob/master/lib/extension-map.js#L125
the main reason why extensions has been a frustrating pattern
Matthew Phillips
@matthewp
Jan 22 2015 14:19 UTC
Ah, awesome, yes I agree we should look for a way to improve this.
Guy Bedford
@guybedford
Jan 22 2015 14:20 UTC
classes feels like the best bet, but I do worry about the deep inheritance chain too
Matthew Phillips
@matthewp
Jan 22 2015 14:20 UTC
You think performance will hurt?
Guy Bedford
@guybedford
Jan 22 2015 14:20 UTC
it's actually pretty much the same as what we do now, so I guess not
just seems a waste to define the intermediate classes
when it is effectively multiple inheritance
the alternative was just to add extensions like
Matthew Phillips
@matthewp
Jan 22 2015 14:21 UTC
yes but as you say it's essentially what we do now
Guy Bedford
@guybedford
Jan 22 2015 14:21 UTC
loader._extensions = [ext1, ext2]
add the functions themselves to the list
so clone is simple to replicate
Perhaps that may be the simplest middle ground
Matthew Phillips
@matthewp
Jan 22 2015 14:22 UTC
that might work
Guy Bedford
@guybedford
Jan 22 2015 14:22 UTC
clone(loader) = loader._extensions.forEach((ext) => ext(newLoader));
PRs welcome :)
Matthew Phillips
@matthewp
Jan 22 2015 14:22 UTC
You'd accept a System.clone that does that?
Guy Bedford
@guybedford
Jan 22 2015 14:22 UTC
yeah
Matthew Phillips
@matthewp
Jan 22 2015 14:22 UTC
I'd be happy to take that one
awesome
Guy Bedford
@guybedford
Jan 22 2015 14:23 UTC
awesome
should be in the core extension
then other extensions add to it
then we can throw out the awful stateless checks
and it enables private extension state finally
Matthew Phillips
@matthewp
Jan 22 2015 14:24 UTC
other extensions just do loader._extensions.push(map)
Guy Bedford
@guybedford
Jan 22 2015 14:24 UTC
exactly
Matthew Phillips
@matthewp
Jan 22 2015 14:24 UTC
well you'd do that in the makefile i assume
Guy Bedford
@guybedford
Jan 22 2015 14:24 UTC
or that too
base clone implementation should include baseURL copy as well
etc
like in the builder implementation
Matthew Phillips
@matthewp
Jan 22 2015 14:25 UTC
right
and paths = { "": ".js" }
Guy Bedford
@guybedford
Jan 22 2015 14:25 UTC
config cloning is a little harder
as it should copy not reference
etc
Matthew Phillips
@matthewp
Jan 22 2015 14:25 UTC
config values?
Guy Bedford
@guybedford
Jan 22 2015 14:25 UTC
yeah
Matthew Phillips
@matthewp
Jan 22 2015 14:25 UTC
I don't know if those should be copied at all
Guy Bedford
@guybedford
Jan 22 2015 14:26 UTC
make it a separate thing
right
var newLoader = loader.clone();
newLoader.config(loader);
actually make it entirely manual
newLoader.config({ baseURL: loader.baseURL });
or newLoader.config(require('loaderconfig.json'))
you're right
Matthew Phillips
@matthewp
Jan 22 2015 14:28 UTC
cool, i'm going to try and set some time to work on this this weekend
Guy Bedford
@guybedford
Jan 22 2015 14:28 UTC
great thanks that would be nice
cloning has been painful still
Matthew Phillips
@matthewp
Jan 22 2015 14:28 UTC
yeah
I want more modular tooling against systemjs
Guy Bedford
@guybedford
Jan 22 2015 14:29 UTC
yeah I want to move away from mutability entirely too
Matthew Phillips
@matthewp
Jan 22 2015 14:29 UTC
so i was going to port our dependency graph to it's own module
dependencyGraph('app/main').then(function(graph) { })
but a clone is needed
have to go, good talking to you
Guy Bedford
@guybedford
Jan 22 2015 14:32 UTC
sure, you too
Ben Monro
@benmonro
Jan 22 2015 16:34 UTC
Hi @guybedford, in response to above re: System.set('./module', require('browserify/module')), how can I convert a normal cjs module into one that System understands? Is there a System.xxx() method that allows me to do that? Or do I have to do that myself? I get Uncaught TypeError: Loader.set(./blah, module) must be a module when I try to do that above...
Also on the topic of System.registry I am unclear on how that even works even after reading the article about System.registry explained... :(