Repository navigation
fix: do not pull esbuild 0.11 into every adapter via @alcalzone/esbuild-register - #751
Conversation
…ld-register @alcalzone/esbuild-register is only used inside the integration test directory, where controllerSetup already installs it. Remove it from the dependencies of @iobroker/testing, so adapters no longer get esbuild@0.11.23 (GHSA-67mh-4wv8-2f99), which Dependabot cannot update. In the generated package.json of the test directory, force esbuild@^0.25.0 for @alcalzone/esbuild-register via a scoped npm override.
|
Does it really make sense to use OVERRIDES here. Overrides most like cause problems. I would suggest to contact @AlCalzone to adapt it's dependencies instead of using overrides |
|
@mcm1957 Hi Martin yes, of course this would make sence. @AlCalzone didn't change anything in his Repo since >5 years - so this could be an easier way. |
|
@AlCalzone did SEVERAL updates for the releasescript within the last months. So he will for sure update this repo too if required. :-) I'll ping him ... |
|
@mcm1957 @AlCalzone I opened AlCalzone/esbuild-register#1: it widens the esbuild range to |
There was a problem hiding this comment.
@alcalzone/esbuild-register is no longer state of the art. Today, tsx is the better alternative. It also runs TypeScript files inside node_modules and depends on a current esbuild, so the override isn't needed.
Besides the suggestions below, the adapter needs to be started with tsx in src/tests/integration/lib/harness.ts:
const args = isTypeScript
? ['--import', 'tsx', mainFileRelative, '--console']
: [mainFileRelative, '--console'];If other repos need modification, I recommend switching them to tsx similarly.
| [`${this.appName}.js-controller`]: controllerVersion, | ||
| // @alcalzone/esbuild-register is needed to run TypeScript adapters | ||
| '@alcalzone/esbuild-register': '^2.5.1-1', | ||
| }, | ||
| // @alcalzone/esbuild-register@2.5.1-1 (the latest version) depends on esbuild@^0.11.5, | ||
| // which is affected by GHSA-67mh-4wv8-2f99. Force a fixed esbuild version, but only | ||
| // for esbuild-register, so an esbuild dependency of the adapter itself is not touched | ||
| overrides: { | ||
| '@alcalzone/esbuild-register': { | ||
| esbuild: '^0.25.0', | ||
| }, | ||
| }, | ||
| // npm >= 12 blocks dependency install scripts by default: | ||
| // - js-controller needs its install script ("setup first") to create the database | ||
| // - esbuild (used by @alcalzone/esbuild-register) downloads its binary |
There was a problem hiding this comment.
| [`${this.appName}.js-controller`]: controllerVersion, | |
| // @alcalzone/esbuild-register is needed to run TypeScript adapters | |
| '@alcalzone/esbuild-register': '^2.5.1-1', | |
| }, | |
| // @alcalzone/esbuild-register@2.5.1-1 (the latest version) depends on esbuild@^0.11.5, | |
| // which is affected by GHSA-67mh-4wv8-2f99. Force a fixed esbuild version, but only | |
| // for esbuild-register, so an esbuild dependency of the adapter itself is not touched | |
| overrides: { | |
| '@alcalzone/esbuild-register': { | |
| esbuild: '^0.25.0', | |
| }, | |
| }, | |
| // npm >= 12 blocks dependency install scripts by default: | |
| // - js-controller needs its install script ("setup first") to create the database | |
| // - esbuild (used by @alcalzone/esbuild-register) downloads its binary | |
| // tsx is needed to run TypeScript adapters | |
| tsx: '^4.20.0', | |
| }, | |
| // npm >= 12 blocks dependency install scripts by default: | |
| // - js-controller needs its install script ("setup first") to create the database | |
| // - esbuild (used by tsx) downloads its binary |
| it('installs the requested JS-Controller version and esbuild-register', () => { | ||
| const packageJson = new ControllerSetup(adapterDir, testDir).createTestDirPackageJson('7.2.2'); | ||
| expect(packageJson.dependencies).to.deep.equal({ | ||
| 'iobroker.js-controller': '7.2.2', | ||
| '@alcalzone/esbuild-register': '^2.5.1-1', | ||
| }); | ||
| }); | ||
|
|
||
| it('forces a fixed esbuild version (GHSA-67mh-4wv8-2f99) for esbuild-register only', () => { | ||
| const packageJson = new ControllerSetup(adapterDir, testDir).createTestDirPackageJson('dev'); | ||
| expect(packageJson.overrides).to.deep.equal({ | ||
| '@alcalzone/esbuild-register': { | ||
| esbuild: '^0.25.0', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
There was a problem hiding this comment.
| it('installs the requested JS-Controller version and esbuild-register', () => { | |
| const packageJson = new ControllerSetup(adapterDir, testDir).createTestDirPackageJson('7.2.2'); | |
| expect(packageJson.dependencies).to.deep.equal({ | |
| 'iobroker.js-controller': '7.2.2', | |
| '@alcalzone/esbuild-register': '^2.5.1-1', | |
| }); | |
| }); | |
| it('forces a fixed esbuild version (GHSA-67mh-4wv8-2f99) for esbuild-register only', () => { | |
| const packageJson = new ControllerSetup(adapterDir, testDir).createTestDirPackageJson('dev'); | |
| expect(packageJson.overrides).to.deep.equal({ | |
| '@alcalzone/esbuild-register': { | |
| esbuild: '^0.25.0', | |
| }, | |
| }); | |
| }); | |
| it('installs the requested JS-Controller version and tsx', () => { | |
| const packageJson = new ControllerSetup(adapterDir, testDir).createTestDirPackageJson('7.2.2'); | |
| expect(packageJson.dependencies).to.deep.equal({ | |
| 'iobroker.js-controller': '7.2.2', | |
| tsx: '^4.20.0', | |
| }); | |
| }); | |
…d-register As suggested in the review of ioBroker#751: tsx is the current state of the art, also runs TypeScript files inside node_modules and depends on a current esbuild, so no npm override is needed in the test directory anymore.
|
Thanks @AlCalzone, that's much cleaner! I switched the PR to tsx as suggested (e66a457): the test dir now gets One observation: the generated test dir still contains |
|
Please say me, when should I look at it. |
|
@GermanBluefox my adapters have been tested against the PR. Currently GitHub would need another trigger from your side to finish the tests (last macos is missing caused by the known GitHub issues last days) If I could assist in testing - tell me what adapter(s) should be tested against this PR - I could fork them and let the BOT do all these tests. |
There was a problem hiding this comment.
🟡 Changes recommended
The tests do not exercise startAdapter(), leaving the new TypeScript loader arguments, adapter working directory, and unchanged JavaScript startup behavior without regression coverage.
1 open issue
What changed in this PR
This PR addresses #750 by removing the dependency that brings legacy esbuild into consuming adapters and switching TypeScript integration-test startup to tsx.
Changes:
- Remove
@alcalzone/esbuild-registerand its dependencies from the library’s dependency tree. - Install
tsxin the integration test directory and launch TypeScript adapters withnode --import tsx. - Add generated-package tests and update compiled output, documentation, and the changelog.
| File | Description |
|---|---|
| src/tests/integration/lib/harness.ts | Switch TypeScript startup to tsx. |
| src/tests/integration/lib/controllerSetup.ts | Extract package generation and install tsx. |
| src/tests/integration/lib/controllerSetup.test.ts | Test dependencies, absent overrides, and script permissions. |
| package.json | Remove the legacy loader dependency. |
| package-lock.json | Remove the loader and its dependency entries. |
| CLAUDE.md | Document the updated startup command. |
| CHANGELOG.md | Describe the dependency and loader changes. |
| build/tests/integration/lib/harness.js | Update the compiled launcher. |
| build/tests/integration/lib/controllerSetup.js | Update compiled test-directory setup. |
| build/tests/integration/lib/controllerSetup.d.ts | Declare the package-generation method. |
Review effort: Balanced
| const command = isWindows ? 'node.exe' : 'node'; | ||
| const args = isTypeScript | ||
| ? ['-r', '@alcalzone/esbuild-register', mainFileRelative, '--console'] | ||
| ? ['--import', 'tsx', mainFileRelative, '--console'] |
|
Thanks for the review — added in d927412. Our earlier practical tests already covered real adapter startup, including a TypeScript adapter running through tsx. The new unit tests now explicitly verify the loader arguments, relative entry point and installed adapter working directory, plus unchanged JavaScript startup. I repeated the checks with the freshly built PR package on Node 22.23.4 and 24.22.2. All passed on both versions:
npm 12/allowScripts was not covered. |
|
@GermanBluefox I also tested two more adapters against the freshly built PR package (
Build, type checking and lint also pass for both adapters. These integration tests verify startup without real configuration, not live operation. Both adapters use compiled JavaScript; the separate TypeScript smoke test covers actual tsx startup. Could you please re-run the checks for the updated PR? |

Fixes #750
Changes
@alcalzone/esbuild-registerfromdependencies(and its entries@alcalzone/esbuild-register,esbuild@0.11.23andjsonc-parserfrompackage-lock.json).@iobroker/testingnever imports it. It is only needed in the integration test directory, wherecontrollerSetup.tsalready installs it.controllerSetup.ts: moved the generated test directorypackage.jsoninto a new methodcreateTestDirPackageJson()and added a scoped npm override:"esbuild"override) leaves an esbuild dependency of the adapter under test alone.allowScriptsstays the same.package.json(dependencies, overrides, allowScripts).build/and added a CHANGELOG entry under**WORK IN PROGRESS**(no version bump).Testing
npm run build,npm run lintandnpm testpass (66 tests, 3 of them new).package.jsoninstalled in an empty directory (npm 11 and npm 12):npm ls esbuildshows only@alcalzone/esbuild-register@2.5.1-1 → esbuild@0.25.12.node -r @alcalzone/esbuild-register some.tsworks (enum, private field, source-mapped stack trace).package.jsonand runningnpm i --omit=dev(with the lockfile deleted, asprepareTestDir()does), esbuild is updated to 0.25.12.esbuild@0.24.2: with the scoped override, the adapter keeps 0.24.2 and esbuild-register gets 0.25.12. A top-level override would have changed both.npm auditreports no esbuild finding, andtest:tsandtest:packagepass. The integration test creates the test directory with the override (esbuild@0.25.12). It then fails at adding the adapter instance only becausehttp://download.iobroker.net/sources-dist.jsoncurrently returns HTTP 500. That failure is unrelated to this change.Note
Adapters that use
@alcalzone/esbuild-registerin their own scripts (for example in.mocharc) and relied on getting it through@iobroker/testingneed to add it to their own devDependencies. The adapters I checked (ioBroker.history, ioBroker.wattcycle) already list it directly.Current state (tsx)
Changes
@alcalzone/esbuild-registerfromdependencies(and its entries@alcalzone/esbuild-register,esbuild@0.11.23andjsonc-parserfrompackage-lock.json).@iobroker/testingnever imports it.node --import tsx) instead ofnode -r @alcalzone/esbuild-register, as suggested by @AlCalzone. tsx also runs TypeScript files insidenode_modulesand depends on a current esbuild, so no override is needed.controllerSetup.ts: moved the generated test directorypackage.jsoninto a new methodcreateTestDirPackageJson(). It installstsx: '^4.20.0'next to js-controller.allowScriptsstays the same (esbuild is now used by tsx).package.json(dependencies, no overrides, allowScripts).build/and added a CHANGELOG entry under**WORK IN PROGRESS**(no version bump).Testing
npm run build,npm run lintandnpm testpass (66 tests).main: src/main.ts, installed into the test dir'snode_modules) on Node 22.23 against js-controller dev: the adapter starts with--import tsxand the integration tests pass.npm ls esbuildin the generated test dir:tsx → esbuild@0.28.2.esbuild@0.11.23is still present via js-controller's own dependency on@alcalzone/esbuild-register; adapters' own dependency trees no longer contain it.