Skip to content

feat: migrate to ESM and vitest #4461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 17, 2025
Merged

feat: migrate to ESM and vitest #4461

merged 15 commits into from
Mar 17, 2025

Conversation

npalm
Copy link
Member

@npalm npalm commented Mar 7, 2025

Description

This PR migrates the TypeScript testing framework from Jest to Vitest and transitions the codebase from CommonJS (CJS) to ECMAScript Modules (ESM).

Motivation:

  • Moving from Jest to Vitest:
    • Performance: Vitest leverages Vite's build pipeline, resulting in significantly faster test execution, especially in larger projects. This speed improvement enhances developer productivity by providing quicker feedback loops.
    • Vite Integration: For projects already using Vite, Vitest offers seamless integration, reducing configuration overhead and providing a unified development experience.
    • Modern tooling: Vitest is a modern test framework that is actively being developed and provides a better developer experience.
  • Migrating from CJS to ESM:
    • Modern JavaScript: ESM is the official standard for module systems in modern JavaScript, offering better static analysis, tree-shaking, and overall performance.
    • Improved Compatibility: ESM is the future of JavaScript modules and ensures better compatibility with modern tooling and libraries.
    • Simplified Dependency Management: ESM's static imports allow for more efficient dependency management and better optimization by bundlers.

Changes:

  • Replaced Jest with Vitest for unit testing.
  • Updated test files to adhere to Vitest syntax.
  • Updated configuration files to reflect the changes (e.g., package.json, tsconfig.json).

Testing:

  • The changes should not introduce any functional regressions. Thoroughly verify existing test suites using Vitest.
  • It is advisable to clear any local cache, such as node_modules and dist folders, before building the lambda functions yourself.
  • Chages are tested with
    • Default example
    • Multi runner example

Related Issues:

Potential Risks:

  • While the migration aims for seamless transition, there's a possibility of encountering minor compatibility issues during the initial build or test runs. Thorough testing and cache clearing should mitigate these risks.

Additional Notes:

  • This migration modernizes the project's tooling and module system, laying a foundation for future improvements and maintainability.

@npalm npalm requested a review from a team as a code owner March 7, 2025 10:31
@npalm npalm marked this pull request as draft March 7, 2025 10:31
@npalm npalm marked this pull request as ready for review March 8, 2025 22:20
@npalm npalm requested a review from a team as a code owner March 8, 2025 22:20
@npalm npalm changed the title chore(refactor): migrate jest to vitest chore(refactor): migrate to ESM and vitest Mar 13, 2025
@npalm npalm changed the title chore(refactor): migrate to ESM and vitest fix: migrate to ESM and vitest Mar 13, 2025
@npalm npalm changed the title fix: migrate to ESM and vitest fix!: migrate to ESM and vitest Mar 13, 2025
@npalm npalm changed the title fix!: migrate to ESM and vitest fix: migrate to ESM and vitest Mar 14, 2025
@npalm npalm changed the title fix: migrate to ESM and vitest feat: migrate to ESM and vitest Mar 15, 2025
@npalm
Copy link
Member Author

npalm commented Mar 15, 2025

@rjaegers what would you say. The change should not be breaking, but it is a big one. I am consider to mark it as a breaking to make the end user aware of this change. Although tested the risk is bigger than most osther changes. What is your view?

@npalm npalm added enhancement New feature or request javascript Pull requests that update Javascript code labels Mar 17, 2025
rjaegers
rjaegers previously approved these changes Mar 17, 2025
@npalm
Copy link
Member Author

npalm commented Mar 17, 2025

@rjaegers updated, removed useless comments.

@npalm npalm requested a review from rjaegers March 17, 2025 13:03
@npalm npalm merged commit aa62967 into main Mar 17, 2025
5 checks passed
@npalm npalm deleted the npalm/vitest branch March 17, 2025 13:06
npalm pushed a commit that referenced this pull request Mar 18, 2025
🤖 I have created a release *beep* *boop*
---


##
[6.4.0](v6.3.2...v6.4.0)
(2025-03-18)


### Features

* migrate to ESM and vitest
([#4461](#4461))
([aa62967](aa62967))


### Bug Fixes

* **lambda:** bump cron-parser from 4.9.0 to 5.0.4 in /lambdas
([#4455](#4455))
([4b446bf](4b446bf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] - migrate lambdas to vitest form jest ESM support
3 participants