These are chat archives for systemjs/systemjs

13th
Oct 2015
George Song
@gsong
Oct 13 2015 13:20
Does anyone know how you’re suppoed to properly import modules such as angular-ui-router? import uiRouter from ‘angular-ui-router’ yields an empty object.
Sean G. Wright
@sgwatgit
Oct 13 2015 13:31
@gsong take a look at this. it's a WIP but it uses ui router w/ imports
https://github.com/sgwatgit/jspm-systemjs-angular-1x
I tried the same thing and it doesn’t work for me in my project.
@sgwatgit I see, nm, you’re still injecting using ‘ui.router’. My expectation would be that uiRouter === 'ui.router'
Sean G. Wright
@sgwatgit
Oct 13 2015 14:37
@gsong the import statement makes sure that the .js files for ui-router are loaded into the bundle (or on demand depending on your workflow) and the angular module dependency ensures that angular's DI system has access to ui-router when it is need in the app
George Song
@gsong
Oct 13 2015 14:39
@sgwatgit I understand. But the convention for Angular modules is to export its own name, right? And I’m wondering why in this case that name isn’t picked up by SystemJS since ui-router is a CJS module, and it does export ’ui.router’.
Sean G. Wright
@sgwatgit
Oct 13 2015 14:52
@gsong ah good point. I hadn't looked to see what ui-router was exporting and i assumed it wasn't the module name or the angular module (which some other packages i have seen, do)
the line https://github.com/angular-ui/ui-router/blob/master/release/angular-ui-router.js#L10 leads me to believe, like you, that you should be able to do something like
import angular from 'angular'
import uiRouter from 'angular-ui-router';

// If uiRouter exports string name
let module1 = angular.module('module1', [uiRouter]);
// if uiRouter exports angular module
let module2 = angular.module('module2', [uiRouter.name]);
George Song
@gsong
Oct 13 2015 14:53
@sgwatgit Exactly.
But instead, uiRouter is an empty object.
Andrew Stoker
@AStoker
Oct 13 2015 15:43
Is there a way to have SystemJS imports go off of a baseUrl? So that if I'm inside a nested folder, I can still access a file in the root by just typing the file? I would still want the ability to use relative paths like ./siblingFile.js.
Sean G. Wright
@sgwatgit
Oct 13 2015 16:01
@AStoker why not name your imports in the config.js map section?
Andrew Stoker
@AStoker
Oct 13 2015 16:09
But what if I'm trying to reference my own files that I'm creating @sgwatgit ? Should I name every file I create that I want to access?
Sean G. Wright
@sgwatgit
Oct 13 2015 16:12

that's the approach i've taken. files/exports i want in various places in my app i end up treating like i would a 3rd party module - i name it in my map and import the name. if it's relative to a given file then it's probably a related piece of that module and i use the relative import statement.

if you want to limit the number of files you name in your map you could re-export from a select few files and treat those as components.

Sean G. Wright
@sgwatgit
Oct 13 2015 19:30
@guybedford what's the current recommendation on defaultJSExtensions in a project with jspm & systemjs? if we want to follow best practices what should the approach be? if i'm updating my import statements right now and using the latest versions of jspm/systemjs, should i be importing files with their extensions?
Sean G. Wright
@sgwatgit
Oct 13 2015 19:44
should i write my imports like import mod from './local-file-module.js' and leave defaultJSExtension: true until jspm 0.17 is out?
scottmas
@scottmas
Oct 13 2015 23:10
Quick question: is there a tool to generate the depCache for the SystemJS config file? I want to have an automated way of building it when I push to production
I'm looking at es-dependency-graph but wasn't able to tell if the functionality is built into SystemJS
MaDGe appears to support all the major module formats
scottmas
@scottmas
Oct 13 2015 23:16
Also, another question: If I properly configure my depCache, does http2 server push mostly become redundant?
scottmas
@scottmas
Oct 13 2015 23:16
Blimy
Didn't see that