Skip to content

fix: prefer .js over .ts when loading plugins for npm compatibility#8

Merged
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-plugin-ts-loading
Mar 24, 2026
Merged

fix: prefer .js over .ts when loading plugins for npm compatibility#8
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-plugin-ts-loading

Conversation

@simongdavies
Copy link
Contributor

Node.js refuses to strip types from .ts files under node_modules, causing 'Stripping types is currently unsupported' errors when plugins are loaded via npm install.

  • Add resolvePluginSource() helper that prefers .js over .ts
  • Update plugin import, source loading, hash computation, and source verification to use the helper
  • .js files exist in dist/ builds (compiled at build time)
  • .ts files still used in dev mode (tsx handles them)

Type validation is unaffected — it uses pre-built .d.ts files (plugins/host-modules.d.ts), not runtime plugin source.

Copilot AI review requested due to automatic review settings March 23, 2026 23:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts plugin source resolution to prefer compiled JavaScript over TypeScript to avoid Node.js “Stripping types is currently unsupported” errors when plugins are installed via npm (i.e., under node_modules), while still supporting TypeScript in dev workflows.

Changes:

  • Added a resolvePluginSource() helper in the plugin manager and used it for plugin hashing, source loading, and source verification.
  • Updated plugin source read/error messages to reflect {ts,js} support.
  • Updated the agent’s plugin loader to prefer index.js when present before dynamically importing plugins.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/plugin-system/manager.ts Introduces and applies JS-first plugin source resolution for hashing/load/verify paths.
src/agent/index.ts Updates runtime plugin dynamic import to select index.js when available.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Node.js refuses to strip types from .ts files under node_modules,
causing 'Stripping types is currently unsupported' errors when
plugins are loaded via npm install.

- Add resolvePluginSource() helper that prefers .js over .ts
- Update plugin import, source loading, hash computation, and
  source verification to use the helper
- .js files exist in dist/ builds (compiled at build time)
- .ts files still used in dev mode (tsx handles them)

Type validation is unaffected — it uses pre-built .d.ts files
(plugins/host-modules.d.ts), not runtime plugin source.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@simongdavies simongdavies merged commit 4aa42f2 into hyperlight-dev:main Mar 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants