Skip to content

Command to open compiled file #294

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

Merged
merged 4 commits into from
Mar 3, 2022
Merged

Command to open compiled file #294

merged 4 commits into from
Mar 3, 2022

Conversation

fhammerschmidt
Copy link
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
Copy link
Collaborator

zth commented Feb 26, 2022

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

@fhammerschmidt
Copy link
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

Copy link
Collaborator

@cristianoc cristianoc left a comment

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
Member Author

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

Copy link
Collaborator

@cristianoc cristianoc left a comment

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
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).

Copy link
Collaborator

@cristianoc cristianoc left a comment

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