Skip to content

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

Description

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)?

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions