/**
     * Gets the routes from a module.
     * The module should export the routes array as a variable.
     *
     * @param moduleId    id of the module to load.
     * @returns {Promise}
     */
    getNavFromRoutes(moduleId){

        //prepare for use in windows

        System.config({
            "baseURL": "./",
            "transpiler": 'babel',
            "babelOptions": {
                "stage": 0
            },
            "paths":{
                "*": this.appPath+"/*.js"
            }
        });

        if(!moduleId) Promise.resolve(null);
        //get routes from the aurelia application
        return new Promise((resolve, reject) => {
            return System.import(moduleId).then(m=>{
                var navRoutes = [];
                for(var i = 0, l = m.routes.length; i < l; i++){
                    var route = m.routes[i];
                    if(route.nav) navRoutes.push(route);
                }
                resolve(navRoutes);
            });
        });


    }
Exemple #2
0
  .then(function() {
    var cfg = config.loader.getConfig();
    delete cfg.bundles;
    cfg.baseURL = 'file:' + config.pjson.baseURL;
    System.config(cfg);

    return System.import(moduleName);
  })
Exemple #3
0
  registerComponent: (appKey, componentProvider, config) => {
    if (config.systemConfig) {
      SystemJS.config(config.systemConfig)
    }
    const App = componentProvider()
    const { historyType } = App
    const AppWithRouter = withRouter(App)
    const history = historyType === 'hash'
      ? createHashHistory() : historyType === 'browser'
        ? createBrowserHistory()
        : createMemoryHistory()

    const loggerMiddleware = store => next => action => {
      if (process.env.NODE_ENV !== 'production') console.warn(action)
      return next(action)
    }

    const create = global.devToolsExtension ? global.devToolsExtension()(createStore) : createStore

    const createReducer = (asyncReducers) => combineReducers({
      router: routerReducer,
      routing: routerReducer,
      ...asyncReducers
    })

    const createStoreWithMiddleware = applyMiddleware(
      ReduxThunk,
      loggerMiddleware,
      routerMiddleware(history)
    )(create)

    const store = createStoreWithMiddleware(createReducer({}), {})
    store.asyncReducers = {}

    const injectReducer = (name, asyncReducer, force = false) => {
      warning(!store.hasOwnProperty(name) || force, `${name} has been injected, if you want to replace it, use force=true argument`)
      store.asyncReducers[name] = asyncReducer
      store.replaceReducer(createReducer(store.asyncReducers))
    }

    return ReactDOM.render(
      <Provider store={store}>
        <ConnectedRouter history={history}>
          <AppWithRouter store={store} injectReducer={injectReducer} />
        </ConnectedRouter>
      </Provider>,
      config.mountPoint
    )
  }
test('plugin-text should return the file as pure test', function (t) {
  t.plan(1)

  // when
  System.config({
    baseURL: path.resolve(__dirname, '..'),
    map: {
      txt: 'lib/plugin-text.js'
    }
  })

  return System.import(actualFilePath + '!')
    .then(function (actual) {
      t.same(expect, actual)
    })
})
 it('should do a jspm import right', async () => {
   System.config({
     baseURL: __dirname,
     defaultJSExtensions: true,
     paths: {
       'github:*': 'jspm_packages/github/*',
       'npm:*': 'jspm_packages/npm/*',
     },
     map: {
       'mock-package': 'npm:mock-package@1.0.0',
     },
   });
   const request = {
     current: 'jspm:mock-package/mock-asset',
     previous: 'stdin',
   };
   const p = await resolvePath(request, '/');
   // System.normalize in resolvePath will give us the absolute path
   const relative = `/${path.relative(__dirname, url.parse(p).path)}`;
   relative.should.equal(
     `/${path.join('jspm_packages', 'npm', 'mock-package@1.0.0', 'mock-asset.scss')}`
   );
 });
Exemple #6
0
var System = require('systemjs');
var resolve = require('resolve');
var path = require('path');

var folderPath = path.relative(process.cwd(), path.dirname(resolve.sync('systemjs-plugin-babel', { basedir: process.cwd() })));
var pluginPath = path.relative(process.cwd(), resolve.sync('babel-plugin-transform-es2015-modules-commonjs', { basedir: process.cwd() }));

System.config({
    map: {
        'systemjs-plugin-babel': folderPath + '/plugin-babel.js'
        , 'systemjs-babel-build': folderPath + '/systemjs-babel-node.js',
        'babel-plugin-transform-es2015-modules-commonjs': pluginPath
    },
     transpiler: 'systemjs-plugin-babel',
  babelOptions: {
    sourceMaps:'inline',
    presets:[],
    plugins: ['babel-plugin-transform-es2015-modules-commonjs']
  }
});

var prom=System.import('./src/test/test.js')

prom.catch(function (err) {
                    console.log(err.message);
                    console.log(err.stack);
                    throw err
                });

Exemple #7
0

// set traceur's options instead of using command line arguments

traceur.options.typeAnnotations = true;
traceur.options.typeAssertionModule = 'assert';
traceur.options.annotations = true;
traceur.options.generators = true;

var System = require('systemjs');


System.config({
    map: {
        'di': 'node_modules/di/src/index',
        'log': 'node_modules/diary/src',
        'ws': 'node_modules/ws/index'
    }
});

System.import('bin/main').then(function(app){


    return app.main();



},function(err){
    console.log(err)
}).catch(function(err){
  console.log(err);
Exemple #8
0
import Dashboard from './Dashboard';
import $ from 'jquery';
import SystemJS from 'SystemJS';

if (!window.PluginsAPI){
  const events = new EventEmitter();
  const factory = new ApiFactory(events);

  SystemJS.config({
    baseURL: '/plugins',
    map: {
      'css': '/static/app/js/vendor/css.js',
      'globals-loader': '/static/app/js/vendor/globals-loader.js'
    },
    meta: {
      '*.css': { loader: 'css' },

      // Globals always available in the window object
      'jQuery': { loader: 'globals-loader', exports: '$' },
      'leaflet': { loader: 'globals-loader', exports: 'L' },
      'ReactDOM': { loader: 'globals-loader', exports: 'ReactDOM' },
      'React': { loader: 'globals-loader', exports: 'React' }
    }
  });

  window.PluginsAPI = {
    Map: factory.create(Map),
    Dashboard: factory.create(Dashboard),

    SystemJS,
    events
  };
var System = require('systemjs');
var assert = require('chai').assert;

System.config({
    baseURL: 'src/js'
});

describe('Parser', function () {

    'use strict';

    var Parser;

    before(function (done) {

        System.import('./parser')
            .then(function (module) {
                Parser = module.default;
                done();
            })
            .catch(function (error) {
                throw error;
            });
    });

    describe('#parse()', function () {

        it('should parse url-encoded strings', function (done) {

            var query = encodeURI('user[name]=alex&user[age]=32&user[address][street]=some street&user[address][number]=1&what[]=first&what[]=last&asc=true');
Exemple #10
0
  let ngPackageNames = [
    'common',
    'compiler',
    'core',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade'
  ]
  // Individual files (~300 requests):
  function packIndex (pkgName) {
    packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' }
  }
  // Bundled (~40 requests):
  function packUmd (pkgName) {
    packages['@angular/' + pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }
  }
  // Most environments should use UMD; some (Karma) need the individual index files
  var setPackageConfig = System.packageWithIndex ? packIndex : packUmd
  // Add package entries for angular packages
  ngPackageNames.forEach(setPackageConfig)
  var config = {
    map: map,
    packages: packages
  }
  System.config(config)
}
var System = require('systemjs');
var path = require('path');

System.config({
  map: { 'rxjs': path.join(__dirname, '..', '..', 'dist', 'package', '/') },
  packages: {
    'rxjs': {main: 'index.js', defaultExtension: 'js' },
    'rxjs/ajax': {main: 'index.js', defaultExtension: 'js' },
    'rxjs/operators': {main: 'index.js', defaultExtension: 'js' },
    'rxjs/testing': {main: 'index.js', defaultExtension: 'js' },
    'rxjs/webSocket': {main: 'index.js', defaultExtension: 'js' }
  }
});

Promise.all([
  System.import('rxjs'),
  System.import('rxjs/ajax'),
  System.import('rxjs/operators'),
  System.import('rxjs/testing'),
  System.import('rxjs/webSocket'),
]).then(
  function () { console.log('Successfully tested all entry-points with SystemJS!'); },
  function (error) {
    console.error('\n\nFailed to load an entry-points via SystemJS: \n\n', error.message);
    process.exit(-1);
  }
);
Exemple #12
0
 .then(function() {
   if (cfg)
     System.config(cfg);
   return System;
 });
Exemple #13
0
 .then(function() {
   System.config(config.loader.getConfig());
   loaderConfigured = true;
 });
Exemple #14
0
const listFPFns = require('../_lib/listFPFns')
const listLocales = require('../_lib/listLocales')
const SystemJS = require('systemjs')
const path = require('path')

const outdatedLocales = require('../../outdatedLocales.json')

const pluginPath = path.join(
  process.cwd(),
  './node_modules/systemjs-plugin-babel'
)

SystemJS.config({
  map: {
    'plugin-babel': path.join(pluginPath, 'plugin-babel.js'),
    'systemjs-babel-build': path.join(pluginPath, 'systemjs-babel-browser.js')
  },
  transpiler: 'plugin-babel'
})

Promise.all(
  importFiles(listFns())
    .concat(importFiles(listFPFns()))
    .concat(importFiles(listLocales().filter(({code}) => !outdatedLocales.includes(code))))
).then(
  () => {
    console.log('SystemJS support is OK')
  },
  err => {
    console.error(err)
    process.exit(1)