Migrate extension webviews to Svelte 5#815
Migrate extension webviews to Svelte 5#815nobody5050 wants to merge 25 commits intowpilibsuite:2027from
Conversation
- Help - Project Creator - Project Importer - Dependency View
|
There was a problem hiding this comment.
I may or may not review this more closely later, but just some broad details I'm noticing (and some of the recommendations may be wrong since I completed the Basic Svelte tutorial like 30 minutes ago):
- Almost all props seem to be optional, but that doesn't actually seem to be the case in practice; they're either defaulted in the child component or initialized with a value in the parent. In fact, several type definitions have their optional declaration erased because of that. How many props can we change to not be optional?
- Speaking of props, we're passing an insane number of props to several child components. Can some of this be replaced with global state in .svelte.ts files? Global state is kinda icky, but these webviews are small, so globals aren't used in very far away places.
- Let's try to completely dump Webpack in this PR. I'm not interested in dealing with multiple build systems.
- Can we make the config files use ES modules?
- There's a lot of functions without JSDoc. Try to add some API docs to newly added shared functions/components.
- Can we reduce the main.ts boilerplate by inlining as much as possible?
| {/if} | ||
| </div> | ||
| </div> | ||
| {:else} |
There was a problem hiding this comment.
That is a seriously impressive amount of indentation (8 indents!) There has to be a way to simplify that...
There was a problem hiding this comment.
The alternative as best I can tell would need to make use of $derived spam and would be truly unreadable. At least this is readable. Open to suggestions for other ways to solve it.
| type DistHtmlOptions = { | ||
| webview: vscode.Webview; | ||
| extensionRoot: vscode.Uri; | ||
| distHtmlFileName: string; | ||
| extraCss?: vscode.Uri[]; | ||
| appAttributes?: Record<string, string>; | ||
| }; | ||
|
|
||
| type RewriteHtmlOptions = { | ||
| webview: vscode.Webview; | ||
| extensionRoot: vscode.Uri; | ||
| html: string; | ||
| extraCss?: vscode.Uri[]; | ||
| appAttributes?: Record<string, string>; | ||
| }; |
There was a problem hiding this comment.
Unify these and make the non-common fields a separate parameter at the call site.
| } from './types'; | ||
|
|
||
| const vscode = acquireVsCodeApi(); | ||
| const t = createTranslator('projectcreator'); |
There was a problem hiding this comment.
Ugh. The current translation infrastructure is riddled with tech debt. Keeping compat with a future l10n transition would mean all calls look like l10n.t.
- Add rollup configuration to .vscodeignore - Re-sort package.json - Better checks for workspace in DependencyView - Clean up unused code in various files - Update TypeScript configuration to target ES2021 (allows promise.any)
This PR converts the webviews to a frontend framework, namely Svelte 5. All of the webviews are now built with rollup and share a lot more infrastructure, so i18n and similar should be easier to maintain. They also have the benefit of sharing components so the different wizards are easier to keep in sync.
Closes #55
Status: