Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 @rometools/js-api has no exported members #3646

Closed
1 task done
NikolaRHristov opened this issue Nov 10, 2022 · 5 comments · Fixed by #3648 or #3652
Closed
1 task done

🐛 @rometools/js-api has no exported members #3646

NikolaRHristov opened this issue Nov 10, 2022 · 5 comments · Fixed by #3648 or #3652
Assignees
Labels
S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@NikolaRHristov
Copy link
Contributor

NikolaRHristov commented Nov 10, 2022

Environment information

CLI:
  Version:              10.0.0
  Color support:        true

Platform:
  CPU Architecture:     x86_64
  OS:                   windows

Environment:
  ROME_LOG_DIR:         unset
  NO_COLOR:             unset
  TERM:                 "xterm-256color"

Rome Configuration:
  Status:               unset

Workspace:
  Open Documents:       0

Discovering running Rome servers...

Running Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i The client isn't connected to any server but rage discovered this running Rome server.        

Server:
  Version:              10.0.0
  Name:                 rome_lsp
  CPU Architecture:     x86_64
  OS:                   windows

Workspace:
  Open Documents:       0

Other Active Server Workspaces:

Workspace:
  Open Documents:       2
  Client Name:          Visual Studio Code - Insiders
  Client Version:       1.74.0-insider

Workspace:
  Open Documents:       0
  Client Name:          Visual Studio Code - Insiders
  Client Version:       1.74.0-insider

Rome Server Log:

! Please review the content of the log file before sharing it publicly as it may contain sensitive information:
  * Path names that may reveal your name, a project name, or the name of your employer.
  * Source code

├─12996221ms INFO rome_lsp::server Starting Rome Language Server...

What happened?

After

npm i rome
npm i @rometools/js-api

I'm trying to run the @rometools/js-api but the Rome object is empty and the node_modules holds no files. Only

node_modules
package.json
README.md

and inside node_modules a .bin

rome
rome.CMD
rome.ps1

which points back to the cli.

Expected result

To be able to do

import {Rome} from "@rometools/js-api"

const rome = await Rome.create({
    backendKind: BackendKind.NODE,
});

const result = await rome.formatContent("function f   () {  }", {
    filePath: "example.js",
});

console.log(result.content)

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@NikolaRHristov NikolaRHristov added the S-To triage Status: user report of a possible bug that needs to be triaged label Nov 10, 2022
@MichaReiser MichaReiser added S-Bug: confirmed Status: report has been confirmed as a valid bug S-To triage Status: user report of a possible bug that needs to be triaged and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Nov 10, 2022
@MichaReiser MichaReiser self-assigned this Nov 10, 2022
@MichaReiser MichaReiser removed the S-To triage Status: user report of a possible bug that needs to be triaged label Nov 10, 2022
@MichaReiser
Copy link
Contributor

This is only partially solved. It's still not possible to use the API because the module statically imports all backends and the bundling of the backend-jsonrpc is broken too #3647 .

#3652 should fix the static imports so that the API can then be used with the WASM backend

@MichaReiser
Copy link
Contributor

MichaReiser commented Nov 10, 2022

It should now be possible to use the package with

import { Rome, BackendKind } from "@rometools/js-api";

const rome = await Rome.create({
	backendKind: BackendKind.NODE,
});

const result = await rome.formatContent("function f   () {  }", {
	filePath: "example.js",
});

console.log(result.content);

You have to manually install the optional @rometools/wasm-nodejs that runs Rome as a WASM module.

Be aware that the API is experimental and is not ready for production.

@NikolaRHristov
Copy link
Contributor Author

NikolaRHristov commented Nov 10, 2022

Thank you! @MichaReiser

@eyeball-bot
Copy link

how can i specify formatting options? because currently it ignores my rome.json settings
thanks

@ematipico
Copy link
Contributor

how can i specify formatting options? because currently it ignores my rome.json settings
thanks

You would need to manually pass the confirmation, here's an example: https://github.com/rome/tools/blob/main/website/src/playground/workers/romeWorker.ts#L143

The API, at the moment, don't look for the configuration file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
4 participants