-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Does Polymer have a JavaScript-first API? #3687
Comments
Hi @trusktr. You may want to checkout the Polymer Docs for that. |
@Pablo-Ivan I read that, but it doesn't show how to add markup to the element. Do we still need to use |
You can absolutely make an element exist only inside of a You can always make two files, HTML for the dom-module and template, and JS for the definition, and that is well supported. As for code loaders and bundlers, we think the available solutions are far from perfect. JS-only tools rely on either a non-standard CommonJS syntax and API, or an as-of-yet-unimplemented-in-browsers ES6 syntax and API. Neither approach is using the platform idiomatically and comes with a dependency on tooling in the short term (and perhaps medium to long term for CommonJS). Polymer uses HTMLImports to encode dependencies from one HTML file to another, and that serves our needs admirably. We have tools for bundling like vulcanize that behave similarly to the JS-focused tools, and it seems to work pretty well for our users. Other tools like crisper can split the I hope that answers your questions 😄 |
It does. Thanks! I was overlooking that we can simply call The "Get set up" section of the "Get started" guide doesn't mention the NPM package at https://www.npmjs.com/package/@polymer/polymer. That would be nice. |
@trusktr I think one reason it's not listed on our getting started docs is that we're not doing a good job of keeping the lib up to date on npm. @arthurevans, should we add info on the package to the docs? @justinfagnani, can we get the latest release up on npm? |
We shouldn't mention npm on the docs until it's actually supported. |
@ebidel @justinfagnani +1 to what Justin said. I don't want to document it until we have a reliable process for 1) updating the packages in NPM, and 2) using those packages in a project. |
Which begs the question, when will we support it? :) Many many many devs want it! |
@justinfagnani @azakus It may be a good idea to convert the v1 Custom Elements polyfill to ES6 modules at the same time. |
Closing this issue in favor of #326 Also note that in Polymer 2, you can now also pass a template as String |
Out of the box, Polymer offers an HTML-first API, meaning that we write HTML first (in
.html
files) then we can add JavaScript behavior as needed inside<script>
tags. On the other hand, Skate.js and X-Tag offer a JavaScript-first API meaning we can write JavaScript first (in.js
files) then we can add HTML as needed (in the.js
files, via React, Handlebars, etc).The advantage of JS-first API:
<script>
tags (as with Polymer) are not very friendly for build systems. To use ES6 Classes and other new language features (or custom features like JSX, CSSX, or glslify), we'd have to compile many bundles, one per component, and that would be additional to managing the Bower workflow.The getting-started docs for Polymer show the HTML-first approach, so I'm not sure if I may have missed the JS-first method of using Polymer, if any. Does one exist?
The text was updated successfully, but these errors were encountered: