Skip to content

Plugin additions #2622

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 27 commits into from
Feb 10, 2021
Merged

Plugin additions #2622

merged 27 commits into from
Feb 10, 2021

Conversation

code-asher
Copy link
Member

The main thing here was adding support for websocket routes and for disposing. The rest was mostly exposing some things so plugins don't have to recreate or reimport them.

@code-asher code-asher requested a review from nhooyr January 22, 2021 17:49
@code-asher code-asher force-pushed the plugin-additions branch 2 times, most recently from c456a86 to ddddcff Compare January 30, 2021 00:24
@jsjoeio jsjoeio modified the milestones: v3.8.1, v3.8.2 Feb 5, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 8, 2021

Dropping my plugin thoughts here.

Overall

We want to make the code-server plugin ecosystem as intuitive and easy as possible for plugin authors. Sub-modules are a headache so we shouldn't go that route.

I think this new architecture (repo is private) looks like the right direction for us to go in.

Education

We probably want to work with @bpmct to create some education around code-server plugins. We'll want it to live in both the /docs but also maybe create content on the Coder blog.

  • What are they?
  • How do they compare to VSCode Extensions?
  • How do you create one?

Further Reading

As we continue to iterate on top of the plugin ecosystem, we should take inspiration from other projects.

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks great 🎉 I left a bunch of questions, comments but all are non-blocking.

@bpmct
Copy link
Member

bpmct commented Feb 8, 2021

@jsjoeio thanks for the heads up. We'll sync on this on Wednesday :)

@code-asher code-asher force-pushed the plugin-additions branch 2 times, most recently from 1a1d131 to 0241c7d Compare February 9, 2021 18:56
In case they need to map it to something else.
This is used by some of our services.
Same reasoning used when exposing Express.
So plugins can pass the logger around.
This way tests that import the http utilities but not the routes won't
error due to missing types.
This is mainly so they can get relative paths in their HTML, in
particular code-server's static base so they can use the favicon and
service worker.
This will let them throw and show nice errors more easily.
Otherwise it consumes the body and plugins won't be able to do things
like proxy POST requests.
@code-asher
Copy link
Member Author

I rebased on master and resolved comments as well as fixed a problem with proxying inside a plugin (see the last five commits).

However, for some reason in Jest the module._load override doesn't work. I've tried a few things but no luck. It's like they have their own require mechanism for some insane reason.

import * as apps from "../src/node/routes/apps"
import * as httpserver from "./httpserver"
const fsp = fs.promises

// Jest overrides `require` so our usual override doesn't work.
jest.mock("code-server", () => codeServer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the magic line!

@@ -9,7 +9,7 @@ import * as httpserver from "./httpserver"
const fsp = fs.promises

// Jest overrides `require` so our usual override doesn't work.
jest.mock("code-server", () => codeServer)
jest.mock("code-server", () => codeServer, { virtual: true })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtual mocks – mocks of modules that don't exist anywhere in the system

🤯 TIL what a virtual mock is

Source

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yeah idk why it was passing locally without this for me though. 🤷

@code-asher code-asher merged commit 8344e20 into master Feb 10, 2021
@code-asher code-asher deleted the plugin-additions branch February 10, 2021 22:45
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.

4 participants