These are chat archives for systemjs/systemjs

7th
Jan 2016
Jeremy Danyow
@jdanyow
Jan 07 2016 01:08
@guybedford here's a start:
Jeremy Danyow
@jdanyow
Jan 07 2016 01:40
and a short blog post
Guy Bedford
@guybedford
Jan 07 2016 15:18
@jdanyow excellent!
Chris Grant
@ChrisGrant
Jan 07 2016 17:39

Wondering if anyone can help me... I have a library in node_modules, but systemjs isn't looking in node modules for it. The url it is looking for is http://localhost:3000/angular2-auth-lib/core but should be http://localhost:3000/node_modules/angular2-auth-lib/core. This is my system config.

  System.config({
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      },
      map: {
        'angular2-auth-lib': 'node_modules/angular2-auth-lib'
      }
    }
  });

Does anyone have any ideas as to what could be causing this?

it is being imported only here import {AppComponent, ROUTE_CONFIG} from 'angular2-auth-lib/core';
Scott Smith
@scottadamsmith
Jan 07 2016 17:41
Could be wrong, but I think you can only import 'angular2-auth-lib' as that is your map key name
Chris Grant
@ChrisGrant
Jan 07 2016 17:44
Hmmm maybe, but then my typescript won't compile
Scott Smith
@scottadamsmith
Jan 07 2016 17:47
If you import something that isn't mapped, I believe it tries to import it directly via the path from the site root, which would explain the behavior you are seeing. Is core a js file within the angular2-auth-lib directory?
Chris Grant
@ChrisGrant
Jan 07 2016 17:49
yeah
Scott Smith
@scottadamsmith
Jan 07 2016 17:51
Can you add core within the mapping and then omit it in your imports?
if you append /core to your map and then change your import to omit /core
I'd think that would work.
Chris Grant
@ChrisGrant
Jan 07 2016 17:58
yeah that did it thank you
Scott Smith
@scottadamsmith
Jan 07 2016 17:58
great, glad to hear it
Chris Smola
@Smolations
Jan 07 2016 19:02
hello web tech progressives! i've been trying to convert a requirejs-driven angular SPA to use jspm instead, but am having trouble. have i come to the right place, by chance? =X
or is it just IRC-style where i just ask a question and cross my fingers for a response? lol
Scott Smith
@scottadamsmith
Jan 07 2016 19:04
possibly depending on the question, but for some questions the for more JSPM specific issues, you might have better luck in https://gitter.im/jspm/jspm
Chris Smola
@Smolations
Jan 07 2016 19:05
well right now i'm in the config phase, so my issues have to do with configuration options in package.json
Scott Smith
@scottadamsmith
Jan 07 2016 19:06
Let me know what your issue is and I will help if I can. I'm relatively new to both projects as well.
Chris Smola
@Smolations
Jan 07 2016 19:07
but you could probably answer this: every time i run jspm install/update, both package.json and my config.js are touched. install/init docs say that running those commands should update config.js with the package.json config. the docs for update say that the deps versions should just be updated. however, i feel like there are several occasions where changes in either of those files get reverted. is that due to bad config? or am i missing something else?
i'm just trying to get the workflow down basically...haha
Scott Smith
@scottadamsmith
Jan 07 2016 19:10
I think it would have to hit both files to update dependencies in package and then maps in config. That said, I am fairly certain that it you can make manual changes (i.e. paths/maps to local resources or CDNs) and they would be intact. But if you made a mapping for something like jQuery, but then installed jQuery, I imagine it would overwrite your change.
Also, if you do an install with overrides, it would have to write that to the package config
Chris Smola
@Smolations
Jan 07 2016 19:16
alright i suppose i will be more mindful of the changes i make. next question: i have just a few libs in a local lib folder. however, i don't know how to bring those into the project. can i specify that config in package.json or do i need to modify config.js for those files? i've tried using the "map" property in the package file, but requiring the lib in entry point file results in an error. reading docs around "shim," "map," and "meta," along with seeing people use an "overrides" property (not mentioned in the docs) has me all confuzzled. :see_no_evil:
the lib files are single js files that need to get loaded up so they can later be DI'ed into the app
Scott Smith
@scottadamsmith
Jan 07 2016 19:18
is lib within the baseURL?
Chris Smola
@Smolations
Jan 07 2016 19:18
it is
its a rails app so operating under the whole /public/ paradigm.
Scott Smith
@scottadamsmith
Jan 07 2016 19:20
not familiar with rails apps, but you should be able to create custom maps for them or just import them directly without a mapping using the path (i.e. import 'lib/main.js')
Chris Smola
@Smolations
Jan 07 2016 19:21
/public
  /app
  /assets
    /jspm_packages
  /lib
  config.js
package.json
Scott Smith
@scottadamsmith
Jan 07 2016 19:21
if you import a path that doesn't match a map, it should just try and resolve it within the baseURL
Chris Smola
@Smolations
Jan 07 2016 19:21
yea the weird thing is that it's trying to resolve to a jspm package
Scott Smith
@scottadamsmith
Jan 07 2016 19:21
what does your import look like?
Chris Smola
@Smolations
Jan 07 2016 19:22
System.import('app/main');
which seems to load just fine
strangely, the mapping of that lib in config.js is mapping to a github repo (i was trying that before using the existing local lib)
i know ive run an update command since i changed it though...
Scott Smith
@scottadamsmith
Jan 07 2016 19:24
Right, what does the import for the lib directory look like?
assuming it is on main or somewhere up the tree from there
Oh, the config.js has it pointing to a jspm_packages map?
Chris Smola
@Smolations
Jan 07 2016 19:26
yeaaaaa
Scott Smith
@scottadamsmith
Jan 07 2016 19:26
if you want to change it to a local lib, I'd just uninstall it via jspm and then create the map manually.
Chris Smola
@Smolations
Jan 07 2016 19:26
package.json:
"jspm": {
  "directories": {
    "baseURL": "public",
    "packages": "public/assets/jspm_packages"
  },
  "map": {
    "angular-bootstrap": "./public/lib/ui-bootstrap-tpls-0.10.0"
  },
  ...
}
Scott Smith
@scottadamsmith
Jan 07 2016 19:26
or just import using the path directly.
no map
and the import 'angular-bootstrap' is resolved to jspm_packages with that config?
Chris Smola
@Smolations
Jan 07 2016 19:28
config.js:
// ...
  map: {
    "angular": "npm:angular@1.4.7",
    "angular-bootstrap": "github:angular-ui/bootstrap@0.10.0",
    ...
  }
and i just ran an update too
Scott Smith
@scottadamsmith
Jan 07 2016 19:28
oh wait, I am not even sure you can define the map on package.json
unless it is just something I am unfamiliar with.
Chris Smola
@Smolations
Jan 07 2016 19:28
Scott Smith
@scottadamsmith
Jan 07 2016 19:30
I think that is the spec for making your package available for the JSPM registry?
Keep in mind, I could be wrong on some of this. I'd say remove the map from package.json and change the one on config.js to use the local lib
Chris Smola
@Smolations
Jan 07 2016 19:30
also, old tutorials ive found say "*": "*.js" is automatically added to the config by jspm, but it doesn't do that with newer version i guess and when i tried it was reverted. i figured i would need that for this problem but maybe i don't?
alright ill give that a shot
Scott Smith
@scottadamsmith
Jan 07 2016 19:31
I don't have the "": ".js" path in place, and I can import by path no problem.
Chris Smola
@Smolations
Jan 07 2016 19:36
boom, totally worked. thanks scott! :+1:
Scott Smith
@scottadamsmith
Jan 07 2016 19:37
No problem, glad it worked.
Chris Smola
@Smolations
Jan 07 2016 19:37
i was hoping that i could configure almost everything in package.json, but at least now i know i should spend more time in the config file