These are chat archives for systemjs/systemjs

12th
Apr 2015
nnscr
@nnscr
Apr 12 2015 14:48 UTC

hi guys, i try to load a class through a es6 export which is transpiled with traceur and then loaded through systemjs. when loading my module through
import DepartmentsController from 'hrm-departments-controller'

i get the following error:
Uncaught TypeError: Cannot read property 'exports' of undefined

which points to the following location in my transpiled code:
Object.defineProperties(module.exports, {.

I figgured out that all other files that were loaded by systemjs are wrapped by
(function(global, exports, module, require, __filename, __dirname) { <code> }).call(_g.exports, _g.global, _g.exports, _g.module, _g.require, _g.__filename, _g.__dirname);

but my controller that triggers the above error does not have this wrapper around it in chromes source view... does any one have an idea?

maybe i need to tell systemjs that my module is commonjs manually, but how can i achieve this?
Guy Bedford
@guybedford
Apr 12 2015 14:59 UTC
@nnscr you can enforce the format via meta config
System.meta['hrm-departments-controller'] = {format: 'cjs'}
note that the above needs to be the fully normalized name after applying map config
if you're unsure what to use, you can call System.normalize('hrm-departments-controller').then(console.log.bind(console)) to see
nnscr
@nnscr
Apr 12 2015 15:00 UTC

so when 'hrm-departments-controller' is defined as following: "hrm-departments-controller": "nnscrHRM/js/departments_controller"

i'd need to use System.meta['nnscrHRM/js/departments_controller']?

Guy Bedford
@guybedford
Apr 12 2015 15:01 UTC
exactly
nnscr
@nnscr
Apr 12 2015 15:01 UTC
that was the problem, thank you!
Guy Bedford
@guybedford
Apr 12 2015 15:01 UTC
it is better to transpile with the instantiate format in Traceur
which will output System.register
but if you're not hitting circular references or bindings cases it's not critical
nnscr
@nnscr
Apr 12 2015 15:08 UTC
mhh... do you mean .pipe(traceur({modules: "instantiate"})) idead of .pipe(traceur({modules: "commonjs"}))?
because this does not change my output files
oh, now it does, my bad. sorry and thanks again :) thats even better