cujojs / wire

A light, fast, flexible Javascript IOC container
Other
861 stars 68 forks source link

Bundling with Webpack doesn't work well #178

Closed designeng closed 8 years ago

designeng commented 8 years ago

When I try to build with Webpack I have a lot of warnings and errors, the first message

WARNING in ./node_modules/wire/wire.js
Critical dependencies:
29:27-34 require function is used in a way in which dependencies cannot be statically extracted
 @ ./node_modules/wire/wire.js 29:27-34
designeng commented 8 years ago

There is the problem with webpack relationship with require function. Webpack tries to evaluate the request expression in the line https://github.com/cujojs/wire/blob/master/wire.js#L25. Request function does not work here in the usual way - it's rewritten with inner webpack 'webpack_require' function with request to context module. As the result of recording phase the context module created by webpack has all inner files mapped. It should be worked around with ContextReplacementPlugin.

briancavalier commented 8 years ago

Hey @designeng, thanks for investigating this and posting a followup. It'll be helpful for others who may run into the same warning.

saunders99999 commented 8 years ago

Hi @designeng / @briancavalier,

Are there any usage samples of wire and webpack? I'm not sure how to have webpack bundle/load the wire library and then read wire specs. I appreciate the post and see deisgneng is working on a webpack loader for wire, but I can't tell how mature that effort is.

Thanks...