Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
/ deno-npm-demo Public archive

A demo using NPM packages with the Deno runtime

Notifications You must be signed in to change notification settings

vtenfys/deno-npm-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno NPM Demo

What is this?

This demo shows how it's possible to use NPM packages (ones with an ES module build) with the Deno JavaScript runtime. Snowpack is used to pack NPM dependencies for use with Deno. You can find ESM packages to try with Deno on Pika.

How do I try it?

  1. Install dependencies with NPM:

    npm install

    Snowpack should automatically run after installation - if it doesn't, use:

    npm run prepare
  2. Run the demos with Deno:

    # deno --importmap=deno_modules/import-map.json demos/<demo>.js
    npm run immer
    npm run preact
    npm run rxjs

Does this work with [my favourite package]?

Probably not - this only works with packages that can both be built as pure ES modules, and that don't require the use of any Node-specific or web-specific JavaScript APIs. Supporting the larger Node.js ecosystem would be a more ambitious project, as Deno doesn't support CommonJS imports (i.e. require), and a compatibility layer would need to be created to support other Node-specific APIs.

Things which likely will work:

  • Packages that can run in both the browser and the server, e.g. Preact
  • Packages that don't rely on Node-specific APIs (e.g. fs, crypto)
  • Utility libraries, e.g. Lodash

Things that won't work:

  • Packages that rely on Node-specific or web-specific APIs
  • Packages that rely on native extensions
  • Packages that rely on the the Node.js module system (require, module etc)

About

A demo using NPM packages with the Deno runtime

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published