I've got a problem where my add-in is running fine in Outlook Online, but won't run in Outlook desktop. The add-in is successfully activated from the manifest, but fails after load. This is a React + TypeScript project (testing using NodeJS + webpack in Webstorm).
I've narrowed the problem to the usage of ANY require statement for importing a reference. If I eliminate it, it runs fine and shows my test Office UI Fabric CompoundButton component. With the code, it spins and eventually shows a blank page. No script exceptions are thrown, and this is enabled in IE settings.
Why would this fail only on the desktop?
To repro, use three files:
- Start/main page: myapp.tsx
- Which renders TestComponent.tsx
- Which references test.jsx
//myapp.tsx import TestComponent from './components/TestComponent'; import * as $ from 'jquery'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { AppContainer } from 'react-hot-loader'; const render = (Component) => { ReactDOM.render( , document.getElementById('container') ); }; Office.initialize = function () { $(document).ready(function () { console.log('====myapp.tsx.Office.initialize(): entered'); render(TestComponent); }); }; if ((module as any).hot) { console.log('====index.tsx.module() foo'); (module as any).hot.accept('./components/App', () => { const NextApp = require('./components/App').default; render(NextApp); }); } //TestComponent.tsx import * as React from 'react'; import { CompoundButton } from 'office-ui-fabric-react/lib/Button'; //============ // BAD CODE! //import foo = require('../scripts/test.jsx'); //============ export default class TestComponent extends React.Component { render() { console.log('====TestComponent.render()'); //============ // BAD CODE! //foo.testFunction(); //============ return( Create account ); } } //test.jsx export function testFunction(){ console.log("test.jsx: testFunction"); }