Simple script to import Web component files.
cd example
Run a http server
Example using nix-shell
and python
:
nix-shell -p python3 --run "python -m http.server"
(see https://gist.github.com/willurd/5720255 for more web server one-liner commands).
Simply cd
into this project directory, and direnv
will use nix-shell
with the shell.nix
file. Project dependencies from shell.nix
will automatically be installed and loaded.
We need to manually drop into a nix shell:
nix-shell
Now we need to install node-specific dependencies for linting/testing/etc.:
npm ci
(in future, would like to move these under 'nix' also)
Now make a pull request, or two :)
- Adopt Typescript
- Load style and template into shadow DOM.
- [] Support 'default export' of an object from .wc file:
- [] By default, will use
BaseComponent
. - [] Allow specifying
name
of component. - [] Allow specifying event handlers for component.
- convention?
on
orhandle
prefix?
- convention?
- [] Support specifying a custom class to export (if need to write more logic in component).
- [] If specifying a custom class, then event handlers should be in the custom class; do not allow event handlers in the exported object.
- [] By default, will use
- [] Support
default export
of a Web Component class.- Will most likely extend
BaseComponent
, orHTMLElement
. Of course can extend any other custom class. - [] Use class name as the custom element tag name
- Will most likely extend
- unable to support static import in <script> section of a .wc file. Might have to resort to writing a simple compiler? ]
- Some prior art: Svelte.
Ideally, we should move the node packages into shell.nix in future. This requires making nix derivations for each of the npm packages.
- Credit to Tomasz Jakut's "Implementing single file Web Components article for initial starting point.
- Unity Component Specification