question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createComment is not a function error - lit and lit-html 2.3.0

See original GitHub issue

Which package(s) are affected?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

using vite and vitest error with latest version of lit Screenshot 2022-08-15 at 11 11 09 AM

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:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
augustjkcommented, Aug 15, 2022

I think the issue here is that vitest is a node test runner and by default uses the node export condition. Here’s some relevant comment from a maintainer: https://github.com/vitest-dev/vitest/issues/1588#issuecomment-1173312515

There 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

2reactions
augustjkcommented, Aug 18, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found