You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When I mount an engine in the main app for the purposes of accessing the API, I receive violations from packwerk check
Privacy violation: '::SomeService::Engine' is private to 'modules/some_service' but referenced from '.'.
Is there a public entrypoint in'modules/some_service/public/' that you can use instead?
Am I missing something in terms of how we should be accessing our engines?
So packwerk doesn't know about engines or the preferred way to mounting them out of the box. In this case, packwerk is considering this a privacy violation because modules/some_service/package.yml has set enforce_privacy to true, and ::SomeService::Engine is not in the public folder of modules/some_service.
In this case, it seems reasonable that SomeService::Engineis the public API to using your engine and connecting it to Rails. I'm not sure if there's a Rails limitation here (let me know if there is), but you should be able to move ::SomeService::Engine to live in modules/some_service/public so it is considered public API. Your other options are:
Turn off enforce_privacy
Use the other API to enforce_privacy to specify private constants
Have packwerk ignore config/routes by setting an exclusion in packwerk.yml.
Packwerk should never ask people to move Rails defaults to other places. That is the main reason why enforce_privacy is being removed from Packwerk. Don't move your engine to modules/some_service/public. Packwerk should not be forcing you to do that.
So the other three options Alex listed are your best ones.
We need a better mechanism than folder collocation to define what is public API and what is isn't. Unfortunately the solution is Packwerk isn't good enough and it is going to be removed. Maybe the upcomin privacy plugin will build a different solution.
Description
When I mount an engine in the main app for the purposes of accessing the API, I receive violations from
packwerk check
Am I missing something in terms of how we should be accessing our engines?
To Reproduce
The text was updated successfully, but these errors were encountered: