Problem with export of nodes inside the remote component

Hi everyone!

Recently I’ve faced with an unpleasing issue related with export.

I have some components (in external library) and their instances (in another project). I have a custom plugin that initially finds all such instances and then does some processing of their main components (using InstanceNode.mainComponent). While processing plugin exports some inner nodes of the components as SVG.

Code snippet:

async function exportToSvg(node: ExportMixin) {
    const settings = { format: 'SVG' } as ExportSettingsSVG;

    return node.exportAsync(settings)
        .then(data => { return String.fromCharCode.apply(null, new Uint16Array(data)); })
        .catch(**reason** => { /* some error handling */ });
}

And the issue is that export fails if node for export is from the subtree of remote component. In case of local component export operation succeeds, in case of instance of the same remote component export succeeds too.

In case of fail reason variable receives very generic error message: “Failed to export node”.

Is this expected behaviour or a bug?

@Gleb, please take a look :wave:

Nodes need to be instantiated on the canvas to be able to export them. Main components of remote instances are permanently hidden and accessible only for reference, so to export them you need to clone them somewhere to the canvas temporarily.

@Gleb, thank for the hint. It would suit as a workaround.

But anyway there is a inconsistance: I can use all the properties and functions of the remote component but the export. Why export is so unique?

If there is some techincal limitation under the hood maybe workaround with temporary instances can be implemented on the Figma API level to mitigate such problem on the side of plugin developers? What do you think?