Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

refactor: use project references#2

Merged
ojeytonwilliams merged 4 commits intomainfrom
refactor/use-project-references
Mar 28, 2025
Merged

refactor: use project references#2
ojeytonwilliams merged 4 commits intomainfrom
refactor/use-project-references

Conversation

@ojeytonwilliams
Copy link
Owner

In order to make sure that scripts running in different environments (i.e. worker vs frame) see the correct types, it's necessary to split the code into different projects (i.e. different tsconfig.jsons). To see the kind of weird errors not doing this generates, see https://github.com/ojeytonwilliams/test-runner/actions/runs/14102608999/job/39501924355. Notably tsc had no issue with the lack of overlap, since it was using different type definitions to Jest.

Since it was necessary to split the project up, it made sense to use references, but this came with a set of challenges

To address the first issue I simply removed ts-jest. In retrospect I can't see a reason to use it over Babel. We're type checking with tsc, so there's nothing to be gained by using ts-jest. Also, Babel works.

I've currently hacked a way around the ts-loader problem by providing one config per entrypoint. TypeStrong/ts-loader#647 seems to have some smarter approaches, so I will try using instance and see if that is enough.

Specifying a outDir, means that there's only ever a single TS file for Jest to import, so it is happy.

@ojeytonwilliams ojeytonwilliams requested a review from Copilot March 27, 2025 18:02
Copy link

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

This pull request refactors the project to use TypeScript project references, updating configurations and import paths to ensure consistent type definitions across different environments.

  • Updated webpack configuration to generate separate configs per entry point and enabled project references for ts-loader.
  • Adjusted import paths in workers, frame evaluators, and test runner files to use consolidated type definitions.
  • Removed ts-jest in favor of Babel and updated corresponding Jest and ESLint configurations.

Reviewed Changes

Copilot reviewed 16 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
webpack.config.cjs Refactored webpack config to support multiple entry points and project references.
packages/workers/src/worker-test-evaluator.ts Updated import paths to use centralized type definitions.
packages/workers/src/worker-test-evaluator.test.ts Adjusted import reference to match new file structure.
packages/main/src/test-runner.ts Updated type imports to reference shared types across projects.
packages/frame-evaluators/src/frame-test-evaluator.ts Updated import paths to centralized type definitions.
packages/frame-evaluators/src/frame-test-evaluator.test.ts Adjusted import reference to match new file structure.
jest.config.mjs Commented out ts-jest configuration in favor of Babel.
eslint.config.mjs Expanded ignored paths to include package build directories.
babel.config.mjs Added new Babel configuration for transpiling TypeScript.
Files not reviewed (5)
  • base-tsconfig.json: Language not supported
  • package.json: Language not supported
  • packages/frame-evaluators/tsconfig.json: Language not supported
  • packages/main/tsconfig.json: Language not supported
  • packages/workers/tsconfig.json: Language not supported

@ojeytonwilliams ojeytonwilliams force-pushed the refactor/use-project-references branch from 3fb960e to 6a69b50 Compare March 28, 2025 07:58
@ojeytonwilliams ojeytonwilliams marked this pull request as ready for review March 28, 2025 07:58
@ojeytonwilliams ojeytonwilliams requested a review from Copilot March 28, 2025 07:58
Copy link

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

This PR refactors the project setup to use TypeScript project references and updates related configurations and imports to support multiple environments. Key changes include:

  • Updating webpack.config.cjs to generate multiple entrypoints for ts-loader using project references.
  • Adjusting import paths in WorkerTestEvaluator, FrameTestEvaluator, and TestRunner to use shared types from a centralized location.
  • Removing ts-jest from jest.config.mjs in favor of Babel, and updating ESLint and Babel configurations accordingly.

Reviewed Changes

Copilot reviewed 16 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
webpack.config.cjs Refactored to dynamically generate entrypoints and module rules.
packages/workers/src/worker-test-evaluator.ts Updated import paths to reference shared type definitions.
packages/workers/src/worker-test-evaluator.test.ts Corrected the import path for WorkerTestEvaluator testing.
packages/main/src/test-runner.ts Updated type imports to rely on centralized type definitions.
packages/frame-evaluators/src/frame-test-evaluator.ts Updated import paths for consistency with shared types.
packages/frame-evaluators/src/frame-test-evaluator.test.ts Adjusted import path for FrameTestEvaluator testing.
jest.config.mjs Removed ts-jest and added configuration for jest-puppeteer.
eslint.config.mjs Extended ignore patterns to include build directories in packages.
babel.config.mjs Added a new Babel config to support TypeScript transpilation.
Files not reviewed (5)
  • base-tsconfig.json: Language not supported
  • package.json: Language not supported
  • packages/frame-evaluators/tsconfig.json: Language not supported
  • packages/main/tsconfig.json: Language not supported
  • packages/workers/tsconfig.json: Language not supported
Comments suppressed due to low confidence (1)

webpack.config.cjs:23

  • [nitpick] Consider using path.join() or adjusting the template string to avoid generating double slashes in the file path, which might lead to issues on some file systems.
        [name]: `${path}/${name}.ts`,

@ojeytonwilliams ojeytonwilliams merged commit 9b54ebd into main Mar 28, 2025
1 check passed
@ojeytonwilliams ojeytonwilliams deleted the refactor/use-project-references branch March 28, 2025 07:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants