Not sure if it’s a bug or a “feature” (jokes apart, I mean if it’s an expected behaviour). Let’s imagine that I have an element that is using a certain component from a library (as an instance), and in my plugin I want to swap that component with another one (“ new ”, of which I have an ID). Usually I would do:
const newMainComponentObject = await figma.importComponentByKeyAsync(newMainComponentKey);
oldComponentInstanceNode.swapComponent(newMainComponentObject);
and this works perfectly fine. Now, what happens is that if the “new” component is a “local” component, it doesn’t work, for the simple reason that calling:
figma.importComponentByKeyAsync(localMainComponentKey);
triggers an error. Now, the question is: why the method importComponentByKeyAsync
should not work, even if the component is “local”? (and yes, the local component is published as library).
This is the error I see if I try to import the component in the file where the component is defined:
This is the same command run in another file:
What do you think folks? Bug or expected behaviour?