identity-obj-proxy icon indicating copy to clipboard operation
identity-obj-proxy copied to clipboard

Webpack loader

Open lucasconstantino opened this issue 9 years ago • 5 comments

Here goes a simple webpack loader: https://github.com/lucasconstantino/identity-object-proxy-loader

lucasconstantino avatar Oct 28 '16 16:10 lucasconstantino

Hey, thanks for making this! Just curious, what are your use cases for this as a webpack loader?

keyz avatar Oct 30 '16 19:10 keyz

When using Jest, you always have to fix a bunch of stuff Webpack takes care of; aliases, loaders, etc. It's very easy to use identity-obj-proxy directly as a mock for some kind of files such as .css, but you always get stuck with something else Webpack is doing which is hard to replicate on Jest. Therefore, sometimes it's easier to have a specific webpack file just for running tests, something that extends the default webpack configuration for you app. In this case, I'll use this loader to address .css files while testing.

Did it make sense?

lucasconstantino avatar Oct 31 '16 21:10 lucasconstantino

Thanks. We just replaced Jest's scriptPreprocessor config with transform (facebook/jest#1917), which is a mapping from extensions to transformer scripts. There's an example usage at facebook/jest#2035. It might fit your needs better -- let me know what you think!

keyz avatar Nov 01 '16 00:11 keyz

Hey, that's really cool! You guys are improving :) For sure this will fit most of my use cases. Anyway, I think there are still parts of Webpack that simply shouldn't be handled by Jest or any other tool. I mean, I can never really guarantee things will get done the same way by the both of them, Jest and Webpack.

Thanks for all the reply!

lucasconstantino avatar Nov 01 '16 01:11 lucasconstantino

Thanks, let's keep this issue open for visibility.

keyz avatar Nov 01 '16 01:11 keyz