Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import klaw from 'klaw';
import path from 'path';
import chalk from 'chalk';
import rfse from 'fs-extra';
import winston from 'winston';
import Promise from 'bluebird';
import Mustache from 'mustache';
import inquirer from 'inquirer';
import SystemJS from 'systemjs';
import utils from '../utils/utils';
const fse = Promise.promisifyAll(rfse);
SystemJS.config({
transpiler: 'plugin-babel',
map: {
'plugin-babel': path.resolve(__dirname, '../../node_modules/systemjs-plugin-babel/plugin-babel.js'),
'systemjs-babel-build': path.resolve(__dirname, '../../node_modules/systemjs-plugin-babel/systemjs-babel-browser.js'),
},
});
/**
* This class represents a template, which will be able to render to some output location.
* All the data and render processes are stored in this instance.
*/
class Template {
filters: Map boolean>;
source: string;
start: string;
constructor(option: IInitOption) {
// 注εζζη Vendors
if (option.vendors) {
option.vendors.forEach(vendor => {
this.registerSystemMap(vendor);
});
}
// 注εζζηεΊη¨
option.apps.forEach(app => {
this.registerSystemMap(app);
});
// Init systemJS
SystemJS.config(this.systemConfig);
// Mount CSS
this.css.forEach(cssHref => {
loadCSS(cssHref);
});
this.apps = option.apps;
this.isRegistered = true;
return this;
}
constructor(option: IInitOption) {
// 注εζζη Vendors
if (option.vendors) {
option.vendors.forEach(vendor => {
this.registerSystemMap(vendor);
});
}
// 注εζζηεΊη¨
option.apps.forEach(app => {
this.registerSystemMap(app);
});
// Init systemJS
SystemJS.config(this.systemConfig);
// Mount CSS
this.css.forEach(cssHref => {
loadCSS(cssHref);
});
this.apps = option.apps;
this.isRegistered = true;
return this;
}
.then(function() {
System.config(config.getLoaderConfig());
if (production || process.env.NODE_ENV === 'production')
System.config({ production: true });
return System.import(moduleName)
.then(function(m) {
if (view)
console.log(m);
});
})
.catch(function(e) {
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