Unlocked packages behaving like managed packages

This is a known issue and we have an item in our roadmap to fix this so that apex code in namespaced unlocked packages is visible in installed orgs. The side effect of this is that it is difficult to work with debug logs in this scenario.

My suggestion is to explore (until we fix this) no-namespace unlocked packages. In a no-namespace unlocked package, Apex is visible. See this FAQ (https://sfdc-db-gmail.github.io/unlocked-packages/faq-unlocked-pkgs) for more details and if you have any questions, please post them in this Trailblazer group: https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F93A000000Lg5U

Also in the scenario that you are describing, the recommended approach is to deploy the metadata to the packaging org using force:mdapi:deploy instead of installing the unlocked package in the packaging org, if the objective is to make this metadata part of your managed package, you will do force:mdapi:deploy to the packaging org and then issue a force:package1:version:create command to create a package version of the managed package.


In a conversion with the 2GP team, I was told that namespaced unlocked packages will hide their code, just like traditional managed packages. So, I think that's a feature, not a bug/limitation.