diff --git a/src/__mocks__/init.js b/src/__mocks__/init.js new file mode 100644 index 000000000..9c5f81382 --- /dev/null +++ b/src/__mocks__/init.js @@ -0,0 +1,10 @@ +/** + * Copyright 2018-present Facebook. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * @format + */ + +export default function init() { + // no-op +} diff --git a/src/index.js b/src/index.js index a96b95e75..d2c337503 100644 --- a/src/index.js +++ b/src/index.js @@ -14,9 +14,8 @@ export {SonarBasePlugin, SonarPlugin, SonarDevicePlugin} from './plugin.js'; export {createTablePlugin} from './createTablePlugin.js'; export {default as SonarSidebar} from './chrome/SonarSidebar.js'; -export * from './init.js'; -export {default} from './init.js'; - export {default as AndroidDevice} from './devices/AndroidDevice.js'; export {default as Device} from './devices/BaseDevice.js'; export {default as IOSDevice} from './devices/IOSDevice.js'; + +export {default as init} from './init.js'; diff --git a/src/init.js b/src/init.js index 96a47ff8c..657489b21 100644 --- a/src/init.js +++ b/src/init.js @@ -62,16 +62,18 @@ const AppFrame = () => ( ); -// $FlowFixMe: this element exists! -ReactDOM.render(, document.getElementById('root')); -// $FlowFixMe: service workers exist! -navigator.serviceWorker - .register( - process.env.NODE_ENV === 'production' - ? path.join(__dirname, 'serviceWorker.js') - : './serviceWorker.js', - ) - .then(r => { - (r.installing || r.active).postMessage({precachedIcons}); - }) - .catch(console.error); +export default function init() { + // $FlowFixMe: this element exists! + ReactDOM.render(, document.getElementById('root')); + // $FlowFixMe: service workers exist! + navigator.serviceWorker + .register( + process.env.NODE_ENV === 'production' + ? path.join(__dirname, 'serviceWorker.js') + : './serviceWorker.js', + ) + .then(r => { + (r.installing || r.active).postMessage({precachedIcons}); + }) + .catch(console.error); +} diff --git a/static/index.dev.html b/static/index.dev.html index c50347685..fecdbcfc4 100644 --- a/static/index.dev.html +++ b/static/index.dev.html @@ -85,6 +85,10 @@ openError('Script failure. Check Chrome console for more info.'); }; + script.onload = () => { + global.Sonar.init(); + }; + document.body.appendChild(script); } diff --git a/static/index.html b/static/index.html index a2e80969a..499dfa068 100644 --- a/static/index.html +++ b/static/index.html @@ -14,5 +14,8 @@ global.electronRequire = window.require; +