comlink
comlink copied to clipboard
Find a way to support Deno and TS with the same code base
Currently, you can use Comlink in Deno through one of the npm CDNs (unpkg, skypack etc). But it’d be nice to be able to import the source from GitHub directly. This currently doesn’t work as TypeScript enforces either no file extensions in imports or .js extension, while Deno requires the actual file path (ending in .ts).
What about using denoify to build deno-compatible code? Then we can commit the built files by GitHub Actions
workaround:
Add
{
"imports": {
"https://unpkg.com/[email protected]/dist/esm/protocol": "https://unpkg.com/[email protected]/dist/esm/protocol.d.ts"
}
}
to your importmap and import comlink like this:
// @deno-types="https://unpkg.com/[email protected]/dist/esm/comlink.d.ts"
import {/*...*/} "https://unpkg.com/[email protected]/dist/esm/comlink.mjs";
This import can be simplified with a extra file
// @deno-types="https://unpkg.com/[email protected]/dist/esm/comlink.d.ts"
export * from "https://unpkg.com/[email protected]/dist/esm/comlink.mjs";
in ./deps/comlink.ts
and also add
{
"comlink": "./deps/comlink.ts"
}
to the importmap.