{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/161","repository_url":"https://api.github.com/repos/webpack/webpack","labels_url":"https://api.github.com/repos/webpack/webpack/issues/161/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/161/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/161/events","html_url":"https://github.com/webpack/webpack/issues/161","id":26870890,"number":161,"title":"How to initialize third-party modules","user":{"login":"jhnns","id":781746,"avatar_url":"https://avatars.githubusercontent.com/u/781746?v=3","gravatar_id":"","url":"https://api.github.com/users/jhnns","html_url":"https://github.com/jhnns","followers_url":"https://api.github.com/users/jhnns/followers","following_url":"https://api.github.com/users/jhnns/following{/other_user}","gists_url":"https://api.github.com/users/jhnns/gists{/gist_id}","starred_url":"https://api.github.com/users/jhnns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhnns/subscriptions","organizations_url":"https://api.github.com/users/jhnns/orgs","repos_url":"https://api.github.com/users/jhnns/repos","events_url":"https://api.github.com/users/jhnns/events{/privacy}","received_events_url":"https://api.github.com/users/jhnns/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/webpack/webpack/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2014-02-04T10:09:00Z","updated_at":"2016-02-14T22:53:22Z","closed_at":"2016-02-14T22:53:22Z","body":"This is rather a question than an issue. This is my scenario:\r\n\r\nIf a given `moduleA` requires some configuration (like `moduleA.use(myPlugin)`), where should I put this configuration code?\r\n\r\nSolution 1: Put it in the entry bundle. But this would force `moduleA` to be in the entry bundle although it could be lazy-loaded. This would be the node.js-style I guess.\r\n\r\nSolution 2: Provide a substitute. In this case I would create `myModuleA` and export the original `moduleA` while configuring it. But in this case I can't take advantage from nice `require()`-paths. Now every `require()` needs to be relative which isn't nice either. Additionally all modules need to know about my substitute.\r\n\r\nSolution 3: Tell webpack, to run a function when a specific module is executed the first time:\r\n\r\n```javascript\r\n// proposal\r\nrequire.when(\"moduleA\", function (moduleA) {\r\n    // gets executed immediately after moduleA has been initialized\r\n    moduleA.use(myPlugin);\r\n});\r\n```\r\n\r\nIs there a CommonJS-way to do this? I guess this is only a problem in async environments."},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/183997517","html_url":"https://github.com/webpack/webpack/issues/161#issuecomment-183997517","issue_url":"https://api.github.com/repos/webpack/webpack/issues/161","id":183997517,"user":{"login":"jhnns","id":781746,"avatar_url":"https://avatars.githubusercontent.com/u/781746?v=3","gravatar_id":"","url":"https://api.github.com/users/jhnns","html_url":"https://github.com/jhnns","followers_url":"https://api.github.com/users/jhnns/followers","following_url":"https://api.github.com/users/jhnns/following{/other_user}","gists_url":"https://api.github.com/users/jhnns/gists{/gist_id}","starred_url":"https://api.github.com/users/jhnns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhnns/subscriptions","organizations_url":"https://api.github.com/users/jhnns/orgs","repos_url":"https://api.github.com/users/jhnns/repos","events_url":"https://api.github.com/users/jhnns/events{/privacy}","received_events_url":"https://api.github.com/users/jhnns/received_events","type":"User","site_admin":false},"created_at":"2016-02-14T22:53:22Z","updated_at":"2016-02-14T22:53:22Z","body":"I think this is a rather specific problem and can already be addressed by some configuration."}}