-
Notifications
You must be signed in to change notification settings - Fork 653
refactor(js-api): remove the JSON-RPC backend and unimplemented methods #3831
Conversation
✅ Deploy Preview for docs-rometools canceled.
|
}, | ||
"peerDependencies": { | ||
"rome": "^10.0.0", | ||
"@rometools/wasm-bundler": "^10.0.0", |
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 why rome
was removed from here?
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.
The rome
package isn't being imported in the JS API, it only serves to pull in the pre-built binaries but we're not making use of that anywhere
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.
Then it should be removed from the peerDependenciesMeta
let isInitialized = { | ||
[Distribution.BUNDLER]: false, | ||
[Distribution.NODE]: false, | ||
[Distribution.WEB]: false, | ||
}; |
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 shape makes me think that more than one distribution can be initialized at the same time. Is it the case?
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.
Yes potentially someone could call Rome.create
multiple times with different distribution, it's unclear why anyone would do that but I figured the modules should at least be initialized properly in that case ...
@@ -1,6 +1,7 @@ | |||
{ | |||
"compilerOptions": { | |||
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ | |||
"lib": ["ES2020", "ESNext.WeakRef"], |
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.
Is WeakRef
used to enable the FinalizationRegistry
feature?
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.
Yes FinalizationRegistry
isn't part of the ES2020 specification
1bf09f3
to
3277027
Compare
2aa5104
to
8962d4e
Compare
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.
Looks good. Please update the README with the correct installation and usage instructions.
Summary
This PR aims at improving the usability of the
@rometools/js-api
package by cleaning up some unfinished features.I removed the JSON-RPC backend as it's unlikely to be useful in the short term while we don't have a long running development server (since this only leaves the WASM backend, the concept of backend has instead been replaced with "distributions" to let the user choose which of the
bundler
,nodejs
orweb
versions of@rometools/wasm
they want to load).I also removed the
formatFiles
andparseContent
methods since those were not implemented at the moment. On the other hand I added newlintContent
andprintDiagnostics
methods since those were mostly straightforward to implement and could provide additional value to the JS API. Finally I've added ashutdown
method to manually free the WASM Workspace instance, as well as an experimental use of theFinalizationRegistry
to automatically free some Workspace instances that are no longer reachable.Test Plan
I've updated the existing tests for the JS API to remove the daemon-specific tests and cover the new methods.