These are chat archives for systemjs/systemjs

19th
Nov 2015
Jithin Emmanuel
@jithin1987
Nov 19 2015 01:03
Hello, how can I run a mocha based test to have require/import going though system.js ?
Igor
@PinkaminaDianePie
Nov 19 2015 05:15
related question. how can i dynamically change baseURL? i use multiple mock projects to test my app, so i need to change base url in tests. before using SystemJS it was enough to run process.chdir(), but for now i need to do something with base URL
Tyler J Presley
@TylerJPresley
Nov 19 2015 07:05
I'm trying to load bootstrap with a dependency of Tether.. I can't seem to get it to work.
I've added tether as a dependency, but BS still can't see it.
BS is looking for it in window. What's the best way to approach this?
  if (window.Tether === undefined) {
    throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)');
  }
Klaus Bayrhammer
@klausbayrhammer
Nov 19 2015 09:14
@PinkaminaDianePie I had a similar problem and ended up splitting the config files (one defining the baseurl and one with all the other stuff). For the tests we configured the baseUrl manually and loaded the config file without the baseURL
Guy Bedford
@guybedford
Nov 19 2015 09:21
(for Bootstrap on Tether)
@PinkaminaDianePie @klausbayrhammer best approach is to create another loader with a difference baseURL, see https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemconstructor
Joeri de Gooijer
@joerideg
Nov 19 2015 13:25
guys, I cannot find a single gulp-systemjs plugin on npm. Am I missing something?
I'm trying to use the systemjs-builder (making a self executing bundle) with gulp, but gulp, of course, is based on streams where as the systemjs builder expects a file path and outputs a file in a path.
Tyler J Presley
@TylerJPresley
Nov 19 2015 14:18
@guybedford should it be:
meta: {
    "jspm_packages/github/TylerJPresley/bootstrap@v4-dev.js": {
      globals: {
        tether: "jspm_packages/github/HubSpot/tether@1.1.1.js"
      }
    }
  },
I forked so that I could expose the scss to my proj.
Peter Uithoven
@peteruithoven
Nov 19 2015 15:37
@jithin1987 Maybe the following issue can help? systemjs/systemjs#736
Jithin Emmanuel
@jithin1987
Nov 19 2015 15:54

@peteruithoven I followed through the examples , but babel is crashing when I try to import.

>> Mocha exploded!
>> TypeError: Cannot read property 'src' of undefined
>>     at /Users/jithine/dev/simple/node_modules/systemjs/dist/system.src.js:4576:31

This is my code

import System from 'systemjs';

import '../../../config.js';

describe('NavBar', () => {
  let sandbox,
    flags = {},
    NavBar,
    navLinks,
    navNode;
  beforeEach(() => {
    sandbox = sinon.sandbox.create();
    return System.import('./src/components/common/NavBar.js')
      .then((mod) => NavBar = mod);
  });
Peter Uithoven
@peteruithoven
Nov 19 2015 15:56
@jithin1987 Why are you importing that navbar async? Are you running this in Chrome? Usually you can click the (...) behind the error in the console for more information.
Jithin Emmanuel
@jithin1987
Nov 19 2015 15:59
@peteruithoven This is a mocha test running on nodejs.
wtfguy
@wtfguy
Nov 19 2015 15:59
Hi does someone have any idea why an "npm install -g jspm-bower-endpoint" does not work for me? I am on Win7 and when i do a "jspm-bower-endpoint" i get a command not found. There was no error when installing.
Jithin Emmanuel
@jithin1987
Nov 19 2015 15:59
complete log
>> Mocha exploded!
>> TypeError: Cannot read property 'src' of undefined
>>     at /Users/jithine/dev/simple/node_modules/systemjs/dist/system.src.js:4576:31
>>     at Object.<anonymous> (/Users/jithine/dev/simple/node_modules/systemjs/dist/system.src.js:4605:3)
>>     at Module._compile (module.js:460:26)
>>     at Module._extensions..js (module.js:478:10)
>>     at Object.require.extensions.(anonymous function) [as .js] (/Users/jithine/dev/simple/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:214:7)
>>     at Module.load (module.js:355:32)
>>     at Function.Module._load (module.js:310:12)
>>     at Module.require (module.js:365:17)
>>     at require (module.js:384:17)
>>     at Object.<anonymous> (/Users/jithine/dev/simple/node_modules/systemjs/index.js:26:22)
Peter Uithoven
@peteruithoven
Nov 19 2015 16:01
@jithin1987 Sounds like two bad ideas combined? Using Mocha (with the whole globals debacle) and using SystemJS / JSPM in Node.js.
Jithin Emmanuel
@jithin1987
Nov 19 2015 16:03
is system.js meant for browser usage only ? I guess my alternative would be to run this in karma.
Peter Uithoven
@peteruithoven
Nov 19 2015 16:05
I'm not sure, but it's focused on browsers. SystemJS builds on the new module loading polyfill, which polyfills upcomming browser functionality.
Since you're probably developing for browsers I found it made more sense to also run my unit tests in the browser
I'll admit, it's not ideal, especially not for continuous Integration
Jithin Emmanuel
@jithin1987
Nov 19 2015 16:07
Even if I don't use system.js everything works except for css file imports. I wam also exploring if I can somehow tell babel to do something when it encounters a css file
Peter Uithoven
@peteruithoven
Nov 19 2015 16:09
Babel and css files? The module loader spec allows writing alternative loaders for, for example css files. I think SystemJS makes this easier.
Igor
@PinkaminaDianePie
Nov 19 2015 16:20
@peteruithoven why using SystemJS is bad idea for node?
Peter Uithoven
@peteruithoven
Nov 19 2015 16:22
@PinkaminaDianePie I've never said that. I'm just sharing that I only use it in the browser.
Peter Uithoven
@peteruithoven
Nov 19 2015 16:31
It would be a great thing to figure out, because it would make things like unit tests easier
Sharon (Sean) Rolel
@Mosho1
Nov 19 2015 17:59
is there anything special I should do in node? the import call returns a Promise but the node process exists immediately the callback isn't called
Jithin Emmanuel
@jithin1987
Nov 19 2015 18:14

I am now stuck at a babel error. I guess my system.js is now properly loading in node.

  1) NavBar "before each" hook for "should have two apps to navigate when metering is enabled":
     the string "ReferenceError: file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33/browser.js:67185\nglobal[\"babel\"] = babel;\n                  ^\nbabel is not defined\n\tEvaluating file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33/browser.js\n\tEvaluating file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33.js\n\tError loading file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33.js\n\tError loading file:///Users/jithine/dev/simple/src/components/common/NavBar.js" was thrown, throw an Error :)
  Error: the string "ReferenceError: file://jspm_packages/npm/babel-core@5.8.33/browser.js:67185\nglobal[\"babel\"] = babel;\n                  ^\nbabel is not defined\n\tEvaluating file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33/browser.js\n\tEvaluating file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33.js\n\tError loading file:///Users/jithine/dev/simple/jspm_packages/npm/babel-core@5.8.33.js\n\tError loading file:///Users/jithine/dev/simple/src/components/common/NavBar.js" was thrown, throw an Error :)
      at lib$es6$promise$$internal$$tryCatch (node_modules/grunt-postcss/node_modules/es6-promise/dist/es6-promise.js:326:16)
      at lib$es6$promise$$internal$$invokeCallback (node_modules/grunt-postcss/node_modules/es6-promise/dist/es6-promise.js:338:17)
      at lib$es6$promise$$internal$$publish (node_modules/grunt-postcss/node_modules/es6-promise/dist/es6-promise.js:309:11)
      at lib$es6$promise$$internal$$publishRejection (node_modules/grunt-postcss/node_modules/es6-promise/dist/es6-promise.js:259:7)
      at lib$es6$promise$asap$$flush (node_modules/grunt-postcss/node_modules/es6-promise/dist/es6-promise.js:120:9)

It could be that node requires a different babel to load ?

So I tried overriding babel path via

System.config({
  map: {
    babel: 'node_modules/babel/bin/babel-node.js'
  }
});

which is giving another weird issue

     ENOENT, open '/Users/jithine/dev/simple/path.js'
  Error: ENOENT, open 'path.js'
      at Error (native)
        Error loading file://path.js as "path" from file:///Users/jithine/dev/simple/node_modules/babel/lib/babel-node.js
        Error loading file://src/components/common/NavBar.js

I guess I am on wrong track.

Jithin Emmanuel
@jithin1987
Nov 19 2015 19:55
@peteruithoven I got the mocha stuff finally working on nodejs. system.js was bailing out on me, so babel directly, and overrode css imports via 'resolveModuleSource' to return a dummy module.