webpack's documentation lists an interesting pattern for shimming a module that sets properties on window
, like window.XModule = {...}
.
require('imports?window=>{}!exports?window.XModule!./file.js')
Applying the pattern to ES6, I ended up with this:
import XMODULE from 'imports?window=>{}!exports?window.XModule!./file.js'
I'm trying to understand how Webpack processes this statement, specifically, what role the imports-loader
part plays, imports?window=>{}
. I understand that the exports-loader
basically sets XMODULE
to be window.XModule
from the dependency. As for the imports-loader
, it seems like all it does is not allow the window
object to get polluted by the dependency... but how?
How does imports?window=>{}
work in conjuction with exports?window.XModule
?