DEV Community

Adam Crockett 🌀
Adam Crockett 🌀

Posted on

Deno dependencies, xstate

I have been playing with deno again lately, seems like it's come quite far now. But what I am wondering about is using libraries.

I would love to use xstate but I'm not sure if xstate needs to be packaged in some special way for deno. How would I import it into my code?

Top comments (3)

Collapse
 
vonheikemen profile image
Heiker

Packages would need to be valid ES6 modules. I guess you'll have to rely on cdn like unpkg or pika.dev.

Using pika.dev cdn and xstate as an example, I think you'll have to do this.

import { Machine, interpret } from 'https://cdn.pika.dev/xstate@^4.7.7';

The deno manual has a section on using third party code: link

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Thanks that's a great help, what about type defs? (Will read link)

Collapse
 
vonheikemen profile image
Heiker

If you use pika.dev you don't have to do anything to get the type definitions. According to this article.

In collaboration with the Deno team for their recent v0.32.0 release, Pika CDN now hosts type declarations for every package that provides them! Import an npm package from our CDN and Deno will automatically fetch its type declarations along with it.

The manual also has a external type definition section: link