All Astro projects use pnpm and Turbo to enable development in a monorepo. Once you've cloned the project install dependencies and do an initial build:
pnpm
pnpm build
During the normal course of development on the VSCode extension you'll want to run the debugger. First run the build in watch mode with:
pnpm dev
Note
If you haven't ran pnpm build
or pnpm dev
already, you may see some errors related to some files being missing. This is normal on a first run, and you can safely ignore these errors.
Then in VSCode:
- Switch to Run and Debug.
- Click Launch Extension.
This will launch a new window for your editor. Here you can navigate to a test Astro project that you will use to develop your changes.
The Debug console in the main editor is where you will get logging information. When developing in the language server, logging is helpful to figure out what is going on.
- Ctrl+Shift+P (CMD+Shift+P on OSX) opens the command palette.
- Select Debug Console.
- At the bottom, switch to Attach to Server. This is most of the information you'll want to see.
Now you can start developing your changes. You can set breakpoints or add debugger;
statements. To see your changes reflect you'll need to take these steps:
- In the extension editor window, go to Run and Debug if you are not already there.
- Click on the Restart button under Launch Client.
This will restart the extension and reload your test window.
If you have the Extension installed you'll need to turn it off, or your development extension will not be used and you'll be confused why your changes are not working.
- Click on Extensions.
- Search for astro.
- Click the extension and then click Disable.
To start development on the TS Plugin, you'll need to first run the following command:
pnpm dev
Logs from TypeScript plugins are shown in the TSServer log. To open this log, follow these steps:
- Ctrl+Shift+P (CMD+Shift+P on OSX) opens the command palette.
- Select TypeScript: Open TS Server log.
If you've never opened the TS Server log before, you'll first need to enable logging and restart the TSServer. The command will prompt you to do this if needed
Hint: TSServer's logs are really noisy, even at the lowest level. Make sure to disable other plugins when working on the TS Plugin. Alternatively, grepping for "Astro Plugin" can help