airbnb/react-sketchapp

renderToJson broken in 3.2.5

Esorakouki opened this issue · 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

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?

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

I tested in a fresh project with skpm create my-app --template=airbnb/react-sketchapp (react-sketchapp@3.2.6) 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.

@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!