Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/desktop/e2e/smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,32 @@ test.describe('app launch (smoke)', () => {
await cleanup();
}
});

// Regression for #311: optimizeDeps only covers the dev server. The
// production rollup/rolldown build used to split @codemirror/@lezer
// across lazy chunks, so HighlightStyle.define() saw `tags` as
// undefined and the packaged editor logged "[CodeMirror] plugin error:
// TypeError: tags is not iterable". This test must load MarkdownEditor
// (lazy from NoteEditor) against the built bundle.
test('opening a note loads CodeMirror without plugin errors', async () => {
const { window, cleanup } = await launchApp();
const consoleErrors: string[] = [];
window.on('console', msg => {
if (msg.type() === 'error') consoleErrors.push(msg.text());
});
window.on('pageerror', err => consoleErrors.push(`pageerror: ${err.message}`));

try {
await window.getByRole('button', { name: 'Create Your First Note' }).click();

const content = window.locator('.cm-content');
await expect(content).toBeVisible({ timeout: 15_000 });
await expect(content).toContainText('Untitled');

const codeMirrorErrors = consoleErrors.filter(line => /\[CodeMirror\]/.test(line));
expect(codeMirrorErrors, codeMirrorErrors.join('\n')).toEqual([]);
} finally {
await cleanup();
}
});
});
79 changes: 0 additions & 79 deletions apps/desktop/electron-vite.config.ts

This file was deleted.

63 changes: 63 additions & 0 deletions apps/desktop/electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { resolve } from 'path';
import { defineConfig } from 'electron-vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
main: {},
preload: {},
renderer: {
plugins: [react()],
// Pre-bundle all CodeMirror packages together to avoid multiple instances of @codemirror/state
// See: https://codemirror.net/docs/guide/#bundling
// optimizeDeps only covers the dev server. Production also has to keep
// @codemirror/* and @lezer/* in one chunk — HighlightStyle.define() in
// editorTheme.ts reads tags at module init, and a split build leaves
// them undefined ("tags is not iterable").
optimizeDeps: {
include: [
'@codemirror/state',
'@codemirror/view',
'@codemirror/autocomplete',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lang-markdown',
'@codemirror/language-data',
'@lezer/highlight',
],
},
build: {
outDir: 'out/renderer',
rollupOptions: {
input: {
index: resolve(__dirname, 'src/renderer/index.html'),
},
output: {
// Function form is the #311 acceptance criterion. Keep
// @codemirror/* and @lezer/* in one chunk so HighlightStyle
// and tags initialize together.
manualChunks(id: string) {
if (id.includes('@codemirror/') || id.includes('@lezer/')) {
return 'codemirror';
}
},
},
},
},
resolve: {
alias: {
'@': resolve(__dirname, 'src/renderer'),
// highlight@1.2.3 nests common@1.5.0; language/markdown nest 1.5.2.
// Two NodeProp identities → HighlightStyle.style(undefined) →
// "tags is not iterable". Pin every import to the desktop copy.
'@lezer/common': resolve(__dirname, 'node_modules/@lezer/common'),
},
dedupe: [
'@codemirror/state',
'@codemirror/view',
'@codemirror/language',
'@lezer/highlight',
'@lezer/common',
],
},
},
});
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@codemirror/language-data": "^6.5.2",
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.43.0",
"@lezer/common": "1.5.2",
"@lezer/highlight": "^1.2.3",
"@sentry/electron": "^7.13.0",
"@tanstack/react-query": "^5.101.0",
Expand Down
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"src/main/index.ts",
"src/preload/index.ts",
"src/renderer/main.tsx",
"electron-vite.config.ts",
"electron.vite.config.ts",
"vitest.config.ts",
"playwright.config.ts",
"e2e/**/*.{ts,spec.ts}"
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@
"*.{json,md}": "prettier --write"
},
"packageManager": "pnpm@9.15.1",
"pnpm": {},
"pnpm": {
"overrides": {
"@lezer/common": "1.5.2"
}
},
"engines": {
"node": ">=20.0.0",
"pnpm": ">=9.0.0"
Expand Down
15 changes: 8 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading