I found an interesting problem when run Export-PnPListToSiteTemplate command.
My Scenario
Let me describe my scenario first.
I have one list which enabled content type management, because I have two content types under this list
Some of the list fields are site column
And these two site columns are set as hidden in my list content type
Missing site column field ref in the exported template
Then it (those two site column field ref) won't get exported when I run Export-PnPListToSiteTemplate or other export template command.
In this case it only exported "Title" since "Tifle" field is visible in list content type

However if I disable the content type management on the list, then I can get all site columns used in this list.
In the source code https://github.com/pnp/pnpframework/blob/dev/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs#L2776, it will not add hidden site column as field ref if the list enabled content type
if (siteList.ContentTypesEnabled && contentTypeFields.FirstOrDefault(c => c.Id == field.Id) == null)
{
if (contentTypeFields.FirstOrDefault(c => c.Id == field.Id) == null)
{
addField = false;
}
}
I found an interesting problem when run
Export-PnPListToSiteTemplatecommand.My Scenario
Let me describe my scenario first.
I have one list which enabled content type management, because I have two content types under this list
Some of the list fields are site column
And these two site columns are set as hidden in my list content type
Missing site column field ref in the exported template
Then it (those two site column field ref) won't get exported when I run

Export-PnPListToSiteTemplateor other export template command.In this case it only exported "Title" since "Tifle" field is visible in list content type
However if I disable the content type management on the list, then I can get all site columns used in this list.
In the source code https://github.com/pnp/pnpframework/blob/dev/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs#L2776, it will not add hidden site column as field ref if the list enabled content type