Test some module designs.

This commit is contained in:
Lars Jung 2016-06-03 17:38:00 +02:00
parent f7187fb14b
commit 70d6528190
2 changed files with 51 additions and 22 deletions

View file

@ -1,23 +1,51 @@
const {jQuery: jq} = require('./win');
const config = require('./config');
// const {jQuery: jq} = require('./win');
// const config = require('./config');
//
// const name = jq('script[data-module]').data('module');
// const request = {
// action: 'get',
// setup: true,
// options: true,
// types: true
// };
//
// if (name === 'index') {
// request.theme = true;
// request.langs = true;
// } else if (name === 'info') {
// request.refresh = true;
// } else {
// throw new Error(`no-main-module: '${name}'`);
// }
//
// config._update(request).then(() => {
// jq(() => require(`./main/${name}`));
// });
const name = jq('script[data-module]').data('module');
const request = {
action: 'get',
setup: true,
options: true,
types: true
module.exports = (deps = {}) => {
const {
jq = require('./win').jQuery,
config = require('./config')
} = deps;
const name = jq('script[data-module]').data('module');
const request = {
action: 'get',
setup: true,
options: true,
types: true
};
if (name === 'index') {
request.theme = true;
request.langs = true;
} else if (name === 'info') {
request.refresh = true;
} else {
throw new Error(`no-main-module: '${name}'`);
}
config._update(request).then(() => {
jq(() => require(`./main/${name}`));
});
};
if (name === 'index') {
request.theme = true;
request.langs = true;
} else if (name === 'info') {
request.refresh = true;
} else {
throw new Error(`no-main-module: '${name}'`);
}
config._update(request).then(() => {
jq(() => require(`./main/${name}`));
});

View file

@ -1 +1,2 @@
require('./lib/init');
const init = require('./lib/init');
init();