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

Export the current Polymer version in polymer-element.js #5317

Merged
merged 3 commits into from
Aug 27, 2018

Conversation

TimvdLippe
Copy link
Contributor

Potential solution for exposing the Polymer version in polymer-element.js. Not sure if this is the desired solution, but it seemed like the best option we have.

Reference Issue

Fixes #5211

* Current Polymer version in Semver notation.
* @type {String} Semver notation of the current version of Polymer.
*/
export const version = '3.0.5';
Copy link
Member

Choose a reason for hiding this comment

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

Although this change makes introspecting the version from a running page possible, it is fairly cumbersome:

import('./need-to-know-path-to-polymer/polymer-element.js').then(module => console.log(module.version));

And that only works if a build tool hasn't compiled modules into bundles or out altogether.

I think it would be pretty useful to have e.g. a static getter on the ElementMixin return the version (in addition to a plain module export), so that it's more straightforward to introspect the version being used on a running page.

e.g. from an element in the inspector

console.log($0.constructor.polymerElementVersion);

or e.g. from the registry:

console.log(customElements.get('my-app').polymerElementVersion);

So perhaps the version can be exported from element-mixin.js instead of here, and returned from a new static get polymerElementVersion() { return version; } getter on the ElementMixin? It could also be re-exported from polymer-element.js for convenience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevinpschaaf Good idea! Updated.

gulpfile.js Outdated
return gulp.src('lib/utils/boot.js')
.pipe(replace(/(window.Polymer.version = )'\d+\.\d+\.\d+'/, `$1'${require('./package.json').version}'`))
.pipe(gulp.dest('lib/utils'));
return gulp.src('polymer-element.js')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to myself: should update to element mixin

@TimvdLippe
Copy link
Contributor Author

@kevinpschaaf This is ready for review again

Copy link
Member

@kevinpschaaf kevinpschaaf left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@kevinpschaaf kevinpschaaf merged commit 7a67e34 into master Aug 27, 2018
@kevinpschaaf kevinpschaaf deleted the export-version branch August 27, 2018 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants