fix(vscode): bundle syntax worker imports
This commit is contained in:
@@ -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 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`
|
- `bridge-localfs-proxy-runtime.ts`
|
||||||
- Local `/api/fs/read` and `/api/fs/raw` proxy helpers and shared proxy utility helpers.
|
- Local `/api/fs/read` and `/api/fs/raw` proxy helpers and shared proxy utility helpers.
|
||||||
- Workspace-contained Markdown gallery images use these local filesystem
|
- Workspace-contained Markdown gallery images use these local filesystem
|
||||||
|
|||||||
@@ -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/);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -25,6 +25,13 @@ export default defineConfig(({ mode }) => ({
|
|||||||
},
|
},
|
||||||
worker: {
|
worker: {
|
||||||
format: 'es',
|
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: {
|
define: {
|
||||||
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),
|
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),
|
||||||
|
|||||||
Reference in New Issue
Block a user