monaco-editor/CONTRIBUTING.md

126 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

2023-02-23 23:12:54 +08:00
# Contributing / Dev Setup
2023-02-23 23:12:54 +08:00
## Source Code Structure
2021-11-06 07:15:13 +08:00
2023-02-23 23:12:54 +08:00
It is important to understand that the Monaco Editor _Core_ is built directly from the [VS Code source code](https://github.com/microsoft/vscode).
The Monaco Editor then enhances the Monaco Editor Core with some basic language features.
2021-11-06 07:15:13 +08:00
2023-02-23 23:12:54 +08:00
This diagram describes the relationships between the repositories and the npm packages:
2021-11-06 07:15:13 +08:00
2023-02-23 23:12:54 +08:00
![](./docs/code-structure.dio.svg)
By default, `monaco-editor-core` is installed from npm (through the initial `npm install`), so you can work on Monaco Editor language features without having to build the core editor / VS Code.
The nightly builds build a fresh version of `monaco-editor-core` from the `main` branch of VS Code.
For a stable release, the commit specified in `vscodeRef` in [package.json](./package.json) specifies the commit of VS Code that is used to build `monaco-editor-core`.
2021-11-06 07:15:13 +08:00
## Contributing a new tokenizer / a new language
Please understand that we only bundle languages with the monaco editor that have a significant relevance (for example, those that have an article in Wikipedia).
- create `$/src/basic-languages/{myLang}/{myLang}.contribution.ts`
- create `$/src/basic-languages/{myLang}/{myLang}.ts`
- create `$/src/basic-languages/{myLang}/{myLang}.test.ts`
- edit `$/src/basic-languages/monaco.contribution.ts` and register your new language
- create `$/website/index/samples/sample.{myLang}.txt`
```js
import './{myLang}/{myLang}.contribution';
```
2023-02-22 18:39:04 +08:00
## Debugging / Developing The Core Editor
2023-02-23 23:12:54 +08:00
To debug core editor issues.
This can be done directly from the VS Code repository and does not involve the monaco editor repository.
- Clone the [VS Code repository](https://github.com/microsoft/vscode): `git clone https://github.com/microsoft/vscode`
- Open the repository in VS Code: `code vscode`
- Run `yarn install`
- Select and run the launch configuration "Monaco Editor Playground" (this might take a while, as it compiles the sources):
![](./docs/launch%20config.png)
- Now you can set breakpoints and change the source code
![](./docs/debugging-core.gif)
- Optionally, you can build `monaco-editor-core` and link it to the monaco editor repository:
```bash
# builds out-monaco-editor-core
> yarn gulp editor-distro
> cd out-monaco-editor-core
> npm link
> cd ../path/to/monaco-editor
# symlinks the monaco-editor-core package to the out-monaco-editor-core folder we just built
> npm link monaco-editor-core
```
2021-11-06 07:15:13 +08:00
## Debugging / Developing Language Support
2021-11-06 07:15:13 +08:00
2023-02-23 23:12:54 +08:00
To debug bundled languages, such as JSON, HTML or TypeScript/JavaScript.
- Clone the [monaco editor repository](https://github.com/microsoft/monaco-editor): `git clone https://github.com/microsoft/monaco-editor`
- Open the repository in VS Code: `code monaco-editor`
- Run `npm install`
- Select and run the launch configuration "Monaco Editor Playground" (this might take a while, as it compiles the sources):
2021-11-09 23:30:09 +08:00
2023-02-23 23:12:54 +08:00
![](./docs/launch%20config.png)
2021-11-06 07:15:13 +08:00
2023-02-23 23:12:54 +08:00
- Now you can set breakpoints and change the source code
![](./docs/debugging-languages.gif)
- Optionally, you can build `monaco-editor` and link it if you want to test your changes in a real application:
```bash
# builds out/monaco-editor
> npm run build-monaco-editor
> cd out/monaco-editor
> npm link
> cd ../path/to/my-app
> npm link monaco-editor
```
2021-11-06 07:15:13 +08:00
## Running the editor tests
```bash
> npm run build-monaco-editor
> npm run test
> npm run compile --prefix webpack-plugin
> npm run package-for-smoketest-webpack
> npm run package-for-smoketest-esbuild
> npm run package-for-smoketest-vite
> npm run package-for-smoketest-parcel --prefix test/smoke/parcel
> npm run smoketest-debug
2021-11-06 07:15:13 +08:00
```
## Running the website locally
2023-02-23 23:12:54 +08:00
```bash
> npm install
> npm run build-monaco-editor
2023-03-01 10:46:15 +08:00
2023-03-02 22:40:06 +08:00
> cd website
> yarn install
> yarn typedoc
> yarn dev
2023-02-23 23:12:54 +08:00
```
2023-03-02 22:40:06 +08:00
Now webpack logs the path to the website.
2023-02-23 23:12:54 +08:00
2023-02-24 22:21:51 +08:00
## Out Folders
This diagram describes the output folders of the build process:
![](./docs/out-folders.dio.svg)
2023-02-23 23:12:54 +08:00
## Maintaining
Checkout [MAINTAINING.md](./MAINTAINING.md) for common maintaining tasks (for maintainers only).