Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol support #53

Merged
merged 31 commits into from
Jun 5, 2017
Merged

Symbol support #53

merged 31 commits into from
Jun 5, 2017

Conversation

lukewestby
Copy link
Collaborator

@lukewestby lukewestby commented Apr 28, 2017

For issue #28

Heya!

There are a few things still missing here but I wanted to get this in front of y'all before going down any paths you wouldn't want. I'll outline some things that are missing or weird still but the gist of the API so far can be explained by this example:

import { Widget } from 'my-lib';
import { makeSymbol, injectSymbols, Artboard, render } from 'react-sketchapp';

// Assume that there is a text string with content "Name" and an <Image> with name prop
// "someImage" within Widget
const WidgetSymbol = makeSymbol(Widget);

const Document = () =>
  <Artboard>
    <WidgetSymbol
      style={{width: 100, height: 100 }}
      overrides={{ 'Name': 'Hi', 'someImage': 'https://whatever.example/image.jpg' }}
    />
  </Artboard>;

export default (context) => {
  injectSymbols(context);
  render(<Document />, context.document.currentPage());
};

What will happen is a new page called "Symbols" will be created if it doesn't already exists and the symbol master generated by the call to makeSymbol will be dumped there. Then, each rendered WidgetSymbol will be a symbol instance pointing to the related master. Names of things are best guess based on the name of the class, and names are currently shared and global, so if you have two things called Widget one will be overwritten.

See also the example in /examples/symbols

How overrides work

I tried to keep the overrides API as similar to the actual experience in Sketch as possible. There are three overridable elements within a symbol: text, images, and other symbols.

Text

Text overrides currently work by mapping either the name from a <Text /> element or the actual text content onto the key in the overrides object. So, if a symbol master looks like:

...
<Text name="my_text">hello</Text>
...

Then the override is going to look like

<Instance overrides={{ my_text: 'whatever you want here' }} />

But, if you just use a string in your master like

...
Hello World
...

Then the override will look like

<Instance overrides={{ 'Hello World': 'Something else' }} />

Images

Image overrides work by mapping the name assigned to the image element onto another image url string. In the master:

... 
<Image name="my_image" source="https://hello.world/image.jpg" />
...

And to override:

<Instance overrides={{ my_image: 'https://hello.world/different.jpg' }} />

Nested Symbols

Nested symbols are overrided by mapping the name given to the symbol instance nested within the master onto the constructor for a different symbol instance. The constructor must ultimately point to a master with the exact same width and height as the original. For a master that contains:

...
<NestedSymbolA name="nested_symbol" />
...

The override is:

<Instance overrides={{ nested_symbol: NestedSymbolB, /* any other overrides in Instance _or_ NestedSymbolB */ }} />

You'll notice here we can provide overrides at the top level that apply to nested symbols within a master. This applies whether the nested symbol instance has been overrided or not. So if we didn't override NestedSymbolA with NestedSymbolB, we could include overrides for the contents of NestedSymbolA. This is how Sketch presents overrides for nested symbols in its UI, and internally we need to collect all overrides into one object as well so I chose to represent it as a flattened application in the API as well.

Things that are weird

  • css-layout wants to see some dimensions on the children of a flex container, so if you just render a symbol like <MyInstance /> you're going to end up with no width and no height. This is
    counterintuitive -- Sketch seems to clone the layout of the master to each instance when you first create it.

Things to do

  • Automatic symbol master injection
  • Automatic symbol instance generation
  • Text overrides
  • Image overrides
  • Symbol instance overrides
  • Use real sketchapp-json-flow-types package again once this PR is merged and published.

ljharb
ljharb previously requested changes Apr 28, 2017
src/index.js Outdated
@@ -8,6 +8,7 @@ import RedBox from './components/RedBox';
import View from './components/View';
import Text from './components/Text';
import TextStyles from './sharedStyles/TextStyles';
import Symbol from './symbol';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol isn't a great name because it shadows the JS primitive. Could we choose something else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh shoot, yes. this was a silly thing to do. how about Symbols?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's fine :-) it can conceptually overlap, as long as it doesn't literally overlap.

However, I'd also say that this doesn't tell me what a "symbol" is in this context, and it's not super clear to me from the OP either :-/

Copy link
Collaborator Author

@lukewestby lukewestby Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shoot! i forgot to reference the original issue that this proposes to resolve! it's for #28, adding automatic sketch symbol generation and references. 0 for 2 on clarity so far 😆 anyway i'll change it to Symbols. thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, so based on the original issue i'd call it a "SketchSymbol", but any name other than "Symbol" is acceptable :-)

Copy link
Contributor

@jemgold jemgold Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'd love it if we could get away with not using SketchX as a prefix.

The exported API can be split into "things that fit into react-primitives" (View, Text, Image etc) and "Sketch-specific concepts" — TextStyles, Artboard etc.

I agree that Symbol is not the right name for it because of clashes, but what if we just exported the symbolize or makeSymbol or whatever HOC rather than Symbol.symbolize? I guess we also need Symbol.inject but there's probably a smart way around that 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed to makeSymbol and injectSymbols, both imported from the top namespace. The example in the PR description is updated to demonstrate. Happy to change these as many times as needed until it feels right.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jongold fwiw, i think the difference here is that "Artboard" isn't a JavaScript-specific concept, but "Symbol" is - and I think that language-specific construct names are always automatically off limits. You shouldn't have a "Map" either - a "GoogleMap" or a "StreetMap" or something, but not a "Map" - that's taken by the language.

@ljharb ljharb dismissed their stale review April 28, 2017 20:26

Concerns addressed.

@lukewestby
Copy link
Collaborator Author

@jongold ready for your review! you can find example usage in examples/symbols

@jemgold
Copy link
Contributor

jemgold commented May 15, 2017

@lukewestby !!!!!!!!!!!! woo, I'll take a look :)

@michaelcarter-wf
Copy link

michaelcarter-wf commented May 18, 2017

@lukewestby awesome work!

I'm hitting an error when try to run the symbol example:

Module not found: Error: Can't resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types'
resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types'

Env:
node 6.x latest

Steps to reproduce:

  1. Check out this branch.
  2. git clean -xdf
  3. npm install
  4. npm run build
  5. cd examples/symbol
  6. npm install
  7. npm run build
  8. produces error + trace below:
Stack Trace, Click to Expand ➜ symbols git:(symbol_support) ✗ npm run build

symbols@1.0.0 build /Users/michaelcarter/git/react-sketchapp/examples/symbols
skpm build

[1/2] 🖨 Copied src/manifest.json in 7ms
error Error while building ./my-command.js
/Users/michaelcarter/git/react-sketchapp//prop-types/factoryWithTypeCheckers.js
Module not found: Error: Can't resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types'
resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types'
Parsed request is a module
using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/prop-types/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/prop-types/package.json (relative path: .)
resolve as module
/Users/michaelcarter/git/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/git/react-sketchapp/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/node_modules
No description file found
Field 'browser' doesn't contain a valid alias configuration
No description file found
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules doesn't exist or is not a directory
[/Users/michaelcarter/git/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/michaelcarter/node_modules/package.json]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill/package.json]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/prop-types/node_modules]
[/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules]
@ /Users/michaelcarter/git/react-sketchapp/
/prop-types/factoryWithTypeCheckers.js 1:0-41
@ /Users/michaelcarter/git/react-sketchapp//prop-types/index.js
@ /Users/michaelcarter/git/react-sketchapp/lib/symbol.js
@ /Users/michaelcarter/git/react-sketchapp/lib/index.js
@ ./src/my-command.js
/Users/michaelcarter/git/react-sketchapp/
/fbjs/lib/warning.js
Module not found: Error: Can't resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/lib'
resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/lib'
Parsed request is a module
using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/package.json (relative path: ./lib)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/package.json (relative path: ./lib)
resolve as module
/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/git/react-sketchapp/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/node_modules
No description file found
Field 'browser' doesn't contain a valid alias configuration
No description file found
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/lib/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/node_modules doesn't exist or is not a directory
[/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules]
[/Users/michaelcarter/git/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/michaelcarter/node_modules/package.json]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill/package.json]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/lib/node_modules]
[/Users/michaelcarter/git/react-sketchapp/node_modules/fbjs/node_modules]
@ /Users/michaelcarter/git/react-sketchapp//fbjs/lib/warning.js 1:0-41
@ /Users/michaelcarter/git/react-sketchapp/
/prop-types/factoryWithTypeCheckers.js
@ /Users/michaelcarter/git/react-sketchapp//prop-types/index.js
@ /Users/michaelcarter/git/react-sketchapp/lib/symbol.js
@ /Users/michaelcarter/git/react-sketchapp/lib/index.js
@ ./src/my-command.js
/Users/michaelcarter/git/react-sketchapp/
/react-test-renderer/lib/ReactUpdates.js
Module not found: Error: Can't resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/lib'
resolve 'sketch-module-console-polyfill' in '/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/lib'
Parsed request is a module
using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/package.json (relative path: ./lib)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/package.json (relative path: ./lib)
resolve as module
/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/lib/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules doesn't exist or is not a directory
/Users/michaelcarter/git/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/git/react-sketchapp/node_modules
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules)
using description file: /Users/michaelcarter/git/react-sketchapp/package.json (relative path: ./node_modules/sketch-module-console-polyfill)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill doesn't exist
looking for modules in /Users/michaelcarter/node_modules
No description file found
Field 'browser' doesn't contain a valid alias configuration
No description file found
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
.sketch.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js doesn't exist
as directory
/Users/michaelcarter/node_modules/sketch-module-console-polyfill doesn't exist
[/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/lib/node_modules]
[/Users/michaelcarter/git/react-sketchapp/node_modules/react-test-renderer/node_modules]
[/Users/michaelcarter/git/react-sketchapp/node_modules/node_modules]
[/Users/michaelcarter/git/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/michaelcarter/node_modules/package.json]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/examples/symbols/node_modules/skpm/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/git/react-sketchapp/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill/package.json]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.sketch.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill.js]
[/Users/michaelcarter/node_modules/sketch-module-console-polyfill]
@ /Users/michaelcarter/git/react-sketchapp//react-test-renderer/lib/ReactUpdates.js 1:0-41
@ /Users/michaelcarter/git/react-sketchapp/
/react-test-renderer/lib/ReactTestRenderer.js
@ /Users/michaelcarter/git/react-sketchapp/~/react-test-renderer/index.js
@ /Users/michaelcarter/git/react-sketchapp/lib/buildTree.js
@ /Users/michaelcarter/git/react-sketchapp/lib/render.js
@ /Users/michaelcarter/git/react-sketchapp/lib/index.js
@ ./src/my-command.js

Thanks!

@jemgold
Copy link
Contributor

jemgold commented May 18, 2017

@michaelcarter-wf this is a bug with skpm's webpack config afaik — to fix it locally until we resolve it, npm install sketch-module-console-polyfill sketch-module-fetch-polyfill sketch-module-settimeout-polyfill sketch-module-setinterval-polyfill

@jemgold
Copy link
Contributor

jemgold commented Jun 5, 2017

So sorry this took so long to merge in — this is really wonderful work.

I'm going to merge it ASAP and then we can do another PR to add docs

you: a+++++ 😍
my maintainer skillz: D- ☠️

@opeologist
Copy link

@lukewestby i pulled down this work and it looks awesome, but i noticed that any updates to the symbols essentially breaks their past use, since sketch thinks the update to the symbols makes them new symbols. any way to hydrate the symbols so any use of the symbols get updated to the latest version of the symbols from code? thanks!

@jemgold
Copy link
Contributor

jemgold commented Jun 5, 2017

@tehOPEologist — I don't follow - any chance you could post a quick screencast of the behavior? (you can use kap if you don't have a screencasting thingy installed)

@opeologist
Copy link

i'm not near my dev environment to replicate/record right now, but essentially:

  1. use this fork to generate a symbol
  2. put the symbol that is now in sketch on a page
  3. update the component in code
  4. npm run render picks up the change and pushes the change to sketch
  5. the symbol you put on the page in step 2 now is "missing"

i'm wondering if there's a way to stop the last thing from happening, and the symbol that's in use get updated to reflect the changes made. that would make this symbol implementation incredibly useful for iterative changes to symbols.

@opeologist
Copy link

opeologist commented Jun 5, 2017

it looks like injectSymbols just replaces the layers in the Symbols page, which is why the symbols are "missing" 😢 if there was a way to update symbols in place, i think this feature would become a lot more powerful.

@jemgold jemgold changed the title [WIP] Symbol support Symbol support Jun 5, 2017
@jemgold jemgold merged commit 2500505 into airbnb:master Jun 5, 2017
@jemgold
Copy link
Contributor

jemgold commented Jun 5, 2017

welp, for some reason flow is bailing on master but wasn't on the branch. I have no idea. will look into it this afternoon, can't publish a new version until that's fixed.

@jemgold
Copy link
Contributor

jemgold commented Jun 5, 2017

@tehOPEologist — makes sense, let's circle back to it at a later point :)

marionebl added a commit to marionebl/skpm that referenced this pull request Jun 7, 2017
* deals with `Module not found: Error: Can't resolve 'sketch-module-console-polyfill'` in setups where `skpm` is linked into the using project.
* related: airbnb/react-sketchapp#53 (comment)
@chrislloyd
Copy link

👏 Thanks for everybody involved with this PR. So much awesome here.

@jongold now that this is merged, would it be possible to get a new release cut?

@jemgold
Copy link
Contributor

jemgold commented Jun 8, 2017

@chrislloyd done — was waiting for #110 to merge, just published 0.11.0 🙏

@jemgold
Copy link
Contributor

jemgold commented Jun 8, 2017

also if anyone gets comfortable with it, we'd appreciate a contribution to the API Documentation! #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants