-
Notifications
You must be signed in to change notification settings - Fork 3.3k
chore: convert server/lib/plugins files from JS to TS #32337
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
Conversation
cypress
|
Project |
cypress
|
Branch Review |
server-plugins-to-ts
|
Run status |
|
Run duration | 20m 21s |
Commit |
|
Committer | Jennifer Shehane |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
13
|
|
1102
|
|
0
|
|
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%
|
|
---|---|
|
186
|
|
157
|
Accessibility
97.71%
|
|
---|---|
|
4 critical
8 serious
2 moderate
2 minor
|
|
110
|
if (!(filePath in fileProcessors)) { | ||
return | ||
} |
There was a problem hiding this comment.
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.
packages/server/lib/plugins/util.ts
Outdated
import Promise from 'bluebird' | ||
import path from 'path' | ||
import type { CompilerErrorLocation, ProcessIpcWrapper, TransformError } from '@packages/types' | ||
import type { SerializedError, ErrorLike } from '@packages/errors' |
There was a problem hiding this comment.
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
}, | ||
} | ||
|
||
export default API |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests fail with this change: https://app.circleci.com/pipelines/github/cypress-io/cypress/74232/workflows/357d572b-99d6-4b0a-944d-11a1e5e823e7/jobs/3106827/tests
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module.exports = API |
|
||
export default API | ||
|
||
module.exports = API |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module.exports = API |
}, | ||
} | ||
|
||
export default API |
There was a problem hiding this comment.
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
Additional details
Migrating server/lib/plugins files from JavaScript to TypeScript. No behavior is intended to change.
Few things to note:
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:
IpcHandler
→PluginIpcHandler
(in@packages/types
)send()
returnsboolean
,on()
returnsthis
for chainingdev-server.ts
,preprocessor.ts
, and data-context plugin handlersIpcWrapper
→ProcessIpcWrapper
(inutil.ts
)send()
returnsvoid
,on()
returnsEventEmitter
, plusremoveListener()
util.ts
for wrapping child processesSteps to test
How has the user experience changed?
N/A
PR Tasks
cypress-documentation
?type definitions
?