amis2/examples/loader.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-08-05 11:11:08 +08:00
const __moduleId = (str: string) => '';
const mapping: {
2019-11-07 10:41:14 +08:00
[propName: string]: any;
2019-08-05 11:11:08 +08:00
} = {
2019-12-06 09:58:08 +08:00
'jquery': __moduleId('jquery'),
'react': __moduleId('react'),
2019-11-07 10:41:14 +08:00
'react-dom': __moduleId('react-dom'),
'react-addons-update': __moduleId('react-addons-update'),
'immutability-helper': __moduleId('react-addons-update'),
'react-cropper': __moduleId('react-cropper'),
'react-dropzone': __moduleId('react-dropzone'),
2019-12-06 09:58:08 +08:00
'classnames': __moduleId('classnames'),
'axios': __moduleId('axios'),
'moment': __moduleId('moment'),
'mobx': __moduleId('mobx'),
2019-11-07 10:41:14 +08:00
'mobx-state-tree': __moduleId('mobx-state-tree'),
'react-transition-group': __moduleId('react-transition-group'),
2019-12-06 09:58:08 +08:00
'echarts': __moduleId('echarts'),
'zrender': __moduleId('zrender'),
'sortablejs': __moduleId('sortablejs'),
'amis': __moduleId('../src'),
2019-11-07 10:41:14 +08:00
'amis/embed': __moduleId('./embed.tsx'),
'prop-types': __moduleId('prop-types'),
'async/mapLimit': __moduleId('async/mapLimit'),
2019-12-06 09:58:08 +08:00
'qs': __moduleId('qs')
2019-08-05 11:11:08 +08:00
};
function amisRequire(...args: Array<any>) {
2019-11-07 10:41:14 +08:00
let id = args.shift();
id = Array.isArray(id) ? id.map(id => mapping[id] || id) : mapping[id] || id;
args.unshift(id);
return amis.require.apply(this, args);
2019-11-07 10:41:14 +08:00
}
2019-08-05 11:11:08 +08:00
2019-11-07 10:41:14 +08:00
(window as any).amisRequire = amisRequire;