Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice needed for a plugin I am developing #14

Open
Francesco-Lanciana opened this issue Mar 18, 2018 · 0 comments
Open

Advice needed for a plugin I am developing #14

Francesco-Lanciana opened this issue Mar 18, 2018 · 0 comments

Comments

@Francesco-Lanciana
Copy link

Hey Sean,

I watched your talk "Everything is a plugin!" and really enjoyed it; it helped to demistify the plugin ecosystem a fair bit. Recently I've been trying to develop my own plugin that would help manage a large project made up of many micro frontends, but I could really use your advice on what I can do better if you have the time.

Bit of context about the plugin first might help. The plugin focuses purely on allowing users to enforce rules as to whether a given apps modules are allowed to import modules from a seperate app.

The use case is quite a niche one because it really only makes sense when you are generating multiple bundles and you want them to be able to interact in certain ways. It also requires that webpacks library option is set (so each bundle is assigned to a variable).

I've made a repo on github with a minimal example showcasing it's functionality, which also has more of an explanation as to why you might need it. Here's the link:

https://github.com/Francesco-Lanciana/prevent-cross-project-imports-webpack-plugin#

Some of the things I could really use your advice on are:

  1. Am I tapping into an event too late in the lifecycle? My first attempt (which can be found in old.js) was to try tap into the resolvers lifecycle but I was having trouble finding a place where I had both the modules full path and its dependencies full path.

  2. How do you go about throwing an error properly, especially one that actually stops the bundle from still compiling? Because this plugin is just enforcing more rules on imports, you can still have a perfectly valid project even if it finds a violation. Therefore it still compiles but just shows my error message below that. Currently I'm using the FriendlyErrorsWebpackPlugin to hide the compilation details but this approach is pretty sucky (needs more than just my plugin and it doesn't actually prevent compilation).

  3. This relates to Question 1 but I would also really like it if I could reliably show the line that the improper import was happening on. I attempted it with my plugin, however I only had access to the transpiled code so mapping it back to the original file was hacky to say the least (find the line that contained the import substring and counting the requires before it). If you knew a way to do this that would be awesome.

  4. Have you ever seen any other use case for something like this (or even a plugin that does the same thing)? Maybe what I'm trying to do makes no sense but I'm in too deep at the moment haha.

Thanks a ton for your time, I'm really keen to get your feedback. Let me know if you have any questions or if something I said made no sense, I'll answer as quickly as I can :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant