[SalesForce] Should we include namespace prefix in code for managed package in SFDX

We're ISV and already built quite a few managed packages. We've been including a namespace prefix everywhere in code (Apex classes, Lightning components etc.) as it's recommended by Salesforce. Now we want to start new projects with Salesforce DX. We know that it's not necessary to add a namespace prefix when you push your code to scratch orgs but should we add namespace when we deploy this code to release org? From my understanding, some code will not be deployed because a namespace prefix is missing, correct?

Thanks in advance!

Best Answer

Normally, you would link a namespace to your DevHub. Once you do this, you can create scratch orgs with the namespace pre-configured in the scratch org definition file. However, generally speaking, you should not include your namespace prefix in your source (I think there's a few exceptions), as the deployment process should automatically do this for you when appropriate.