safaehar opened a new pull request, #75986: URL: https://github.com/apache/airflow/pull/75986
## Why - `useGraphLayout` imports ELK from the `elkjs` package entry. Its `lib/main.js` requires `elk-worker.min.js` as a fallback worker. - The hook also imports the same worker as a `?raw` string for its same-origin blob Worker. - So the layout engine is bundled twice, and it loads with every page that imports the graph components, not only the graph view. ## How - Import only `elkjs/lib/elk-api.js`, since the hook already supplies its own worker. This is the same change as #75864. - Load the worker source with a dynamic `import()` the first time a graph is laid out, so pages that never show a graph don't download it. - A failed load is not cached, so the next layout retries. - The same-origin blob worker from #65031 is unchanged. Related: #75864 (removes the duplicate copy; this PR also defers the remaining one). ## Results Measured on a 3.3.2 build that also has the lazy routes from #74663 (gzip, JavaScript a page needs beyond the entry chunks): | Page | Before | After | |---|---|---| | Dag | 1,205 KB | 315 KB | | Dag run | ~1,220 KB | 330 KB | | Task instance | 1,223 KB | 334 KB | The worker becomes a separate ~459 KB gzip chunk, loaded once when a graph is drawn. Numbers on `main` to be added before this leaves draft. ## Testing - `vitest` Graph tests, `tsc`, ESLint and Prettier pass. - To do before review: Graph view in the browser (Dag, Dag run, task group), and before/after sizes on `main`. --- ##### Was generative AI tooling used to co-author this PR? _To be completed by the author before marking ready for review._ - [ ] Yes (please specify the tool below) --- -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
