0
votes

I'm creating a lit-element that has an external javascript dependency (npm module) that is not packaged as an es6 module. What is the recommended way of loading this dependency?

Should I just use a script tag in my index.html that references the cdn version of this module

//index.html
<script src="cdnToexternalJavascriptDependcy"></script>

but that would not encapsulate the dependency within the lit-element.

In Polymer, we can just use HTMLImports inside a html file and "import" it which would handle deduplication of dependencies.

For lit-element, what is the recommended way of encapsulating this "non-es6-module" dependency within my custom lit-element without using a bundler like webpack?

1

1 Answers

1
votes

You can load it as normal script. If you load it from CDN it will not be included in the bundle. If you load it from node_modules folder when you use polymer build it'll bundle the dependency.