Home > other >  What's the correct way to self-host a Deno library?
What's the correct way to self-host a Deno library?

Time:05-25

I've set up an apache2 server and have located my library at http://example.com/lib/deno/[email protected]/ and then created a 301 redirect from http://example.com/lib/deno/test/ to the former. In VS Code (using deno plugin) I noticed that when I import something like https://deno.land/std/http/server.ts I get a warning message:

Implicitly using latest version (0.140.0) for https://deno.land/std/http/server.ts deno(deno-warn)

Following the url it re-directs to https://deno.land/[email protected]/http/server.ts

However when I import my own http://example.com/lib/deno/test/mod.ts I do not get a similar message. Is this warning somehow hard coded to only work with deno.land or am I not hosting things correctly?

CodePudding user response:

Deno provides an implementation of the Language Server Protocol. To integrate tightly with all of its capabilities in regard to module discovery, autocomplete, etc. you will need to implement a module registry, which is described here:

https://deno.land/[email protected]/language_server/imports

Here are the basics of what is required, but you'll need to understand the details of the API endpoints, schema, etc. to succeed in your implementation.

Registry support for import completions

In order to support having a registry be discoverable by the Deno language server, the registry needs to provide a few things:

  • A schema definition file. This file needs to be located at /.well-known/deno-import-intellisense.json. This file provides the configuration needed to allow the Deno language server query the registry and construct import specifiers.

  • A series of API endpoints that provide the values to be provided to the user to complete an import specifier.

  • Related