Mike
Mike

Reputation: 5816

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 };

Upvotes: 0

Views: 155

Answers (2)

Vyacheslav Palamar
Vyacheslav Palamar

Reputation: 507

I believe it has to be export default UIkit; Because now you export an object with UIkit being it's key. But you also need to import UIkit to myfunction as well.

Upvotes: 0

Anurag Srivastava
Anurag Srivastava

Reputation: 14433

Add window.UIkit = UIkit after import

Upvotes: 1

Related Questions