Skip to content

Commit 6eb7ced

Browse files
feat(Output): Add comprehensive Electron-to-Tauri polyfill layer
Implement a complete set of polyfills enabling VS Code to run in the Tauri browser environment without Electron: - **ProcessPolyfill**: Node.js process object with argv, env, platform, versions, cwd(), hrtime(), cpuUsage(), exit() - **FileSystemPolyfill**: fs module mapping readFile/writeFile/rmdir/etc to Mountain file:invoke commands - **FileProtocolShim**: vscode-file://, vscode-userdata://, vscode-resource:// protocol handlers via fetch interception - **ChildProcessPolyfill**: child_process spawn/exec/fork mapping to Mountain electron: commands - **IPCRendererShim**: Electron ipcRenderer API with VS Code binary IPC protocol loopback for channel.call() - **NativeModulePolyfill**: require('electron') shim providing ipcRenderer, webFrame, app, screen, shell, dialog, clipboard, nativeTheme - **SharedProcessProxy**: Service proxies for extension host, search, debug, storage, update routing to Cocoon/Mountain via Tauri - **TauriMainProcessService**: Drop-in replacement for ElectronIPCMainProcessService, routes getChannel().call() through Tauri invoke to Mountain - **DevLog**: Tag-filtered development logging (vfs, ipc, config, etc.) with short/dedup modes Also fix RestPlugin lazy loading: use if/try/catch instead of ternary to prevent ESM evaluation of the specifier when Compiler != Rest. This is Phase 1-7 of Approach A3 — providing the Node.js/Electron API surface that VS Code's workbench expects, bridged to Tauri backend services.
1 parent 65b9a76 commit 6eb7ced

14 files changed

Lines changed: 6321 additions & 12 deletions

Configuration/ESBuild/Output.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Configuration/ESBuild/Output.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/ESBuild/Output.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
// RestPlugin is loaded lazily only when Compiler=Rest is set.
2-
// Enable via: Compiler=Rest dum prepublishOnly --filter=@codeeditorland/output
3-
const RestPlugin = process.env["Compiler"]?.toLowerCase() === "rest"
4-
? await import("./RestPlugin.js").then((M) => M.createRestPluginIfEnabled())
5-
: null;
2+
// The dynamic import must be inside the conditional body — not a ternary —
3+
// so ESM module evaluation does not resolve the specifier when Compiler != Rest.
4+
let RestPlugin = null;
5+
if (process.env["Compiler"]?.toLowerCase() === "rest") {
6+
try {
7+
const { createRestPluginIfEnabled } = await import("./RestPlugin.js");
8+
RestPlugin = createRestPluginIfEnabled();
9+
}
10+
catch {
11+
console.warn("[Output] RestPlugin.js not found — falling back to esbuild TS loader");
12+
}
13+
}
614
export const Clean = process.env["Clean"] === "true";
715
export const Meta = process.env["Meta"] === "true";
816
export const On = process.env["NODE_ENV"] === "development" ||

Source/ESBuild/Output.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import type { BuildOptions } from "esbuild";
22

33
// RestPlugin is loaded lazily only when Compiler=Rest is set.
4-
// Enable via: Compiler=Rest dum prepublishOnly --filter=@codeeditorland/output
5-
const RestPlugin =
6-
process.env["Compiler"]?.toLowerCase() === "rest"
7-
? await import("./RestPlugin.js").then((M) => M.createRestPluginIfEnabled())
8-
: null;
4+
// The dynamic import must be inside the conditional body — not a ternary —
5+
// so ESM module evaluation does not resolve the specifier when Compiler != Rest.
6+
let RestPlugin: import("esbuild").Plugin | null = null;
7+
if (process.env["Compiler"]?.toLowerCase() === "rest") {
8+
try {
9+
const { createRestPluginIfEnabled } = await import("./RestPlugin.js");
10+
RestPlugin = createRestPluginIfEnabled();
11+
} catch {
12+
console.warn("[Output] RestPlugin.js not found — falling back to esbuild TS loader");
13+
}
14+
}
915

1016
export const Clean = process.env["Clean"] === "true";
1117

0 commit comments

Comments
 (0)