Skip to content

Commit 06d0f39

Browse files
committed
chore(starters): enable lit library starter
- enable lit library starter for CLI - fix broken go starter links Signed-off-by: Cory Rylan <crylan@nvidia.com>
1 parent e72e4f9 commit 06d0f39

5 files changed

Lines changed: 52 additions & 35 deletions

File tree

projects/starters/go/src/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta name="description" content="A simple starter using Elements and TypeScript." />
88
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
9-
<link rel="stylesheet" type="text/css" href="https://https://esm.sh/@nvidia-elements/core/dist/bundles/index.css" /> <!-- will be replaced by CDN when available-->
9+
<link rel="stylesheet" type="text/css" href="https://esm.sh/@nvidia-elements/styles/dist/bundles/index.css" />
10+
<link rel="stylesheet" type="text/css" href="https://esm.sh/@nvidia-elements/themes/dist/bundles/index.css" />
11+
<link rel="stylesheet" type="text/css" href="https://esm.sh/@nvidia-elements/themes/dist/fonts/inter.css" />
12+
<link rel="stylesheet" type="text/css" href="https://esm.sh/@nvidia-elements/monaco/dist/bundles/index.css" />
1013
<script type="module">
11-
import 'https://https://esm.sh/@nvidia-elements/core/dist/bundles/index.js'; // will be replaced by CDN when available
14+
import "https://esm.sh/@nvidia-elements/core/dist/bundles/index.js"
1215
</script>
1316
</head>
1417
<body nve-text="body">
@@ -18,7 +21,7 @@
1821
<a slot="prefix" href="https://NVIDIA.github.io/elements/">Elements</a>
1922
<nve-button container="flat"><a href="https://NVIDIA.github.io/elements/docs/integrations/angular/" target="_blank">Catalog</a></nve-button>
2023
<nve-button container="flat"><a href="https://NVIDIA.github.io/elements/starters/">Starters</a></nve-button>
21-
<nve-button container="flat"><a href="https://github.com/NVIDIA/elements/" target="_blank">Gitlab</a></nve-button>
24+
<nve-button container="flat"><a href="https://github.com/NVIDIA/elements/" target="_blank">GitHub</a></nve-button>
2225
</nve-page-header>
2326
<nve-page-panel slot="left" size="sm">
2427
<nve-page-panel-content>

projects/starters/lit-library/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import '@nvidia-elements/themes/dark.css';
1515
import '@nvidia-elements/styles/layout.css';
1616
import '@nvidia-elements/styles/typography.css';
17-
import './dist/login/define.js';
17+
import 'lit-library-starter/login/define.js';
1818
</script>
1919
</body>
2020
</html>

projects/starters/lit-library/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@
6464
"lit": "catalog:"
6565
},
6666
"peerDependencies": {
67-
"@nvidia-elements/core": "workspace:*"
67+
"@nvidia-elements/core": "workspace:^"
6868
},
6969
"devDependencies": {
70-
"@internals/vite": "workspace:*",
7170
"@nvidia-elements/core": "workspace:*",
7271
"@nvidia-elements/styles": "workspace:*",
7372
"@nvidia-elements/themes": "workspace:*",
74-
"@internals/testing": "workspace:*",
7573
"@nvidia-elements/lint": "workspace:*",
7674
"@vitest/browser": "catalog:",
7775
"@vitest/browser-playwright": "catalog:",
@@ -101,6 +99,7 @@
10199
"src/**",
102100
"!src/**/*.examples.ts",
103101
"!src/**/*.test.ts",
102+
"!src/**/*.test.*.ts",
104103
"package.json",
105104
"tsconfig.lib.json",
106105
"vite.config.ts"
@@ -132,8 +131,7 @@
132131
],
133132
"output": [],
134133
"dependencies": [
135-
"build",
136-
"../../internals/testing:build"
134+
"build"
137135
]
138136
},
139137
"test:watch": {

projects/starters/lit-library/src/login/login.test.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { html } from 'lit';
1+
import { html, render, type TemplateResult } from 'lit';
22
import { describe, expect, it, beforeEach, afterEach } from 'vitest';
3-
import { createFixture, elementIsStable, removeFixture } from '@internals/testing';
43
import type { DomainLogin } from 'lit-library-starter/login';
54
import 'lit-library-starter/login/define.js';
65

@@ -62,3 +61,22 @@ describe('domain-login', () => {
6261
expect(element.validity.patternMismatch).toBe(true);
6362
});
6463
});
64+
65+
async function createFixture(template: TemplateResult) {
66+
const fixture = document.createElement('div');
67+
document.body.append(fixture);
68+
render(template, fixture);
69+
await customElements.whenDefined('domain-login');
70+
return fixture;
71+
}
72+
73+
function removeFixture(fixture: HTMLElement) {
74+
fixture.remove();
75+
}
76+
77+
async function elementIsStable(element: DomainLogin, attemptsRemaining = 10): Promise<void> {
78+
if (await element.updateComplete) return;
79+
if (attemptsRemaining > 0) return elementIsStable(element, attemptsRemaining - 1);
80+
81+
throw new Error('Element did not stabilize');
82+
}

projects/starters/lit-library/vite.config.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import process from 'process';
1+
import fs from 'node:fs';
2+
import { resolve as resolvePath } from 'node:path';
3+
import process from 'node:process';
44
import { defineConfig } from 'vite';
55
import minifyHTML from 'rollup-plugin-html-literals';
66
import dts from 'vite-plugin-dts';
77
import { globSync } from 'glob';
88

9-
const packageFile = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url)) as any);
10-
const resolve = rel => path.resolve(process.cwd(), rel);
9+
const getAbsolutePath = (file: string) => resolvePath(process.cwd(), file);
10+
const packageFile = JSON.parse(fs.readFileSync(getAbsolutePath('./package.json'), 'utf-8'));
1111
const index = process.argv.findIndex(i => i === '--outDir') + 1;
1212
const dist = (p = '') => `${index ? process.argv[index] : './dist'}/${p}`;
13+
const prod = process.env.NODE_ENV === 'production';
1314

14-
export default defineConfig(env => {
15-
const mode = env.mode as 'production' | 'watch' | 'test' | 'development';
16-
15+
export default defineConfig(({ mode }) => {
1716
return {
1817
resolve: {
1918
alias: {
20-
'lit-library-starter': resolve('./src')
19+
'lit-library-starter': getAbsolutePath('./src')
2120
}
2221
},
2322
plugins: [
2423
{
2524
...dts({
26-
root: resolve('.'),
27-
entryRoot: resolve('./src'),
28-
outDir: dist(),
29-
exclude: ['**/*.test.ts', '**/*.examples.ts']
25+
root: getAbsolutePath('.'),
26+
entryRoot: getAbsolutePath('./src'),
27+
exclude: ['**/*.test.ts', '**/*.test.*.ts', '**/*.examples.ts']
3028
}),
3129
enforce: 'pre'
3230
}
3331
],
3432
build: {
33+
reportCompressedSize: false,
3534
cssCodeSplit: true,
3635
minify: true,
3736
watch: mode === 'watch' ? {} : undefined,
3837
outDir: dist(),
39-
emptyOutDir: false,
40-
sourcemap: true,
38+
emptyOutDir: true,
39+
sourcemap: prod,
4140
target: 'esnext',
4241
lib: {
43-
entry: {
44-
index: resolve('./src/index.ts'),
45-
...globSync('./src/**/define.ts').reduce((p, i) => {
46-
// all component entrypoints
47-
return { ...p, [i.replace('src/', '').replace('.ts', '')]: resolve(i) };
48-
}, {})
49-
}
42+
entry: Object.fromEntries(
43+
[
44+
'./src/index.ts',
45+
...globSync('./src/**/index.ts', { ignore: ['./src/index.ts'] }),
46+
...globSync('./src/**/define.ts')
47+
].map(file => [file.replace(/^\.?\/?src\//, '').replace(/\.ts$/, ''), getAbsolutePath(file)])
48+
)
5049
},
5150
rolldownOptions: {
52-
treeshake: false,
5351
preserveEntrySignatures: 'strict',
5452
external: [
5553
...Object.keys(packageFile.dependencies || {}),
@@ -64,7 +62,7 @@ export default defineConfig(env => {
6462
entryFileNames: '[name].js'
6563
}
6664
],
67-
plugins: [mode === 'production' ? minifyHTML() : false]
65+
plugins: [prod ? minifyHTML() : false]
6866
}
6967
}
7068
};

0 commit comments

Comments
 (0)