Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Stackblitz demos for 3.x elements #2537

Merged
merged 14 commits into from
Apr 28, 2018
Merged

Stackblitz demos for 3.x elements #2537

merged 14 commits into from
Apr 28, 2018

Conversation

e111077
Copy link
Contributor

@e111077 e111077 commented Apr 25, 2018

The commit messages might be helpful to follow for review here.

What I've done:

I added inline demos for 3.0. It uses stackblitz. See gif at the bottom of this PR for example

Usage:

  1. Create a sample folder
    1. Add your files
    2. Must include an index.html and an index.js
    3. Files must be included in a manifest.json at the root of that folder
      1. API of manifest json is { files: string[], dependencies: { [npmDepName: string]: string }}
  2. Create a demo tabs element
    1. Usage is the same as before
    2. Instead of adding a src which was used for plunkr links, use projectPath which is the path to the sample folder you just created (e.g. /3.0/samples/custom-element)
    3. optional: define an editorOpenFile to declare what file will be shown upon editor embed

Performance

3.0 quick-tour Chrome with service worker and cache on

first time page load

test new old change explanation
page load 662kb 1mb down removed iframe demo
opening single editor 3.7mb 1mb up cannot be service-worked only cached
opening all editors 3.8mb 1mb up editor static files cached

subsequent page load

test new old change explanation
page load 147kb 160kb down removed iframe demo
opening single editor 156kb 160kb down editor cached
opening all editors 227kb 160kb up editor static files cached

Lighthouse

Lighthouse score went up to high 60s from low 60s as we removed the iframe demos and lazy load the editor.

Outstanding issues

Critical

Nice to have

Demo

Try it out! Link
clicktoload

@e111077 e111077 requested review from justinfagnani, arthurevans, keanulee and a user April 25, 2018 23:01
@e111077 e111077 changed the title Stack blitz demos for 3.x elements Stackblitz demos for 3.x elements Apr 25, 2018
Copy link
Contributor

@keanulee keanulee left a comment

Choose a reason for hiding this comment

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

Do you have a sample deployment? Maybe @arthurevans or @katejeffreys should try the gulp/deploy process?

},

// Call out to a global method defined by app.js
_plunkerLaunched: function() {
_hideEditorButton: function(srcDefined, prjoectPathDefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

_hideEditorButton is a method AND a property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops


_isStackBlitz: {
type: Boolean,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

_isPlunkr and _isStackBlitz unused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah I forgot to rename srcDefined to this etc.

return (!src || src === '');
_srcProjectPathChanged: function(src, projectPath) {
this._srcDefined = !!this.src;
this._projectPathDefined = !!this.projectPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel like _srcDefined and _projectPathDefined aren't needed since they're just proxies for src/projectPath

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the process of removing them, but I'm going to need one that is of type boolean as the databinding will not work if I try

<div hidden$=[[!stringThatIsUndefined]]>

@@ -0,0 +1,186 @@
<link rel="import" href="./stack-blitz-sdk.html">
Copy link
Contributor

Choose a reason for hiding this comment

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

stack-blitz-sdk.html doesn't need to exist (not used elsewhere so doesn't need to be de-duped) - just have <script src="../js/sdk.umd.js"></script> here

}.bind(this)).catch(onError);
}.bind(this);

this.importHref('/elements/stack-blitz.html', onLoad, onError, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes implemented

@EricSimons
Copy link

Hey everyone- StackBlitz co-creator here! Super excited to see this PR :)

Just wanted to give y'all an update on the ETA for the various items outlined above from our end. With ngconf done and our Teleport feature out the door, we're finally able to focus on the next version of our bundler/dev server which solves all the 'critical' & 'nice to have' items. Specifically, we're going to enable serving the static JS files themselves without any transpilation done beforehand.

We're realistically shooting to have this live on prod in ~4 weeks- would love to hear everyone's thoughts/if there's func in polymer CLI that'd be ideal to have on StackBlitz as well 🥂

@e111077
Copy link
Contributor Author

e111077 commented Apr 26, 2018

@EricSimons TBH it's miraculous that bare module specifiers work out of the box for ES6 modules with no additional tooling.

There is nothing really polymer-cli-specific that I can think of atm, but there are a few rough patches that we've been filing issues for. Perhaps we can sync up later sometime in VC to discuss this further?

CC @justinfagnani

@EricSimons
Copy link

Sounds good! My email is eric at esft.com, so feel free to drop me a note and we'll get something on the calendar 👍

@ghost
Copy link

ghost commented Apr 26, 2018

\o/ i will try to review this Thursday 26th

@ghost ghost self-assigned this Apr 26, 2018
package.json Outdated
@@ -7,7 +7,8 @@
"node": ">=5.0.0"
},
"scripts": {
"postinstall": "bower install; gulp",
"postinstall": "bower install; npm run generate-stackblitz; gulp",
"generate-stackblitz": "cp ./node_modules/@stackblitz/sdk/bundles/sdk.umd.js ./app/js/sdk.umd.js; cp ./node_modules/@stackblitz/sdk/bundles/sdk.umd.js.map ./app/js/sdk.umd.js.map;",
Copy link
Contributor

@keanulee keanulee Apr 26, 2018

Choose a reason for hiding this comment

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

Can we use a hosted version of the SDK instead? Not a huge fan of this one-off, manual copying from node_modules/.

<script src="https://unpkg.com/@stackblitz/sdk/bundles/sdk.umd.js"></script>

(referenced https://medium.com/@ericsimons/stackblitz-sdk-instantly-add-live-environments-to-your-docs-blogs-more-73dab05c51ae)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll just need to add this to the service worker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spoke offline, decided it's best not to add SW

.gitignore Outdated
dist
build

# Dev directories
/app/bower_components
/node_modules
/app/node_modules
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think this is created.

@e111077
Copy link
Contributor Author

e111077 commented Apr 26, 2018

package.json Outdated
@@ -22,6 +22,7 @@
},
"homepage": "https://www.polymer-project.org/1.0/",
"devDependencies": {
"@stackblitz/sdk": "^1.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Reset this file and package-lock.json

.gitignore Outdated
@@ -3,6 +3,7 @@
# Generated files/folders
*.pyc
app/css/*
app/js/sdk*
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this

@@ -0,0 +1,187 @@
<link rel="import" href="../bower_components/polymer/polymer.html">

<script src="https://unpkg.com/@stackblitz/sdk/bundles/sdk.umd.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Pin unpkg to a specific version to avoid breakages/extra redirect https://unpkg.com/@stackblitz/[email protected]/bundles/sdk.umd.js

gulpfile.js Outdated
@@ -251,6 +251,7 @@ gulp.task('jshint', 'Lint JS', function() {
return gulp.src([
'gruntfile.js',
'app/js/**/*.js',
'!app/js/**/sdk*',
Copy link
Contributor

Choose a reason for hiding this comment

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

argh, one more thing to remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just testing you... you pass

Copy link
Contributor

@keanulee keanulee left a comment

Choose a reason for hiding this comment

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

Code changes LGTM. Will defer to @arthurevans and/or @katejeffreys to test on their machines as well.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Tested, works beautifully on my machine. Thank you so much for this!!

@e111077 e111077 merged commit 36248de into master Apr 28, 2018
@e111077 e111077 deleted the stack-blitz branch April 28, 2018 00:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants