From 2a26c784c39003c8fef4bae2981e1d6b21897f08 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Tue, 13 Oct 2026 05:30:48 +0000 Subject: [PATCH 1/2] Take the style library without lodash (#356) ngx-reactome-cytoscape-style no longer imports lodash (reactome/ngx-reactome-base#15): its four uses are native code or small local memoize/throttle held to lodash's behaviour by spec. The lockfile moves the library to that build (76de66a, built from dc16af7) by its entry alone -- `npm update` also rewrote unrelated entries, so it was edited and checked with `npm ci` instead. ehld.service's one isArray is Array.isArray. With the router change (#432), which takes the state service's lodash imports, nothing the embed loads imports lodash. Co-Authored-By: Claude Opus 5.5 --- package-lock.json | 5 ++--- projects/pathway-browser/src/app/services/ehld.service.ts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index eb9de653..cb990429 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22633,15 +22633,14 @@ }, "node_modules/ngx-reactome-cytoscape-style": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/reactome/ngx-reactome-base.git#f138ccaa8bfa8b14c21aea0b33109c219ffee04a", + "resolved": "git+ssh://git@github.com/reactome/ngx-reactome-base.git#76de66a0bee7bb6f41506c69b47f2db8e7c3cef1", "dependencies": { "tslib": "^2.3.0" }, "peerDependencies": { "chroma-js": "^3.1.2", "cytoscape": "^3.30.0", - "cytoscape-layers": "^3.0.0", - "lodash": "^4.17.21" + "cytoscape-layers": "^3.0.0" } }, "node_modules/ngx-reactome-style": { diff --git a/projects/pathway-browser/src/app/services/ehld.service.ts b/projects/pathway-browser/src/app/services/ehld.service.ts index 2e856dc2..692658f1 100644 --- a/projects/pathway-browser/src/app/services/ehld.service.ts +++ b/projects/pathway-browser/src/app/services/ehld.service.ts @@ -2,7 +2,6 @@ import { computed, ElementRef, Injectable, InjectionToken, inject } from '@angul import { Observable, switchMap } from 'rxjs'; import { HttpClient } from '@angular/common/http'; import type { Analysis } from '../model/analysis.model'; -import { isArray } from 'lodash'; import { AnalysisService } from './analysis.service'; import { DataStateService } from './data-state.service'; import { UrlStateService } from './url-state.service'; @@ -337,7 +336,7 @@ export class EhldService { const palette = type === 'fdr' ? this.analysis.fdrPalette() : this.analysis.palette(); values.forEach((exp, _i) => { const last = stops.at(-1); - const realExp = isArray(exp) ? exp[0] : exp; + const realExp = Array.isArray(exp) ? exp[0] : exp; if (last && last.exp === realExp) { last.stop += delta; last.width += delta; From ff9d17dc1f75047c2717a67849ce68a098adbd27 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Tue, 13 Oct 2026 06:23:36 +0000 Subject: [PATCH 2/2] The style library needs no vitest inlining now; say what the interop spec guards It was inlined for its CommonJS lodash import, which is gone. All 84 spec files pass without the option; the interop spec still imports the library directly, so a build that brings back a CommonJS-only import fails there. Co-Authored-By: Claude Opus 5.5 --- .../diagram/cytoscape-style-interop.spec.ts | 24 +++++++------------ vitest.config.ts | 18 -------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/projects/pathway-browser/src/app/diagram/cytoscape-style-interop.spec.ts b/projects/pathway-browser/src/app/diagram/cytoscape-style-interop.spec.ts index 317046dc..b7e7dceb 100644 --- a/projects/pathway-browser/src/app/diagram/cytoscape-style-interop.spec.ts +++ b/projects/pathway-browser/src/app/diagram/cytoscape-style-interop.spec.ts @@ -1,27 +1,19 @@ /** * `ngx-reactome-cytoscape-style` can be imported under vitest. * - * Its published ESM does `import { isArray } from 'lodash'`, and lodash is - * CommonJS only. Vite's interop rejects that named import -- "Named export - * 'isArray' not found" -- before any test using the library can run. - * `server.deps.inline` in vitest.config.ts makes vite transform the library and - * resolve the interop, which is why that option is there. - * - * Nothing exercised it. Every module importing this library is a component, and - * the same config file explains that components are covered by e2e rather than - * unit tests -- so the option was load-bearing and untested, and a vitest or vite - * upgrade could have silently stopped honouring it. Found while moving to - * vitest 4 (#234), where it would have been exactly the kind of breakage a - * "244 passed" run does not mention. - * - * The import is the test. The assertions are here so it fails as a statement - * about the library rather than as a bare module error. + * It used to import lodash, which is CommonJS only, and vite's interop rejected + * the named import ("Named export 'isArray' not found") until vitest.config.ts + * inlined the library. The library no longer imports lodash + * (reactome/ngx-reactome-base#15), so that option is gone. This keeps the import + * under test, so a library build that brings back a CommonJS-only import fails + * here, as a statement about the library, rather than in whichever spec happens + * to pull it in first. */ import { describe, expect, it } from 'vitest'; import { ReactomeEventTypes, Style } from 'ngx-reactome-cytoscape-style'; describe('the cytoscape style library under vitest', () => { - it('imports, despite its lodash interop', () => { + it('imports under vitest as it is installed', () => { expect(typeof Style, 'Style should be the class the diagram builds on').toBe('function'); }); diff --git a/vitest.config.ts b/vitest.config.ts index 9ad71982..2505be48 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -24,23 +24,5 @@ export default defineConfig({ // sat in the repo without being run by anything at all. include: ['{src,projects,tools}/**/*.spec.{ts,mjs}'], css: false, - // ngx-reactome-cytoscape-style's ESM does `import { isArray } from - // 'lodash'`, and lodash is CommonJS only, so vite's interop rejects the named - // import ("Named export 'isArray' not found") before any test touching the - // library can run. Inlining it makes vite transform the library and resolve - // the interop. - // - // The library is installed built, from ngx-reactome-base, so a local run and - // CI resolve the same copy. (When it was built here, a machine with dist/ - // passed without this option and CI failed on four spec files.) - // - // diagram/cytoscape-style-interop.spec.ts imports the library directly, so - // this is covered by a test rather than only by whichever spec happens to - // pull the library in first. - server: { - deps: { - inline: [/reactome-cytoscape-style/], - }, - }, }, });