Skip to content

Migrate extension webviews to Svelte 5#815

Open
nobody5050 wants to merge 9 commits intowpilibsuite:2027from
nobody5050:feat/convert-to-svelte
Open

Migrate extension webviews to Svelte 5#815
nobody5050 wants to merge 9 commits intowpilibsuite:2027from
nobody5050:feat/convert-to-svelte

Conversation

@nobody5050
Copy link

@nobody5050 nobody5050 commented Nov 9, 2025

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:

  • Dependency View
  • Project Creator
  • Project Importer
  • Help
  • Riolog

- Help
- Project Creator
- Project Importer
- Dependency View
@github-actions github-actions bot added the 2027 label Nov 9, 2025
@nobody5050 nobody5050 changed the title Convert webviews to Svelte Migrate extension webviews to Svelte 5 Dec 29, 2025
@Gold856
Copy link
Member

Gold856 commented Feb 19, 2026

Per https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension:

For security reasons, you must keep the VS Code API object private and make sure it is never leaked into the global scope.

Copy link
Member

@Gold856 Gold856 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only used in RioLogEntry? Define it there instead.

{/if}
</div>
</div>
{:else}
Copy link
Member

@Gold856 Gold856 Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a seriously impressive amount of indentation (8 indents!) There has to be a way to simplify that...

const svelte = require('rollup-plugin-svelte');
const svelteConfig = require('./svelte.config');

const production = process.env.NODE_ENV === 'production';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels overkill to migrate. It's much leaner this way, and it's self contained.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to push back on this one. I'd rather have all webviews be done with svelte than a mix, especially if we ever want to expand the help page in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but I’m still not a fan of shipping 200 kB of JavaScript just for that page.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because svelte doesn't use a virtual DOM and instead compiles, the actual cost of shipping this should be negligible compared to the old way. See: https://svelte.dev/blog/virtual-dom-is-pure-overhead

"sourceMap": true,
"rootDir": "src",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this enabled for?

Comment on lines +245 to +253
$effect(() => {
projectFolderError = validateProjectFolder(projectFolder);
});
$effect(() => {
projectNameError = validateProjectName(projectName);
});
$effect(() => {
teamNumberError = validateTeamNumber(teamNumber);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be derived state?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this replace localeloader.ts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why function here compared to arrow functions everywhere else?

Comment on lines +39 to +41
name: 'localeloader',
input: 'src/webviews/localeloader.ts',
title: 'Locale Loader',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a library, not a webview.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but I’m still not a fan of shipping 200 kB of JavaScript just for that page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants