Galooshi / import-js

A tool to simplify importing JS modules
MIT License
525 stars 55 forks source link

Provide the option to override parser plugins in configuration #611

Closed mikabytes closed 10 months ago

mikabytes commented 10 months ago

Related to #571

This PR provides a new configuration key parserPlugins that allows the end-user to override or extend what babel parser plugins to use. See README for example use.

This implementation uses a (nasty) singleton in parse.js to achieve the goal. While I'm not too happy about that, I have reasons;

I spent a long time trying to implement this by passing the values around from Configuration.js to its endpoint, parse.js. However, I ran into trouble doing so. As it turns out a lot of code is calling parse.js indirectly, such as findExports and even meteorEnvironment and Configuration itself. I tried to find all the cases but in the end I had hundreds of lines of code changed and 96 failed tests. Weird circular dependencies started showing up as well. In the end, I gave up on that strategy.