createComment is not a function error - lit and lit-html 2.3.0
See original GitHub issueWhich package(s) are affected?
Lit Core (lit / lit-html / lit-element / reactive-element)
Description
using vite and vitest error with latest version of lit
Reproduction
Please check stackblitz URL
https://stackblitz.com/edit/vitejs-vite-omm8ny
Workaround
downgrade to lit@2.2.8
and lit-html@2.2.7
version
Is this a regression?
Yes. This used to work, but now it doesn’t.
Affected versions
2.3.0
Browser/OS/Node environment
Chrome 103 MacOSX Node 16
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error after upgrading to latest version · Issue #364 · lit/lit - GitHub
/edit: I see that a newer version of shady added prepareTemplateDom. But I guess the right dependencies aren't in lit-html / lit-element.
Read more >Template inside render function is not resolving - LitElement
Question: How to show a loader till I get the data from the Promise? import { LitElement, html } from 'lit-element'; class EmpComponent ......
Read more >@lit-labs/ssr - npm
A package for server-side rendering Lit templates and components. Status. @lit-labs/ssr is pre-release software, not quite ready for public ...
Read more >lit-html | Yarn - Package Manager
html : A JavaScript template tag used to produce a TemplateResult , which is a container for a template, and the values that...
Read more >Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError- Some selector is not a function - jQuery is not a function - owlCarousel is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the issue here is that
vitest
is a node test runner and by default uses thenode
export condition. Here’s some relevant comment from a maintainer: https://github.com/vitest-dev/vitest/issues/1588#issuecomment-1173312515There appears to be an option to potentially override that here https://vitest.dev/config/#transformmode-web
I tried just grabbing all .js files and forcing the transform by inlining all the dependencies in your stackblitz repro and the test command does seem to work. https://stackblitz.com/edit/vitejs-vite-zwvume?file=vite.config.js
While it’s work-aroundable, perhaps we can also add some check here to use an existing
document
if it exists.https://github.com/lit/lit/blob/ecdb3bcd311772e227f6e2b8e73614471ddf2682/packages/lit-html/src/lit-html.ts#L347-L353