Skip to content

Commit

Permalink
Merge pull request #109 from CodinGame/improve-treemending
Browse files Browse the repository at this point in the history
Improve/simplify tree-mending
  • Loading branch information
CGNonofr committed May 3, 2023
2 parents b934837 + 857461c commit 063cb4c
Show file tree
Hide file tree
Showing 47 changed files with 2,043 additions and 3,429 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
vscode/
vscode-default-extensions/
dist/
dist/
monaco-editor-treemending.patch
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ The VSCode api is composed of:
- If it's an important feature: it requires to use the corresponding service override.
- If it's some advanced features that don't make a lot of sense on Monaco (scm, tests...), it just throws an error when you try to use it.

## Installation

```bash
npm install vscode@npm:@codingame/monaco-vscode-api
npm install -D @types/vscode
```

⚠️ And add in your package.json ⚠️:
```json
{
"scripts": {
"postinstall": "monaco-treemending",
}
}
```

### Why?

Monaco-editor is a library that is constructed using code from vscode and goes through an intense treeshaking process.

However, due to the inclusion of additional code from VSCode in this library that utilizes internal modules bundled in monaco, this treeshaking is a problem here.

To **tree-mend** (to **un**treeshake it) monaco-editor, this library provide a script that will apply a patch on the local installation of monaco-editor, restoring all the code that was treeshaken during the monaco-editor build process

# Usage

## Monaco standalone services

Also, monaco-editor use `standalone` versions or the vscode services, which are much simpler.
Expand All @@ -30,7 +56,7 @@ await initialize({
})
```

Additionally, this library exposes 11 modules that include the vscode version of some services (with some glue to make it work with monaco):
Additionally, this library exposes 13 modules that include the vscode version of some services (with some glue to make it work with monaco):

- Notifications: `vscode/service-override/notifications`
- Dialogs: `vscode/service-override/dialogs`
Expand Down Expand Up @@ -120,14 +146,7 @@ The only difference is that is will use the `configurationService` as a default
`createModelReference` return a reference to a model. The value is fetched from the memory filesystem (which is written if you provide the second argument).
The reference can then be disposed, the model will only be disposed if there is no remaining references.

### Installation

```bash
npm install vscode@npm:@codingame/monaco-vscode-api
npm install -D @types/vscode
```

### Usage
## VSCode api usage

You can just import it as if you were in a vscode extension:

Expand Down
Loading

0 comments on commit 063cb4c

Please sign in to comment.