-
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
Add importMeta getter to derive importPath from modules. Fixes #5163 #5172
Conversation
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.
1 nit, other than that LGTM. The Travis build failed on a missing semicolon
lib/mixins/element-mixin.html
Outdated
this._importPath = module ? module.assetpath : '' || | ||
Object.getPrototypeOf(/** @type {PolymerElementConstructor}*/ (this).prototype).constructor.importPath; | ||
if (module) { | ||
this._importPath = module ? module.assetpath : ''; |
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.
Can be just module.assetpath
, as the condition already asserted for module
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 in general
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.
Let's update the docs for importPath to mention importMeta.
lib/mixins/element-mixin.html
Outdated
@@ -409,13 +409,30 @@ | |||
*/ | |||
static get importPath() { | |||
if (!this.hasOwnProperty(JSCompiler_renameProperty('_importPath', this))) { | |||
const meta = this.importMeta; | |||
if (meta) { | |||
this._importPath = meta.url.slice(0, meta.url.lastIndexOf('/') + 1); |
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.
use resolveUrl.pathFromUrl
In order to determine the import path for ES modules, rather than implement
static get importPath()
and return the folder name ofimport.meta.url
, users can implement the following getter (verbatim), and Polymer will use that when defined to determine theimportPath
:Reference Issue
Fixes #5163
cc: @arthurevans to roll into 3.0 docs