These are chat archives for systemjs/systemjs

10th
Jun 2016
RaleS
@RaleS
Jun 10 2016 08:20
Is there a way to load systemjs in a webworker?
Michael Bøcker-Larsen
@mblarsen
Jun 10 2016 08:28
I’m a bit confused about meta.deps. Can it be the case that I have to specifiy file paths (full or with glob) for deps to be picked up:
System.config({
  baseURL: '/',
  defaultJSExtensions: true,
  transpiler: 'babel',
  babelOptions: {
    stage: 1,
  },
  meta: {
    'js/app.js': { deps: [ 'clipboard' ] }, // works
    'app': { deps: [ 'clipboard' ] },       // doesn't work
  },
  map: {
    app: 'js',
    clipboard: 'assets/clipboard/dist/clipboard.min.js',
  },
  packages: {
    app: { main: 'app.js' },
  }
});
System.js should be able to derive that ‘app’ is: js (from map) + app.js (from packages) no?
Хан Юрий
@khanyuriy_twitter
Jun 10 2016 11:39
@RaleS yes, importScripts('path to System.js')
RaleS
@RaleS
Jun 10 2016 11:43
@khanyuriy_twitter I have tried that and getting 'require is not defined'
Хан Юрий
@khanyuriy_twitter
Jun 10 2016 12:15
@RaleS you have to import your entry script
importScripts('../node_modules/systemjs/dist/system.js');
System.config({
    defaultJSExtensions : true,
    baseURL: '/'
});
System.import('./workerCore');
same way like you do in host html page
RaleS
@RaleS
Jun 10 2016 12:56
@khanyuriy_twitter Since I am building it with tsc I need to import the worker
/// <reference path="../typings/systemjs.d.ts" />
importScripts('/scripts/node_modules/systemjs/dist/system.js');
System.config({
    baseURL: '/scripts',
    defaultJSExtensions: true,
});
System.import('./worker1-app.js'); 
import {Worker1App} from './worker1-app'; // <- compiled to const worker1_app_1 = require('./worker1-app');
var x = new Worker1App();
Хан Юрий
@khanyuriy_twitter
Jun 10 2016 13:01
import {Worker1App} from './worker1-app'; // <- compiled to const worker1_app_1 = require('./worker1-app');
var x = new Worker1App();
you need to place this code in the file, that you import with System.import()
RaleS
@RaleS
Jun 10 2016 13:14
@khanyuriy_twitter thanks