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

Clarification on the modularity of Polymer within external web component scripts: Is Polymer designed in a way to export it as a (commonjs) module? #666

Closed
lozandier opened this issue Jul 29, 2014 · 2 comments
Assignees

Comments

@lozandier
Copy link

I'm trying to figure out how whether or not polymer library users can wrap around Polymer to make it a node-style module in order to create an external script for a web component with libraries I hope to load in as modules using browserify or a similar module tool.

my-custom-element.js

let _ = require('libraryA'); 
let Polymer = require("polymer-module"); 

Polymer('my-custom-element', {
  // my-custom-element's properties and methods 
})

polymer-module.js (browserify-style)

module.exports = ????

I thought it would be simple as creating JavaScript or CoffeeScript file that exports the Polymer object, but apparently not since the polymer.js file begins with stuff like window.PolymerGestures={}.

Since most will import polymer.html, are we expected to not overthink it and merely import anything else we would like to add in our Polymer function declaration to define our web components however we like (requirejs, browserify, and whatever else) instead of having to account for it being anything different in our external script tags (even when minified)?

@sjmiles
Copy link
Contributor

sjmiles commented Aug 18, 2014

As of today, Polymer itself is simply a global. I consider this acceptable given the context.

If there is a practical reason to make it importable as a module, I'd like to gather that information, but I don't believe there is a compelling rationale at the moment.

This is only for Polymer itself, individual elements can be modules or use modules from various sources using various techniques.

@sjmiles sjmiles closed this as completed Aug 18, 2014
@lozandier
Copy link
Author

Thanks for the clarification, @sjmiles.

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

No branches or pull requests

2 participants