How do I fail a build from a resolver plugin? #4992
-
Hello! I'm creating a resolver plugin. When a certain file is required, I would like my plugin to be able to fail the build rather than allow the asset to continue to the next resolver. How would I do this? I can throw a |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Currently that's impossible as the way it works is that a thrown error will result in the next resolver getting a chance to resolve the asset as an error usually means that it can't resolve it. We might add a flag or something similar to it that we can use like the MODULE_NOT_FOUND in the standard node resolver, so we know what kind of error occurred although not entirely sure what the best approach for this is. |
Beta Was this translation helpful? Give feedback.
-
Making the return type |
Beta Was this translation helpful? Give feedback.
-
Thanks. Even though it's not the answer I was hoping for, it's definitely helpful. In case it helps to hear our use case, we are creating bundles of untrusted, third-party code (which we call extensions). We want to allow the third-party code to import/require other files that the third-party provided but not any arbitrary file on the server. We also want the third-party code to be able to import/require certain npm packages, but not others. I was hoping to set up my resolvers in my I'll probably either try to call |
Beta Was this translation helpful? Give feedback.
-
@DeMoorJasper @mischnic Is this being tracked somewhere already or should I create an issue for it? |
Beta Was this translation helpful? Give feedback.
Currently that's impossible as the way it works is that a thrown error will result in the next resolver getting a chance to resolve the asset as an error usually means that it can't resolve it.
We might add a flag or something similar to it that we can use like the MODULE_NOT_FOUND in the standard node resolver, so we know what kind of error occurred although not entirely sure what the best approach for this is.