webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

feat: allow the IIFE to be customized via rules #57

Closed julianxhokaxhiu closed 4 years ago

julianxhokaxhiu commented 7 years ago

Example of usage:

require("imports-loader?this=>window%2Cdocument|window%2Cdocument!path/to/library") // (function(window,document){ ...content of library... })(window,document)

Fixes https://github.com/webpack-contrib/imports-loader/issues/56

jsf-clabot commented 7 years ago

CLA assistant check
All committers have signed the CLA.

julianxhokaxhiu commented 6 years ago

Any update on this?

michael-ciniawsky commented 6 years ago

@julianxhokaxhiu I don't get this example

require("imports-loader?this=> window%2Cdocument|window%2Cdocument  !path/to/library")

it's using the same exact same value twice ? Could you provide another example please :)

julianxhokaxhiu commented 6 years ago

Actually the full example is living on my first comment. As you can see the issue ( https://github.com/webpack-contrib/imports-loader/issues/56 ) I'm providing a way to fill custom arguments inside the IIFE.

In this case, I'm using it to wrap angular libraries that still need the real document and window, but sometimes you can override them by providing a $window,$document if needed.

The example is just a pure example, but you can use it the way you prefer. I truly think that this PR has some real value as I used it already with this patch on top. Would be nice if this goes upstream :)

julianxhokaxhiu commented 6 years ago

Any update on this?

julianxhokaxhiu commented 6 years ago

This project looks like dead to me. Are you still interested on this PR?