-
Notifications
You must be signed in to change notification settings - Fork 319
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
Suggestion: remove bare import statements #724
Comments
It seems that the |
@magic-akari — bare specifiers is the best practice moving forward here are some compelling options you can use today
cheers! 👋 Chase |
@chase-moskal Thanks for your recommendation. Pika is awesome.
|
@magic-akari you can try using https://github.com/pikapkg/web if you want to avoid bundlers. |
ah, yes, i understand — i think the best solution for your use-case, to give you more control, would be to use es-module-shims, and configure an import map then you can use es modules with bare specifiers, and you can configure (via import map) the browser where to fetch using your own bundler is another option, but requires a build step also |
We very consciously chose to use bare specifiers, and we could not change this at this point even if we wanted to. We're following npm ecosystem standards by using bare specifiers. Nearly all tooling supports them, and the platform will soon too with import maps. Relative imports are not reliable in npm. In fact, many tools break with relative imports that reach out of the package. |
The only one dependence in
lit-element
islit-html
. (Thanks for removing@polymer/polymer
.)There are three methods to use
lit-element
?module
)But it is painful to use
lit-element
as es modules without any extra specific effort.lit-element
form./node_modules
as my demo project.lit-element
from other CDN. They don't support to rewrite bare import statements as unpkg doing.Maybe it is better to remove bare import statement from
lit-element
.There are only two functions/classes used in
lit-element
which is imported fromlit-html
.render function:
https://github.com/Polymer/lit-element/blob/46c8f404937672ed10587124ec3ddee82fd005fe/src/lit-element.ts#L76
TemplateResult:
https://github.com/Polymer/lit-element/blob/46c8f404937672ed10587124ec3ddee82fd005fe/src/lit-element.ts#L213
I did some try, here is my idea.
or
When the users are going to use LitElement, they have to inject the render function themselves first.
It's ok to create a wrapper file which imports
lit-html
and injects render function automatically. It will keep compatibility.As for
TemplateResult
, we may need a flag inlit-html
.It is my rough idea. There will, of course, be a lot more details when we get started for real.
Do you have any ideas?
Related issue: #140
The text was updated successfully, but these errors were encountered: