These are chat archives for systemjs/systemjs

14th
Jun 2016
Yahya Kacem
@yahyaKacem
Jun 14 2016 10:04

Hi, does anyone know how to make local modules importable by alias,
instead of typing the whole path, so instead of:

import { SomeModule } from '../../../../shared';

it would be:

import { SomeModule } from 'shared';

maybe something in the map, or paths, is there an example for this?

Andrei Balmus
@abalmush
Jun 14 2016 10:05

Guys I’m getting very strange issue, System.normalize() returns different paths on my local and test environments, the example:

<script>
            System.baseURL = '/_ui/';
            System.import('isomorphic-fetch');
</script>

// Local Environment - Path: http://127.0.0.1:9001/en_GB/
System.normalize('isomorphic-fetch').then(function() { console.log(arguments); })
//returns
["http://127.0.0.1:9001/_ui/lib/npm/isomorphic-fetch@2.2.1.js”]

//Test Environment - Path: http://mytestenvironment.com/en_GB/
System.normalize('isomorphic-fetch').then(function() { console.log(arguments); })
//returns
["http://mytestenvironment.com/en_GB/lib/npm/isomorphic-fetch@2.2.1.js"]

The local paths are correct with _ui, but test replacing _ui with en_GB, any ideas? What I’m doing wrong?

Andrei Balmus
@abalmush
Jun 14 2016 10:11
maybe it related to PORT number?
Andrei Balmus
@abalmush
Jun 14 2016 10:53
no ideas guys ? :worried: fyting with this issue all day
all modules from jspm_modules/npm are 404 but they are in that folder, I’ve just renamed it to lib in jspm config
Guy Bedford
@guybedford
Jun 14 2016 11:30
@abalmush try inspecting the value of System.baseURL before running System.normalize
Andrei Balmus
@abalmush
Jun 14 2016 11:35
@guybedford thanks for your ansver!
System.baseURL
"http://mytestenvironment.com/_ui/"

System.baseURL
"http://127.0.01:9001/_ui/“
Looks liek they are ok on both environments :( but on test environments it resolves all jspm modules relative the current path not the base path
Guy Bedford
@guybedford
Jun 14 2016 11:49
@abalmush and System.map, System.paths?
Andrei Balmus
@abalmush
Jun 14 2016 11:59
System.map are the same.
System.paths
Object {github:*: "http://mytestenvironment.com/en_GB/lib/github/*", npm:*: "http://mytestenvironment.com.com/en_GB/lib/npm/*”}

System.paths
Object {github:*: "lib/github/*", npm:*: "lib/npm/*”}
The paths are different
but I dont undertend how it was changed
in my jspm.config.js they are absolutelly the same
Also I found that I have newest jspm version on test environment
with this fix systemjs/builder@eabc810
on local I have older version
Guy Bedford
@guybedford
Jun 14 2016 12:04
Paths would explain it then. What are the paths in the configuration file?
Andrei Balmus
@abalmush
Jun 14 2016 12:05
  paths: {
    "github:*": "lib/github/*",
    "npm:*": "lib/npm/*"
  },
After JPSM update on my local environment, same issue :)
Guy Bedford
@guybedford
Jun 14 2016 12:06
Make sure you set your baseURL before the paths configuration
Andrei Balmus
@abalmush
Jun 14 2016 12:07
ok one sec
Guy Bedford
@guybedford
Jun 14 2016 12:10
@HendrikRoth that error is supposed to only show when running in Node without XMLHttpRequest support... so if you're running in a browser, then it means you don't have window.XMLHttpRequest for some reason!?
Andrei Balmus
@abalmush
Jun 14 2016 12:11
yay! @guybedford thanks with baseURL inside jspm config works well!
thanks!
David
@DavidStrada
Jun 14 2016 18:37
@yahyaKacem you can do it on the paths
paths: {
    “shared”: "../../../../shared"
  },
however when bundleling or building I have found some errors by doing it so. It’s a matter of testing i guess.
Hendrik Roth
@HendrikRoth
Jun 14 2016 22:09
@guybedford no xmlhttprequest support in node? how can i change this?
Guy Bedford
@guybedford
Jun 14 2016 22:16
@HendrikRoth so it's the Node case that's not working? If so, yes loading network modules in non-browser NodeJS environments is not supported in SystemJS, because you should be accessing the filesystem directly in these environments. Fetch without a non-HTTP cache layer would just be silly.
Hendrik Roth
@HendrikRoth
Jun 14 2016 22:17
@guybedford yes it’s the node case.
@guybedford i used systemjs to load data from apis in an isomorphic app. so it would be nice to fetch externes sources in this case.
Guy Bedford
@guybedford
Jun 14 2016 22:18
that makes sense, although perhaps use an isomorphic fetch polyfill for this use case rather?
Hendrik Roth
@HendrikRoth
Jun 14 2016 22:19
@guybedford i am doing this already :-)
Guy Bedford
@guybedford
Jun 14 2016 22:19
:+1: