Skip to content

rafactor: Migrate karma config files to ts and fix types in browser-test-runner#3266

Merged
mondoreale merged 2 commits into
mainfrom
migrate-karma-configs-to-ts
Dec 8, 2025
Merged

rafactor: Migrate karma config files to ts and fix types in browser-test-runner#3266
mondoreale merged 2 commits into
mainfrom
migrate-karma-configs-to-ts

Conversation

@mondoreale

Copy link
Copy Markdown
Contributor

This pull request migrates Karma and Webpack configuration files from CommonJS/JavaScript to ES Modules/TypeScript across several packages, and improves type safety and maintainability for browser-based tests. It also refactors the createKarmaConfig and createWebpackConfig APIs to use proper Webpack types, updates custom matcher imports, and adjusts package scripts to use the new TypeScript config files.

Changes

Configuration migration and refactoring:

  • Migrated all Karma and Webpack config files in dht, proto-rpc, sdk, and trackerless-network packages from .js/CommonJS to .ts/ES Modules, updating imports and exports accordingly.
  • Refactored createKarmaConfig and createWebpackConfig in browser-test-runner to use proper Webpack types (Configuration, ExternalItem, etc.), improving type safety and merging external dependencies more robustly.

Test setup improvements:

  • Updated custom matcher imports in karma-setup.js files to use ES Module syntax (import instead of require) for consistency and compatibility.

Package script updates:

  • Updated test-browser and related scripts in package.json files to use .ts config files instead of .js, ensuring the new TypeScript-based configs are used for browser tests.

File renaming and cleanup:

  • Removed obsolete .js config files and replaced them with .ts equivalents where appropriate, cleaning up the codebase and reducing duplication.

Webpack configuration enhancements:

  • Added explicit empty alias and fallback fields to resolve in webpack.config.js to support new type definitions and ensure compatibility with the updated config factories.

We can do that even in older node versions. Better than cjs configs, eh?
@github-actions github-actions Bot added network Related to Network Package dht Related to DHT package utils proto-rpc sdk labels Dec 8, 2025
@mondoreale mondoreale requested review from juslesan and teogeb December 8, 2025 14:18
@mondoreale mondoreale marked this pull request as ready for review December 8, 2025 14:18
@mondoreale mondoreale changed the title rafactor: Migrate karma config files to ts rafactor: Migrate karma config files to ts and fix types in browser-test-runner Dec 8, 2025

@teogeb teogeb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good improvement 👍

}
}
},
} as Configuration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we avoid this casting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, by… casting the result of defaultConfig but it makes merging them configs a mess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, that's actually a "no", eh?

@mondoreale mondoreale merged commit 878862a into main Dec 8, 2025
23 checks passed
@mondoreale mondoreale deleted the migrate-karma-configs-to-ts branch December 8, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dht Related to DHT package network Related to Network Package proto-rpc sdk utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants