DEV Community

Kevin Jump
Kevin Jump

Posted on

Umbraco Early Adopters Gotcha - use @umbraco lit

Things i keep getting wrong part n+1

when you are developing your elements and contexts for the new Umbraco backend - visual studio code is very good at auto inserting all the import statements for you.

import { UmbModalBaseElement, UmbModalToken } from "@umbraco-cms/backoffice/modal";
import { html } from "lit";
import { customElement } from "lit/decorators.js";
Enter fullscreen mode Exit fullscreen mode

the vite process then does a good job of working out what needs to be included in your js files.

but Umbraco already has the lit library as an external reference.
if you swap out your lit library references out for umbraco ones.

import { UmbModalBaseElement, UmbModalToken } from "@umbraco-cms/backoffice/modal";
import { html, customElement } from "@umbraco-cms/backoffice/external/lit";
Enter fullscreen mode Exit fullscreen mode

It's not a lot but if you do this then your compiled javascript will smaller as it won't need to include any lit methods you've used as they will be in the umbraco libraries.

Top comments (0)