These are chat archives for systemjs/systemjs

13th
Mar 2015
Adrian Mitev
@amitev
Mar 13 2015 11:38
I have a .js file that exports a class but doesn't import anything. If I compile it using Traceur (with default modules mode) I get an error when using it that says 'module.exports is not defined' and by looking at the compiled js file the 'module' variable is specified nowhere (and looks like it's not in the globals). If I import anything (whatever it is) in that module, everything works fine. Idea why Traceur is doing that to me and how to workaround it? P.S. if i use the AMD mode for compilation, everything works fine.
Guy Bedford
@guybedford
Mar 13 2015 12:32
@amitev you should use the instantiate modules output for Traceur. see https://github.com/ModuleLoader/es6-module-loader/wiki/Production-Workflows
SystemJS understands the System.register format natively
Adrian Mitev
@amitev
Mar 13 2015 12:41
@guybedford that worked. Thank you!
Adrian Mitev
@amitev
Mar 13 2015 12:52
Unfortunately the instantiate mode breaks the unit tests (karma-jspm). For some reason the testing framework cannot load my compiled code.
rasmus
@rspi
Mar 13 2015 13:50

hello

I also have two questions regarding testing and test coverage (using istanbul):

I have a angular project where I run tests on my instantiate build with karma (= browser).
Importing the tests with system.import (and system.import inside tests).
It runs the tests and everything works. but the test coverage report is a bit messed up because the coverage follows all the internal imports.
Not really a big problem but I wonder how I would mock out the imports to only test one file at a time?

In my second mithril app I try to run tests using node (mocha), and importing my files inside the test with jspm.import.
this also works but here the coverage is always 0.

Any idea how to make it work better?

rasmus
@rspi
Mar 13 2015 13:59
@amitev I got testing working by doing something similar to this: https://github.com/gocardless/es6-angularjs. Look at config/karma-spec-loader.config.js
Dave Ackerman
@dmackerman
Mar 13 2015 14:02
any special magic I have to do to get my bundle working? The bundle succeeded, but when I do System.import('app/app.module') it still loads every dependency individually and not the bundle?
Dave Ackerman
@dmackerman
Mar 13 2015 14:10
nevermind, forgot the bundle before I import :)
Adrian Mitev
@amitev
Mar 13 2015 15:02
@rspi +1 for "mock out the imports to only test one file at a time"
Dave Ackerman
@dmackerman
Mar 13 2015 21:27
is there a difference between a bundle built by https://github.com/systemjs/builder and the jspm "jspm bundle" comnmand?
Dave Ackerman
@dmackerman
Mar 13 2015 21:35
also, I get this weird error when I try to build my bundle with the system-js builder:
Potentially unhandled rejection [4] Error: Error loading "github:components/jquery@2.1.3"