amis/examples/loader.ts

40 lines
1.3 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'),
'immutability-helper': __moduleId('immutability-helper'),
2019-11-07 10:41:14 +08:00
'react-cropper': __moduleId('react-cropper'),
'react-dropzone': __moduleId('react-dropzone'),
2019-12-06 09:58:08 +08:00
'classnames': __moduleId('classnames'),
'axios': __moduleId('axios'),
2020-11-25 12:29:00 +08:00
'exceljs': __moduleId('exceljs'),
2019-12-06 09:58:08 +08:00
'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'),
2020-09-25 18:06:14 +08:00
'papaparse': __moduleId('papaparse'),
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'),
'qs': __moduleId('qs'),
2021-06-17 16:33:33 +08:00
'path-to-regexp': __moduleId('path-to-regexp'),
'history': __moduleId('history')
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;