fix(desktop): disable main/preload minification to keep page.evaluate stable
Playwright serializes the function passed to page.evaluate via .toString() and runs it in the browser context. With main-process minify on, esbuild renames inlined helpers (e.g. __name) and closure references to two-letter identifiers like FK/p/ed; their definitions stay at module scope on the Node side, so the browser eval throws ReferenceError. Mac dev builds were unaffected because dev mode doesn't minify; only packaged Windows builds hit this. Main process bundle size is irrelevant (loaded once on startup) so turning minify off is the cheapest correct fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,12 @@ export default defineConfig({
|
|||||||
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
||||||
build: {
|
build: {
|
||||||
sourcemap: 'hidden',
|
sourcemap: 'hidden',
|
||||||
|
// Disable minification for the main process: the bundle is only loaded
|
||||||
|
// once on app startup so size is irrelevant, and minified short names
|
||||||
|
// break Playwright `page.evaluate` because the function is serialized
|
||||||
|
// via `.toString()` and helper identifiers (e.g. `__name` renamed to
|
||||||
|
// `FK`) become undefined in the browser context.
|
||||||
|
minify: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: {
|
input: {
|
||||||
bootstrap: resolve(rootDir, 'src/main/bootstrap.ts'),
|
bootstrap: resolve(rootDir, 'src/main/bootstrap.ts'),
|
||||||
@@ -51,6 +57,7 @@ export default defineConfig({
|
|||||||
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
||||||
build: {
|
build: {
|
||||||
sourcemap: 'hidden',
|
sourcemap: 'hidden',
|
||||||
|
minify: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: {
|
input: {
|
||||||
bridge: resolve(rootDir, 'src/preload/bridge.ts'),
|
bridge: resolve(rootDir, 'src/preload/bridge.ts'),
|
||||||
|
|||||||
Reference in New Issue
Block a user