1

I'm creating desktop and web apps as pure HTML+JavaScript and recently started using Web Components, as discussed here: How to run web components based HTML without node?

And here: How to run Polymer locally, without any web server?

I would like to do the same with LWC components and be able to include them in basic HTML/JS apps, without using node. I guess that potentially this can be done by replacing "import { LightningElement } from 'lwc'" with some external JavaScript files?

Any simple example would be appreciated - thanks!

1
  • When you start with native Web Components first, you don't have any of these issues. Once you mastered native technology you can choose to use any of the 55+ LWC alternatives and see if development indeed is easier. If you start with LWC you are learning a Tool first, and the Technology second. Commented Mar 24, 2022 at 10:59

1 Answer 1

1

I received a response from LWC development team, as follows:

" LWC components must be compiled by the LWC compiler before they can be run, so no, you cannot directly import LWC source files in the browser and use them in the browser. However, you can use the CustomElementConstructor API to import a compiled LWC component just like any other web component. Here is a demo: https://github.com/nolanlawson/lwc-barebone/tree/7e3662b7a86aa1f1ca2e0b39c2696057d3495519/src

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.