|
9 | 9 | * CSS extraction with hashed filenames, the lot. |
10 | 10 | * |
11 | 11 | * Import target: |
12 | | - * `@codeeditorland/output/vs/code/electron-browser/workbench/workbench` |
| 12 | + * `@codeeditorland/output/Target/Microsoft/VSCode/vs/code/ |
| 13 | + * electron-browser/workbench/workbench.js` |
13 | 14 | * |
14 | | - * The Output package's `exports` map (`"./*"` -> |
15 | | - * `./Target/Microsoft/VSCode/*.js`) resolves this through |
16 | | - * `node_modules/@codeeditorland/output/Target/...`. Output's own |
17 | | - * prepublishOnly populates that tree before Sky's Vite step runs, so |
| 15 | + * No package-exports-map indirection: the path is the on-disk path |
| 16 | + * inside the Output package. The same shape works locally |
| 17 | + * (`../../../../../Output/Target/Microsoft/VSCode/vs/.../workbench.js`) |
| 18 | + * once the monorepo waterfall populates Output's Target. Output's |
| 19 | + * prepublishOnly runs before Sky's Vite step (Turbo task graph), so |
18 | 20 | * Rollup sees real files when it walks the module graph. |
19 | 21 | * |
20 | | - * Using the package specifier (not a relative path into Dependency/) |
21 | | - * means the existing `Static/Application/` pipeline is untouched - |
22 | | - * Sky's `astro:build:done` still copies + transforms the same files |
23 | | - * for the non-bundled boot path. |
24 | | - * |
25 | 22 | * Globals required by VS Code before workbench.js loads: |
26 | 23 | * - `_VSCODE_FILE_ROOT` - origin/path the desktop loader dereferences |
27 | 24 | * - `_VSCODE_PRODUCT_JSON` - product metadata (defaulted empty) |
|
33 | 30 | * non-bundled comparison. |
34 | 31 | */ |
35 | 32 |
|
36 | | -if (typeof (globalThis as never as { __name?: unknown }).__name !== "function") { |
37 | | - (globalThis as never as { __name: unknown }).__name = ( |
38 | | - Target: object, |
39 | | - Value: string, |
40 | | - ) => { |
41 | | - Object.defineProperty(Target, "name", { |
42 | | - value: Value, |
43 | | - configurable: true, |
44 | | - }); |
45 | | - return Target; |
46 | | - }; |
47 | | -} |
48 | | - |
| 33 | +// `__name` shim, WKWebView polyfills (requestIdleCallback, cancelIdle |
| 34 | +// Callback, queryLocalFonts), and Blob worker URL rewrite are now |
| 35 | +// injected directly into VS Code's `vs/code/electron-browser/workbench |
| 36 | +// /workbench.js` by Output's `InjectWebViewPolyfills` transform plugin |
| 37 | +// (runs at Output's prepublishOnly tail). Both Sky paths consume the |
| 38 | +// same pre-shimmed file, so this Entry only needs to set the VS Code |
| 39 | +// loader globals before kicking off the workbench import. |
| 40 | +// |
| 41 | +// `_VSCODE_FILE_ROOT` is the base URL the workbench bootstrap uses to |
| 42 | +// resolve runtime `await import(computedURL)` chains - e.g. |
| 43 | +// `vs/workbench/workbench.desktop.main.js`. Vite/Rollup cannot follow |
| 44 | +// computed-string dynamic imports, so those land at runtime regardless |
| 45 | +// of the bundled chunk. Pin to `/Static/Application/` (Sky's existing |
| 46 | +// pipeline still produces this tree even in bundled profiles) so |
| 47 | +// runtime resolutions hit real files instead of `_astro/vs/...` 404s. |
49 | 48 | (globalThis as never as { _VSCODE_FILE_ROOT?: string })._VSCODE_FILE_ROOT ??= |
50 | | - new URL("./", import.meta.url).href; |
| 49 | + `${window.location.origin}/Static/Application/`; |
51 | 50 |
|
52 | 51 | (globalThis as never as { _VSCODE_PRODUCT_JSON?: object })._VSCODE_PRODUCT_JSON ??= |
53 | 52 | {}; |
54 | 53 |
|
55 | 54 | performance.mark("land:bundled:electron:start"); |
56 | 55 |
|
| 56 | +// Pre-import the workbench's desktop entry shim with a LITERAL string so |
| 57 | +// Vite/Rollup follows desktop.main.js's static import graph (~1500 |
| 58 | +// modules: contrib/*, services/*, platform/*, base/*, editor/*) and |
| 59 | +// pulls them into the bundled chunk. Without this, only workbench.js |
| 60 | +// + its small synchronous graph land in the bundle (~26 MB), and the |
| 61 | +// workbench loader's runtime `await import(computedURL)` resolves |
| 62 | +// against `/Static/Application/` - re-fetching ~1500 separate files |
| 63 | +// from disk every cold boot. |
| 64 | +// |
| 65 | +// The browser's module cache deduplicates: when workbench.js later |
| 66 | +// runs `await import("vs/workbench/workbench.desktop.main.js")` the |
| 67 | +// resolved URL hits the same cache entry as the static import here, |
| 68 | +// so order-of-execution is preserved (desktop.main.js side-effects |
| 69 | +// happen first, registering DI services; workbench.js then runs |
| 70 | +// `result.main(configuration)` against the registered surface). |
| 71 | +// |
| 72 | +// `workbench.web.main.internal.js` is statically imported by |
| 73 | +// `workbench.web.main.js`, which `workbench.desktop.main.js` shares |
| 74 | +// many modules with - Rollup chunk-deduplicates so we're not paying |
| 75 | +// the import twice. |
| 76 | +await import( |
| 77 | + "@codeeditorland/output/Target/Microsoft/VSCode/vs/workbench/workbench.desktop.main.js" |
| 78 | +); |
| 79 | + |
57 | 80 | await import( |
58 | | - "@codeeditorland/output/vs/code/electron-browser/workbench/workbench" |
| 81 | + "@codeeditorland/output/Target/Microsoft/VSCode/vs/code/electron-browser/workbench/workbench.js" |
59 | 82 | ); |
60 | 83 |
|
61 | 84 | performance.mark("land:bundled:electron:imported"); |
|
0 commit comments