0

I need to export two functions in the global scope, for example, I have these two functions:

function Suite() {//...} 

function Test() {//...} 

I want to be able to export them to the global scope using the Webpack, so I can use them like this:

Suite();
Test();

instead of how I am now:

myLib.Suite();
myLib.Test();

I know I can export a function to the global scope like this:

module.exports = Suite;

But I do not know how it would do to export two or more functions to the global scope. For it to work on both nodejs and client.

PerduGames
  • 1,108
  • 8
  • 19

1 Answers1

1

Inside your module you can use global as follows

function Suite() {//...} 
function Test() {//...} 

global.Suite = Suite;
global.Test = Test;

global is window in the browser, and global in node when using webpack.

rich
  • 91
  • 2