react-sketchapp icon indicating copy to clipboard operation
react-sketchapp copied to clipboard

renderToJson broken in 3.2.5

Open Esorakouki opened this issue 4 years ago • 4 comments

Expected behavior:

Observed behavior: when I update the version from 3.1.2 to 3.2.5 , report error "undefined is not an object (evaluating 'bridge.createStringMeasurer') "

How to reproduce: image image

Sketch version: 66

But it work when i change the import: image May be related to this pr #517

Esorakouki avatar Jun 07 '20 15:06 Esorakouki

Does render work as normal, but renderToJSON not work? import ... from 'react-sketchapp' should be resolving to react-sketchapp/lib/module/entrypoint.sketch. Have you tried it in a fresh project?

macintoshhelper avatar Jun 07 '20 17:06 macintoshhelper

Are you building with skpm? If so, what's the version? If it's not the latest, try updating. If not, you need to configure webpack to pick .sketch.js before .js

mathieudutour avatar Jun 08 '20 08:06 mathieudutour

I tested in a fresh project with skpm create my-app --template=airbnb/react-sketchapp ([email protected]) and couldn't reproduce this, so seems to be an issue with local setup.

import { render, renderToJSON, Artboard, Text, View } from 'react-sketchapp';

console.log(renderToJSON(<Document colors={colorList} />))

Are you building with Babel before building/rendering with skpm? Might want to mark react-sketchapp as an external dependency during build, or just use skpm build with a custom Babel config.

macintoshhelper avatar Jun 08 '20 13:06 macintoshhelper

@mathieudutour @macintoshhelper My sketch crashed when I run a new project with template or run examples in react-sketchapp, so may be related to my local environment. I will test in other computer and try update skpm in my project later.

And I wonder if there is any doc about skpm entry point configuration? thanks!

Esorakouki avatar Jun 08 '20 16:06 Esorakouki