Search code examples
javascriptecmascript-6uikitbabeljs

ES6: How to Import and Export modules and keep access from console


Usually I can trigger UIkit functions from the console like:

UIkit.alert('.myalert').close();

I have this small example where I use UIkit and a dummy function. When compiling this i no longer have access over the console:

import UIkit from 'uikit';
import Icons from './uikit/uikit-icons';
UIkit.use(Icons);

import Myfunction from './myfunction';

document.addEventListener('DOMContentLoaded', () => {
    Myfunction('something');
})

I added this to export UIkit with no luck:

export default { UIkit };

Solution

  • Add window.UIkit = UIkit after import