Skip to content

Conversation

@ericzundel
Copy link
Contributor

Resolves #60

This change adds a webworker to add LSP support to perform linting for the code editors.

// tab
import TabTemplate from "../utilComponents/TabTemplate";

let aceLinterWorker = new Worker(new URL('/ace-linter-worker.js', import.meta.url), { type: 'module' })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am concerned that this won't work when deployed. I had so much trouble with getting this path right in my development - only using the absolute path worked for me. If I tried anything else, vite served up index.html in its place which was very confusing. This bothers me because:

  • I solved a problem in serviceWorkerRegistration.js by REMOVING the absolute path.
  • With this code, I'm getting this error from the NPM console:
Instead of /public/ace-linter-worker.js?worker_file&type=module, use /ace-linter-worker.js?worker_file&type=module.

@@ -1,4 +1,4 @@
const CACHE_NAME = "CircuitPython-Online-IDE-cache";
const CACHE_NAME = "CircuitPython-Online-IDE-cache.v20250714.001";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had so many issues with caching, that I was concerned that new users of the IDE might start to see lots of issues if they had used the IDE before. That may be why I found a number of missing resources when I ran it that you might not have seen in your development environment. See #121

@ericzundel
Copy link
Contributor Author

I deployed this to my local server and found a problem with npm build that I fixed in the above commit. As I'm running this, I'm also finding that the linting code may not be perfect. It seems to crash in different ways. Here's one console log. I think we need to put this behind a setting and leave it off by default until we get more familiar with it.

image

@ericzundel
Copy link
Contributor Author

ericzundel commented Jul 16, 2025

In another PR/issue we were discussing what gets output when you build the app and cache it. Here's what this change adds:

$ ls -l docs
total 19444
-rw-rw-r-- 1 zundel zundel    12081 Jul 16 13:13 ace-linter-worker-grSrny8J.js
-rw-rw-r-- 1 zundel zundel      563 Jul 16 13:13 ace-linter-worker.js
-rw-rw-r-- 1 zundel zundel    22016 Jul 16 13:13 blinka-192.png
-rw-rw-r-- 1 zundel zundel    63915 Jul 16 13:13 blinka-512.png
-rw-rw-r-- 1 zundel zundel   279517 Jul 16 13:13 blinka.svg
-rw-rw-r-- 1 zundel zundel      116 Jul 16 13:13 _commonjsHelpers-CqkleIqs.js
-rw-rw-r-- 1 zundel zundel  7054583 Jul 16 13:13 index.html
-rw-rw-r-- 1 zundel zundel   307647 Jul 16 13:13 json-service-CnN8TVyx.js
-rw-rw-r-- 1 zundel zundel      724 Jul 16 13:13 manifest-BW_f1orH.json
-rw-rw-r-- 1 zundel zundel 12139285 Jul 16 13:13 python-service-C5HrWFNf.js
-rw-rw-r-- 1 zundel zundel     1683 Jul 16 13:13 service-worker.js

Notably, the app now spans multiple javascript files. There is a 12 MB download for the python service. It is mostly WASM encoded in javascript, so hugely bloated.

Google Workbox allows you to pass it a glob for specifing files to cache in one of their npm plugins that generates the service-worker.

@ericzundel ericzundel force-pushed the zundel/ace-python-ruff-linter branch from ac8f5ce to 73e456d Compare July 17, 2025 10:45
- In IdeEditor we create a web worker and tell the ACE editor
  to use that worker for language support
- The ace-linter-worker.js loads up JSON and Python language lint
  support
- I also changed the name of the cache to clear out outdated versions.
  I was having tons of issues with stale caching and was concerned
  that might persist past a deploy.
Vite needed some extra config to avoid an error when building the site.
It was complaining as follows:

Invalid value "iife" for option "worker.format" - UMD and IIFE output formats are not supported for code-splitting builds.

Changing the config to generate in 'es' format seems to fix it.
Since I've seen some exceptions from the linter, I thought it
might be nice to deploy with the linter off to see how things are
going.
@ericzundel ericzundel force-pushed the zundel/ace-python-ruff-linter branch from 73e456d to 93b27ee Compare July 26, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor: Auto black python format

1 participant