-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathentry.js
More file actions
45 lines (35 loc) · 1.26 KB
/
entry.js
File metadata and controls
45 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/** This is the real webpack entry file. It manages setting up the zimlet and HMR.
* The user-defined entry file (index.js) is imported here via a `zimlet-cli-entrypoint` alias.
*/
(() =>
getZimlet({
code: (() => {
function init() {
return (context) => {
let { zimbra, config, plugins, shims, components, store, meta } =
context;
// Add shims to the global scope to expose dependencies to Zimlets
// Shimmed dependencies include preact, preact-router, react-apollo
global.shims = shims;
global.zimbra = zimbra;
global.config = config;
global.plugins = plugins;
global.components = components;
global.store = store;
global.ZIMLET_STYLES = [];
global.meta = meta;
let entry = require('zimlet-cli-entrypoint');
let r = (entry && entry.default) || entry;
// If export is a factory, pass it context. Otherwise it's a singleton.
let instance = typeof r === 'function' ? r(context) : r;
context.styles.set(global.ZIMLET_STYLES.join('\n'));
return instance;
};
}
if (process.env.NODE_ENV === 'development' && module.hot) {
module.hot.accept('zimlet-cli-entrypoint', init);
}
return init();
})(),
name: () => require('zimlet-cli-entrypoint-package').name
}))();