Falcon
Falcon

Reputation: 1367

How to expose the variables in an entry module as global variables with webpack?

i am hoping for some webpack option (or loader) like bare in coffee which removes the top-level function wrapper and expose the variables for convenience in debugging.

Upvotes: 1

Views: 1994

Answers (1)

Falcon
Falcon

Reputation: 1367

script-loader evaluates the required module in the global context. Essentially it generates eval(source) in the global context in the output bundled javascript file. Beware to avoid setting use strict otherwise the eval would create its own scope (instead of using the global context).

Upvotes: 1

Related Questions