Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
docs: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsukina-7mochi committed Mar 8, 2024
1 parent e12fe69 commit 06fe064
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 28 deletions.
2 changes: 2 additions & 0 deletions example/lit-esmsh/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const lockMap = JSON.parse(Deno.readTextFileSync('./deno.lock'));

const denoPath = await esbuildCachePlugin.util.getDenoDir();
await esbuild.build({
target: "esnext",
platform: "browser",
entryPoints: ['./index.ts'],
bundle: true,
outfile: './bundle.js',
Expand Down
1 change: 1 addition & 0 deletions example/lit-esmsh/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"lib": [
"DOM"
]
Expand Down
16 changes: 4 additions & 12 deletions example/lit-esmsh/my-counter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { css, html, LitElement } from 'lit';
// decorators are not currently supported by esbuild
// import { customElement, property } from 'lit/decorators.js';
import { customElement, property } from 'lit/decorators.js';

@customElement('my-counter')
export class MyCounter extends LitElement {
static properties = {
count: { type: Number },
};
static styles = css`
button {
padding: 1em;
Expand All @@ -26,12 +23,8 @@ export class MyCounter extends LitElement {
}
`;

declare count: number;

constructor() {
super();
this.count = 0;
}
@property({ type: Number })
accessor count = 0;

private _increment() {
this.count += 1;
Expand All @@ -43,4 +36,3 @@ export class MyCounter extends LitElement {
`;
}
}
customElements.define('my-counter', MyCounter);
1 change: 1 addition & 0 deletions example/lit-esmsh/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Example: Using Lit from esm.sh

Using Lit from esm.sh, mapping `lit` to remote URL (see `import_map.json`.)
Note that esbuild compiles typescript decorators (`experimentalDecorators`) into ES decorators, therefore compiled code can be executed only with browsers that supports ES decorators.
2 changes: 1 addition & 1 deletion example/lit-npm/import_map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"imports": {
"lit": "npm:lit",
"lit/": "npm:lit/"
"lit/decorators.js": "npm:lit/decorators.js"
}
}
17 changes: 4 additions & 13 deletions example/lit-npm/my-counter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { css, html, LitElement } from 'lit';
// decorators are not currently supported by esbuild
// import { customElement, property } from 'lit/decorators.js';
import { customElement, property } from 'lit/decorators.js';

@customElement('my-counter')
export class MyCounter extends LitElement {
static properties = {
count: { type: Number },
};
static styles = css`
button {
padding: 1em;
Expand All @@ -26,13 +23,8 @@ export class MyCounter extends LitElement {
}
`;

declare count: number;

constructor() {
super();
this.count = 0;
}

@property({ type: Number })
accessor count = 0;
private _increment() {
this.count += 1;
}
Expand All @@ -43,4 +35,3 @@ export class MyCounter extends LitElement {
`;
}
}
customElements.define('my-counter', MyCounter);
4 changes: 2 additions & 2 deletions example/lit-npm/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Example: Using Lit from npm registry

Using Lit from npm registry, mapping `lit` to npm module (see
`import_map.json`.)
Using Lit from npm registry, mapping `lit` to npm module (see `import_map.json`.)
Note that esbuild compiles typescript decorators (`experimentalDecorators`) into ES decorators, therefore compiled code can be executed only with browsers that supports ES decorators.

0 comments on commit 06fe064

Please sign in to comment.