Skip to content

Commit

Permalink
feat: 🎸 updated devtools manager code to ima17
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimck committed Dec 6, 2019
1 parent d546293 commit 44355ba
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions packages/devtools-scripts/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { aop, createHook, hookName, createCallTrap } from 'to-aop';
import uid from 'easy-uid';
import DevToolManager from './DevToolManager';

const ImaMainModules = [
'onLoad',
'getInitialImaConfigFunctions',
'getNamespace',
'getInitialPluginConfig',
'createImaApp',
'getClientBootConfig',
'bootClientApp',
'routeClientApp',
'hotReloadClientApp',
'reviveClientApp'
];

// eslint-disable-next-line no-unused-vars
function createDevtool(registerHook) {
$IMA.devtool = $IMA.devtool || {};
Expand Down Expand Up @@ -182,21 +195,21 @@ function createDevtool(registerHook) {
}
);

// TODO CHANGE FOR IMA@17
let imaMain = importIMAClass('ima/main');
let imaCore = importIMAClass('@ima/core');
ImaMainModules.forEach(moduleName => {
const key = `__${moduleName}__`;

Object.keys(imaMain).forEach(property => {
const key = `__${property}__`;
Object.defineProperty(imaMain, key, {
value: imaMain[property],
Object.defineProperty(imaCore, key, {
value: imaCore[moduleName],
enumerable: false,
configurable: false,
writable: false
});
imaMain[key] = imaMain[property];
imaMain[property] = createCallTrap({
target: imaMain,
object: imaMain,

imaCore[key] = imaCore[moduleName];
imaCore[moduleName] = createCallTrap({
target: imaCore,
object: imaCore,
property: key,
pattern: revivePattern
});
Expand Down

0 comments on commit 44355ba

Please sign in to comment.