Skip to content

Command to open compiled file - #294

Merged
cristianoc merged 4 commits into
rescript-lang:masterfrom
fhammerschmidt:open-compiled-command
Mar 3, 2022
Merged

cristianoc merged 4 commits into
rescript-lang:masterfrom
fhammerschmidt:open-compiled-command

Conversation

@fhammerschmidt

Copy link
Copy Markdown
Member

This implements #107

Press CMD+Shift+P and select ReScript: Open the compiled JS file for this implementation file.
It should open the corresponding .bs.js, .js, .mjs in the correct directory (whether in-source or not).

Unfortunately, this requires to parse bsconfig.json. I did not know how to account for an array with more than one element of package-specs, so for now it just takes the first one, but I guess it is better to use an object anyway, as suggested by the docs.

@zth

zth commented Feb 26, 2022

Copy link
Copy Markdown
Member

@fhammerschmidt would it be possible to refactor this to use the same bsconfig read mechanism as your other PR?

@fhammerschmidt

Copy link
Copy Markdown
Member Author

Yes! Just did that and also factored out all the commands into separate files.
Bonus: You can open the compiled file both with the CMD+SHIFT+P menu and the following icon in the navigation menu:
image

Let me know if you think there is a better icon for this action: https://code.visualstudio.com/api/references/icons-in-labels#icon-listing

Comment thread server/src/utils.ts Resolved

@cristianoc cristianoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking great.
Is it ready to merge?

@fhammerschmidt

Copy link
Copy Markdown
Member Author

IMO yes, I used it all day while working on a big monorepo and it always worked well so far.

Comment thread server/src/constants.ts Resolved
Comment thread server/src/server.ts Resolved

@cristianoc cristianoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See comments.

@fhammerschmidt

Copy link
Copy Markdown
Member Author

I tried to be more explicit with the modulename -> foldername resolving.
Also added another case when you directly set the "package-specs" field to a string.
Tested it with the example project now as well (and I tested all possible module format strings).

@cristianoc cristianoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fantastic. Merging.

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.

3 participants