Fix render tool on Windows: add .js extension to dynamic imports

ESM dynamic imports require explicit file extensions for resolution on
Windows + Bun. The extensionless '../render/render-jsx' path worked on
macOS/Linux but failed on Windows with 'Cannot find module' error.

Fixes #43
This commit is contained in:
Danila Poyarkov 2026-03-05 09:19:15 +03:00
parent d6922caf00
commit 3199abb4e6

View file

@ -193,7 +193,7 @@ export const render = defineTool({
parent_id: { type: 'string', description: 'Parent node ID to render into' }
},
execute: async (figma, args) => {
const { renderJsx } = await import('../render/render-jsx')
const { renderJsx } = await import('../render/render-jsx.js')
const result = await renderJsx(figma.graph, args.jsx, {
parentId: args.parent_id ?? figma.currentPageId,
x: args.x,
@ -1046,7 +1046,7 @@ export const nodeReplaceWith = defineTool({
const x = node.x
const y = node.y
node.remove()
const { renderJsx } = await import('../render/render-jsx')
const { renderJsx } = await import('../render/render-jsx.js')
const result = await renderJsx(figma.graph, args.jsx, { parentId, x, y })
return { id: result.id, name: result.name, type: result.type }
}