fix(vscode): bundle syntax worker imports

This commit is contained in:
Bohdan Triapitsyn
2026-08-24 16:58:45 +03:00
parent c82f188fc8
commit 7bd27d44d6
3 changed files with 20 additions and 0 deletions
+2
View File
@@ -44,6 +44,8 @@ Keep `bridge.ts` as a thin orchestration layer that delegates message handling t
The webview CSP permits `blob:` only for `worker-src` so shared UI parsers can run bounded local decompression off the main thread. Blob scripts remain disallowed by `script-src`.
The webview build emits each worker as one self-contained file. VS Code webviews cannot load module imports from inside a worker, so allowing worker URLs in the CSP is not enough when Rollup splits Shiki grammars into separate chunks.
- `bridge-localfs-proxy-runtime.ts`
- Local `/api/fs/read` and `/api/fs/raw` proxy helpers and shared proxy utility helpers.
- Workspace-contained Markdown gallery images use these local filesystem
+11
View File
@@ -0,0 +1,11 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, test } from 'node:test';
const source = readFileSync(new URL('../vite.config.ts', import.meta.url), 'utf8');
describe('VS Code webview worker build', () => {
test('bundles worker imports into one file', () => {
assert.match(source, /worker:\s*\{[\s\S]*?inlineDynamicImports:\s*true/);
});
});
+7
View File
@@ -25,6 +25,13 @@ export default defineConfig(({ mode }) => ({
},
worker: {
format: 'es',
// VS Code webviews cannot load module imports from inside a web worker.
// Keep the Shiki worker self-contained instead of emitting grammar chunks.
rollupOptions: {
output: {
inlineDynamicImports: true,
},
},
},
define: {
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),