Skip to content

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Aug 22, 2025

Additional details

Migrating server/lib/plugins files from JavaScript to TypeScript. No behavior is intended to change.

Few things to note:

  • I tried to convert server/lib/plugins/util.js file and....it is not ready to be touched basically. The problem seemed to be around the child process files needing the utils file to be JavaScript (to be spawnable).

Interface Renaming for IPC comms:

  1. IpcHandlerPluginIpcHandler (in @packages/types)

    • Purpose: Plugin IPC communication with the main process
    • Methods: send() returns boolean, on() returns this for chaining
    • Context: Used by dev-server.ts, preprocessor.ts, and data-context plugin handlers
  2. IpcWrapperProcessIpcWrapper (in util.ts)

    • Purpose: Process IPC communication (parent-to-child process)
    • Methods: send() returns void, on() returns EventEmitter, plus removeListener()
    • Context: Used internally by util.ts for wrapping child processes

Steps to test

  • Run server tests

How has the user experience changed?

N/A

PR Tasks

@jennifer-shehane jennifer-shehane self-assigned this Aug 22, 2025
cursor[bot]

This comment was marked as outdated.

Copy link

cypress bot commented Aug 22, 2025

cypress    Run #65160

Run Properties:  status check passed Passed #65160  •  git commit a64c21d59c: fix another preprocessor default call
Project cypress
Branch Review server-plugins-to-ts
Run status status check passed Passed #65160
Run duration 20m 21s
Commit git commit a64c21d59c: fix another preprocessor default call
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 13
Tests that did not run due to a developer annotating a test with .skip  Pending 1102
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26661
View all changes introduced in this branch ↗︎

Warning

Partial Report: The results for the Application Quality reports may be incomplete.

UI Coverage  45.11%
  Untested elements 186  
  Tested elements 157  
Accessibility  97.71%
  Failed rules  4 critical   8 serious   2 moderate   2 minor
  Failed elements 110  

Comment on lines +145 to +147
if (!(filePath in fileProcessors)) {
return
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Code used to be:

    if (!fileProcessors[filePath]) {
      return
    }

Since fileProcessors is typed as Record<string, Promise<string>>, the values are always Promise<string> objects, which are always truthy.

import Promise from 'bluebird'
import path from 'path'
import type { CompilerErrorLocation, ProcessIpcWrapper, TransformError } from '@packages/types'
import type { SerializedError, ErrorLike } from '@packages/errors'
Copy link
Member Author

Choose a reason for hiding this comment

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

Pulling in error types from @packages/errors

cursor[bot]

This comment was marked as outdated.

@mschile mschile requested a review from AtofStryker August 26, 2025 15:10
},
}

export default API
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason we have both module.exports and export default here @jennifer-shehane ? Since the code is internal we should just need export default API and any play this is required we just change the require('dev-server') to require('dev-server').default

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah I think they were being used in tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

This may be some leftover code from me trying to get the utils to work, I’ll revisit next week

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@jennifer-shehane it's likely stubbing something that is now exported on the default. i'll pull the branch down and check


export default API

module.exports = API
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
module.exports = API


export default API

module.exports = API
Copy link
Contributor

Choose a reason for hiding this comment

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

should be able to do the same here too. otherwise the compiled output could conflict

execute: Promise.method((eventName: string, ...args: unknown[]) => {
if (!plugins.has(eventName)) return

return plugins.execute(eventName, ...args)
Copy link
Contributor

Choose a reason for hiding this comment

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

could be a good time to async/await this code but its out of scope

Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

I pushed up 09cb9b1 @jennifer-shehane that should fix the errors you are running into. inside the spec files, the imports now need to alias the default export since its loaded in a CJS context and is dynamically interpreting the TypeScript file


export default API

module.exports = API
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
module.exports = API

},
}

export default API
Copy link
Contributor

Choose a reason for hiding this comment

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

@jennifer-shehane it's likely stubbing something that is now exported on the default. i'll pull the branch down and check

@AtofStryker AtofStryker self-requested a review September 2, 2025 18:54
@jennifer-shehane jennifer-shehane merged commit b5fc986 into develop Sep 3, 2025
87 of 90 checks passed
@jennifer-shehane jennifer-shehane deleted the server-plugins-to-ts branch September 3, 2025 13:52
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