airbnb / react-sketchapp

render React components to Sketch ⚛️💎
http://airbnb.io/react-sketchapp/
MIT License
14.95k stars 824 forks source link

renderToJson broken in 3.2.5 #519

Open Esorakouki opened 4 years ago

Esorakouki commented 4 years ago

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

macintoshhelper commented 4 years ago

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?

mathieudutour commented 4 years ago

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

macintoshhelper commented 4 years ago

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.

Esorakouki commented 4 years ago

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