Leveraging the unpkg CDN for showcasing the Lit 3.0 my-element demonstration

Utilizing Lit 2.0, we were able to release a web component to npm and integrate it using a script tag similar to this example:

<script src="https://unpkg.com/@fireflysemantics/fs-gist"></script>

The specific component is part of this package.

Below are the pertinent properties found in the package.json:

  "main": "fs-gist.bundle.js",
  "module": "fs-gist.js",
  "types": "fs-gist.d.ts",
  "type": "module",

I attempted a similar approach with the my-element demo within the Lit 3.0 TypeScript starter.

Here is the GitHub repository link for testing purposes: This. It was published on npm under the name @fireflysemantics/wctest.

The relevant properties in the package.json file include:

  "main": "my-element.bundled.js",
  "module": "my-element.js",
  "types": "my-element.d.ts",
  "type": "module",

However, when attempting to utilize the element rollup bundle via the npm CDN, it fails to render correctly: StackBlitz.

Any suggestions or insights on this issue?

Answer №1

It appears that your bundler configuration is not visible to me, but based on the presence of an export statement in the bundle, it seems like you are outputting a standard JS module. However, the issue may lie in the fact that you have not included type="module" within the script tag, which could be causing the script to fail.

I've noticed peculiar behavior from Stackblitz as well: it does not seem to respect the type="module" attribute for some unknown reason.

If you were to move your sample to the lit.dev playground and add the type="module" attribute, it appears to function properly: here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A Guide to Implementing Inner CSS in Angular

I am working with an object named "Content" that has two properties: Content:{ html:string; css:string } My task is to render a div based on this object. I can easily render the html using the following code: <div [innnerHtml]="Content.html"& ...

The variable being declared at the class level inside a function within the same class is not recognized

Seeking guidance on the code snippet I'm currently studying. I am implementing a TypeScript 1.8.10 compiler along with EM5: module myAmazingModule{ 'use strict'; export interface INavigateService { links: string[], ...

Which option yields better performance: using useSelector() on an object directly or on its individual properties?

Imagine we are currently developing a Customer Profile page within our store, using an object called CustomerProfile. export interface ICustomerProfileState { status: string, customerId: number, contactInfo: IContactInfo, financialInfo: IFi ...

Leveraging aws-sdk within a TypeScript, jQuery, and webpack application

Greetings! I have a TypeScript/jQuery/Webpack application with all the latest releases, and everything seems to be functioning properly. Now, I am attempting to integrate the aws-sdk into it. I followed the same approach I used for importing other librarie ...

An error was encountered while attempting to proxy the request [HPM]

After cloning a GitHub repository, I ran npm i in both the root directory and client directories. I then created a development configuration file. However, when attempting to run npm run dev, nodemon consistently crashes with a warning about compiled cod ...

How can you optimize the storage of keys in JS objects?

Just pondering over this scenario: Consider a line definition like the one below, where start and end are both points. let ln = { s: {x:0, y:0}, e: {x:0, y:0}, o: 'vertical' } Now imagine having a vast array of lines, how can we sav ...

Resolve the "kexec" malfunction obstructing the successful execution of "npm install" for packages like WebPack in the "node_modules" directory following an upgrade to node versions 12, 13, or 14

After upgrading from "node" to "node 14", I attempted an "npm install" but encountered a failure due to the compilation error of "kexec" (also known as "node-kexec") which is a requirement for WebPack. The error messages received were: npm ERR! path /User ...

Encountering compilation issues when transitioning from Angular 7 to Angular 8

Upon upgrading my project to Angular 8, an unexpected error occurs during the build process: ERROR in HostResourceLoader: loader(C:/myapp/cli/src/app/pages/user-home/user-home.component.html) returned a Promise i 「wdm」: Failed to compile. Ho ...

The specified property is not found within this type (Union type)

When working with one of multiple interfaces, I encounter an issue in Vue where it claims the property does not exist. export interface Link { to: string text?: string; } export interface Text { text: string; } export interface Html { html: string ...

The object does not contain a 'navigation' property within the 'Readonly<{}> & Readonly<{ children?: ReactNode; }>' type

As a beginner in react native, I am facing some challenges with the components I have created. Let me share them: List of Playlists: export default class Playlists extends Component { playlists = [ ... ]; render() { const {navigation} = th ...

Error thrown when using React Router DOM: FC{} | ReactNode is not compatible with type ReactNode

Recently, I started using TypeScript and delving into a project that involves the react-router-dom. However, as I attempt to create elements in my App.tsx file, an error keeps popping up. Let's take a look at the code snippet: <Route path="la ...

What steps do I need to take in order to obtain the value for insertion into a form for editing, so that the record

In order to display all book records in a table and provide the functionality to edit these records, you can utilize the following code snippet. This code includes a button that redirects to the editbook.html page where you can update the record: <tbody ...

We couldn't locate the module: Unable to find the '@react-aria/interactions' sourceMapping

I've encountered an issue while trying to integrate Native Base into my existing Expo React project. Despite following the instructions outlined in their installation guide and installing the necessary packages, I keep running into errors. I've a ...

The console is displaying a promise that is pending, rather than the desired data

Here is the content of my file: 'use strict' import * as moment from "moment"; import { Report} from "./Report"; import { Timeframe} from "./Timeframe"; import { ReportComparison } from "./ReportComparison"; function test(firstFrom: string, fi ...

A step-by-step guide on updating a deprecated typings package manually

Currently, I am developing a NodeJS application using TypeScript and incorporating numerous Node packages. However, not all of these packages come with TypeScript definitions, so Typings is utilized to obtain separate definition files. During the deployme ...

ngif directive does not function properly when subscribe is utilized in ngOnInit

this is the unique component code import { Component, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; //import { Item } from '../item/item.model'; import { CartItem } from './cart-item.model'; imp ...

Guide on incorporating a library into an external project without the need to publish it on NPM for Angular applications

I've encountered an issue with my 2 angular apps that require the use of the same services and interfaces. To address this, I decided to create a separate project where I built a library containing these shared services and interfaces. Once the librar ...

rxjs module is mysteriously missing in Visual Studio 2019, yet it can be easily located when using the t

I recently integrated TypeScript into an aging angularjs project with the intent of eventually transitioning to Angular 2+. In my TypeScript code, I am eager to utilize rxjs observables; however, I have encountered some unexpected behavior during my attemp ...

The color of the text in Tailwind is displayed in a refreshing blue instead of the

In my current project, I am utilizing React JS with Node, and npm as the package manager. Within the project, I have incorporated various packages such as heroicons and tailwind. To style the text in my footer as grey, I have applied the "text-slate-500" ...