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