-
Notifications
You must be signed in to change notification settings - Fork 54
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
Auto Imports, remove JS/TS config #677
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
136090d
wip
machty ba6975c
passing test
machty 87b4e4b
prettier
machty 8bcaaf7
fix relative imports
machty a6b0d04
disregard line items
machty 2018955
improve formatting of imports
machty a9cb5a2
fix lint
machty f31a196
prettier
machty 0a891f7
test additional
machty 5cfe89c
progress
machty 3e614f2
show relative path
machty a6c417a
prettier
machty 8996962
rm ConfigManager
machty 5796a15
prettier/eslint
machty 3589b20
add launch task without TS
machty 2b97e1a
improve CONTRIBUTING docs
machty 4eb19fe
fix behavior of relative imports
machty d5ad04d
clarify debugging
machty 5def97d
Fix glimmer component imports
machty fbcdd0b
prettier
machty a06a985
add some ts-ignores
machty 6312d7a
rm console errors
machty 918cb33
tweak docs
machty 6dc15df
add note about IR
machty f416758
de-hardwire useCaseSensitiveFileNames
machty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,69 @@ Glint is a family of packages which all live in this repo as a Yarn workspace. T | |
- Read the project’s [ARCHITECTURE.md](./ARCHITECTURE.md) to understand the basics of how the code base works. | ||
|
||
Once you have made changes and added tests to confirm they work correctly, you can then open a PR and we'll work with you to polish it up and get it landed! | ||
|
||
# Common Debugging Scenarios | ||
|
||
## How to run glint-language-server locally? | ||
|
||
If you would like to connect your editor to a locally running version of the Glint language server, first start the `tsc` compiler in watch mode from the root folder of the Glint repo: | ||
|
||
``` | ||
tsc --build --watch | ||
``` | ||
|
||
Then you can configure your editor to point to the absolute path of the `./packages/core` folder within this repo when launching the language server. For VSCode users, this means opening your user preferences (after having already installed the Glint VSCode extension) and setting "Glint: Library Path" (aka `glint.libraryPath`) to the absolute path of the `packages/core` folder, e.g. `/Users/machty/code/glint/packages/core`. | ||
|
||
With the running `tsc --build --watch` command, the language server will rebuild when any source code files change. _Important_: after any source code file change and subsequent rebuild, you will need to restart the language server from within your editor in order for the changes to be reflected in your editor. In VSCode, this means running "Glint: Restart Glint Server" from the Command Palette. | ||
|
||
## How to run glint-language-server locally in debug mode? | ||
|
||
There are a few VSCode Launch Configurations within `./vscode/launch.json` that are handy for debugging: | ||
|
||
- Both will enable the TS/JS debugger on both the language server and the client-side VSCode extension code, meaning the debug breakpoints will pause execution to allow you to debug things like text completions | ||
- Debug Extension (Glint + TS) | ||
- This spins up a VSCode window with both Glint and the built-in TS language server running. | ||
- In this mode, both language servers will provide duplicate completions and suggestions, which can be useful for testing out feature parity between Glint and TS | ||
- Debug Extension (Glint Only) | ||
- This is useful for testing out the "takeover" mode of running Glint, where Glint is responsible for providing all of the language features (debugging, diagnostics, etc); this is the ideal way to run Glint, but at the time of writing we have not yet achieved feature parity with built-in TS | ||
- By default these extensions will launch the VSCode Extension Host in the `test-packages` subfolder, which have Ember and Glimmerx apps that you can do some basic testing on | ||
- _TIP_: you can open any workspace with the Extension Host, meaning you can even debug the language server with breakpoints on a totally separate Ember repo, for example. | ||
- _NOTE_: debugging takes place within the `glint` workspace, i.e. if you are debugging completions, you'd trigger a completion within the Extension Host, and the breakpoint would pause within the Glint workspace VSCode instance. | ||
|
||
These launch configurations can be run via the Run and Debug tab in VSCode. | ||
|
||
## How to test out the VSCode extension locally? | ||
|
||
Firstly, there is an entire suite of integration tests that will spin up instances of VSCode and test out the VSCode Glint extension. These can be run from the `packages/vscode` directory via: | ||
|
||
``` | ||
yarn run test | ||
``` | ||
|
||
Secondly, the Launch Configurations described above (I believe) will run your client-side extension code in debug mode, along with the language server. | ||
|
||
## How to see the transformed Intermediate Representation (IR) code of a template | ||
|
||
Glint transforms template code into TypeScript code so that it can be type-checked by the vanilla TS compiler. Transformed IR code looks something like: | ||
|
||
```ts | ||
static { | ||
({} as typeof import("@glint/environment-ember-loose/-private/dsl") | ||
.templateForBackingValue(this, function(𝚪, χ: typeof import("@glint/environment-ember-loose/-private/dsl")) { | ||
{ | ||
const 𝛄 = χ.emitComponent(χ.resolve(χ.Globals["FooComponent"]) | ||
({ desc: "notchHeight _ footer", ...χ.NamedArgsMarker })); | ||
𝛄; | ||
{ | ||
const [] = 𝛄.blockParams["default"]; | ||
{ | ||
// ... | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using these Greek letters makes the code/documentation less readable. |
||
|
||
Sometimes it is useful to see the IR of any .hbs template or .gts/.gjs file for debugging purposes; if you're using VSCode you can see the IR by: | ||
|
||
1. Enable "Glint: Debug" in your VSCode user preferences | ||
2. Run the "Glint: Show IR for Debugging" command | ||
|
||
Your template code will be replaced by the IR directly in your editor window. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks a ton for adding this! This is all the information i got super stuck on not having when i was first getting in to glint!
Very needed!