webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

injecting variable of submodule #32

Closed baywet closed 7 years ago

baywet commented 7 years ago

Hi, I've been stuck over the last few days on injecting jsrsasign into oauth-ng. Latest test is require('jsrsasign'); require('imports?KJUR=jsrsasign,KEYUTIL=jsrsasign!oauth-ng');

that gives me the following result at the beginning of oauth-ng in the bundle var KJUR = __webpack_require__(462); var KEYUTIL = __webpack_require__(462);

But what I actually would like to have is something equivalent to var KJUR = __webpack_require__(462).KJUR; var KEYUTIL = __webpack_require__(462).KEYUTIL;

Is there anyway to do that? (jsrsasign defines mutiples modules using the exports syntax, and those are the modules I want to inject, not the "container") Thank you for your help, pulling my haire on this one

SpaceK33z commented 7 years ago

Would #30 fix your issue?

baywet commented 7 years ago

If I understood properly what it does, yes probably. I'd have to do something like: require('imports?KJUR=jsrsasign.KJUR,KEYUTIL=jsrsasign.KEYUTIL!oauth-ng');

SpaceK33z commented 7 years ago

I've released imports-loader@0.7.0 with that fix, let me know if you still have issues.