-
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
Export the current Polymer version in polymer-element.js #5317
Conversation
polymer-element.js
Outdated
* Current Polymer version in Semver notation. | ||
* @type {String} Semver notation of the current version of Polymer. | ||
*/ | ||
export const version = '3.0.5'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
@kevinpschaaf This is ready for review again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks
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