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

Description

@lozandier

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

Activity

  1. sjmiles commented on Aug 18, 2014

    @sjmiles
    Contributor

    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.

  2. lozandier commented on Aug 18, 2014

    @lozandier
    Author

    Thanks for the clarification, @sjmiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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