plasticine / inject-loader

💉📦 A Webpack loader for injecting code into modules via their dependencies.
https://www.npmjs.com/package/inject-loader
MIT License
482 stars 47 forks source link

babelrc config not used #50

Open kkroboth opened 6 years ago

kkroboth commented 6 years ago

In version 3.0.1 this PR #38 disabled babelrc file configs which doesn't compile my code correctly.

Aside from the compact option, I also added the filename option to assist in debugging Babel messages like the one I encountered (without the filename, it falls back to "unknown"). Adding filename means we also have to set babelrc: false to prevent it from trying to look up an external config file (which can interfere with inject-loader).

Does this option need to be false or is there another way to include my babel config? Using the env option in babelrc we can set up a different environment for testing that doesn't interfere with "filename".

seanparmelee commented 6 years ago

Sorry @kkroboth, I just happened to notice this issue now, but is this still an issue for you?

After setting the filename to the file that's being injected, babel will try to look up its config starting from that folder and moving up the hierarchy. I was worried that it might cause a babel config to get picked up unexpectedly.

I too now have a use case for wanting inject-loader to use a particular babel config and I'm not sure if there's a better way to specific a config than reverting the babelrc: false. I was thinking about adding options to inject-loader, but I think the only way to pass them in would be to append them to your inject-loader!... requests which is tedious.

Curious to hear your thoughts on this @plasticine