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

[WIP] Add Polymer 2 support #2225

Merged
merged 83 commits into from
Jan 13, 2018
Merged

[WIP] Add Polymer 2 support #2225

merged 83 commits into from
Jan 13, 2018

Conversation

leonrodenburg
Copy link

@leonrodenburg leonrodenburg commented Nov 3, 2017

What I did

We added initial support for Polymer 2 and set up an example application. We are in the process of improving the compatibility in all browsers and adding support for all Storybook addons. Tests have to be added.

How to test

  • Run yarn in the repo root
  • Run yarn bootstrap in the repo root
  • Change to examples/polymer-cli directory (cd examples/polymer-cli)
  • Start Storybook (yarn storybook)

The Welcome page and example stories should be shown at http://localhost:9001/

TODO

  • Firefox support
  • Fix getstorybook CLI command for polymer
  • Support for other addons, especially knobs
  • Fix tests
  • Improve examples stories
  • Allow string templates
  • Add example stories for Polymer
  • HMR
  • Try to generalise for all web component frameworks (won't fix in this PR)
  • Cleanup code (lot of React stuff in there from copying)
  • Bring PR up to date with latest changes

ndelangen and others added 30 commits November 3, 2017 09:39
Run through webpack-dev-server
@robdodson
Copy link

I would wait on supporting Polymer 3 until the team starts announcing a release candidate.

@equinusocio
Copy link

equinusocio commented Dec 4, 2017

@robdodson v3 is not just a v2 delivered with npm? Do you have info about some polymer 3 announcements?

@robdodson
Copy link

@equinusocio yes it will be delivered over npm but I think the team is still designing the project and I don't know when they plan to release it. So supporting an early alpha might be difficult because they may make breaking changes along the way.

# Conflicts:
#	package.json
#	yarn.lock
@ndelangen
Copy link
Member

We should add a netlify deploy/site for this, so we can demo this!

@ndelangen ndelangen changed the base branch from release/3.3 to master December 23, 2017 22:54
@ndelangen
Copy link
Member

@shilman I'd like your approval to merge this

import createChannel from '@storybook/channel-postmessage';
import Preview from './preview';

export default class ReactProvider extends Provider {
Copy link
Member

Choose a reason for hiding this comment

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

Is this called ReactProvider and not PolymerProvider because it bridging between Polymer and React?

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Is there any reason why don't have demo components defined in here? We do in both react/angular (but don't in vue). don't care too heavily either way, but maybe we should be consistent?

@shilman shilman merged commit 4c050d2 into master Jan 13, 2018
@shilman shilman deleted the add-polymer-support branch January 13, 2018 10:12
@@ -0,0 +1 @@
// TODO: add demo stories
Copy link
Member

Choose a reason for hiding this comment

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

Will we do that?

@tonai
Copy link
Contributor

tonai commented Apr 27, 2018

Hi all,

I have tried the following on my existing stencil project (which is derivated from stencil-component-starter):

npm install --save-dev @storybook/polymer polymer-webpack-loader

Then I added the script line in the package.json:

{
  "scripts": {
    "storybook": "start-storybook -p 9001 -c .storybook -s www"
  }
}

I created the .storybook folder containing a basic config.js file:

import { configure } from '@storybook/polymer';
const req = require.context('../src', true, /\.stories\.js$/);
function loadStories() {
  req.keys().forEach((filename) => req(filename))
}

configure(loadStories, module);

And a preview-head.html with:

<script src="/build/mycomponent.js"></script>
<link rel="stylesheet" type="text/css" href="/build/mycomponent.css">

Finally I created a story:

import { storiesOf } from '@storybook/polymer';
const stories = storiesOf('Button', module);
stories.add('using string', () => ('<hec-button>Click here</hec-button>'));

But I got the following error:

custom-elements-es5-adapter.js:4 Uncaught TypeError: Class constructor  cannot be invoked without 'new'
    at new j (custom-elements-es5-adapter.js:4)
    at renderMain (VM489 preview.bundle.js:27558)
    at renderPreview (VM489 preview.bundle.js:27574)
    at renderUI (VM489 preview.bundle.js:26461)
    at Object.dispatch (VM489 preview.bundle.js:24235)
    at ConfigApi._renderMain (VM489 preview.bundle.js:27342)
    at render (VM489 preview.bundle.js:27293)
    at ConfigApi.configure (VM489 preview.bundle.js:27318)
    at Object.<anonymous> (VM489 preview.bundle.js:26365)
    at Object.defineProperty.value (VM489 preview.bundle.js:26366)

This comes from the custom-elements-es5-adapter.js script which is included by @storybook/polymer (@storybook/polymer/dist/server/iframe.html.ejs).

I have commented out the custom-elements-es5-adapter.js and webcomponents-lite.js scripts directly in the file and it finally works.

I don't know if I can override the template iframe.html.ejs inside my project, because this is clearly a dirty trick to make it works...

@ndelangen
Copy link
Member

@naipath something you could do here?

@equinusocio
Copy link

Polymer 3 is on the way, it will be released in weeks...do worth integrating v2?

@tonai
Copy link
Contributor

tonai commented May 2, 2018

Updating my process with the usage of @storybook/[email protected]:

Just changing the first npm install and keep the rest:

npm install --save-dev @storybook/polymer@4.0.0-alpha.4 polymer-webpack-loader lit-html

And it works 👍 😄

Just one warning is remaining:

WARNING in ./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js
Module not found: Error: Can't resolve 'vertx' in './node_modules/@webcomponents/webcomponentsjs'

But doesn't seems to be blocking so far.

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

Successfully merging this pull request may close these issues.