Giter Site home page Giter Site logo

ajax27 / denoify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garronej/denoify

0.0 1.0 0.0 497 KB

🦕For NPM module authors that would like to support Deno but do not want to write and maintain a port for it.

License: MIT License

TypeScript 86.74% JavaScript 13.26%

denoify's Introduction

🦕 Support Deno and release on NPM with a single codebase.🦕


NOTICE: The tool will be presented at the next Deno Israel online meetup.

What it is

A build tool that takes as input a TypeScript codebase that was meant to target node and/or the web and spits out a modified version of the source files ready to be deployed as a Deno module.

what_denoify_does

If you are just looking for a quick way to load NPM modules in your Deno project you can check out CommonJS module Loading, unlike Denoify, it won't give you types definitions, it will involve node_modules/ and require --allow-read but it will also be easier to get working.

This tool is mainly for NPM module maintainer, to enable them to bring first-class citizen Deno support to their modules and doing so without introducing breaking changes.

Motivations

  • Although it is quite easy to port a module to Deno no one wants to maintain two codebase.
  • Wouldn't it be great to have a tool able to bring Deno support to NPM modules?

Example of modules using Denoify

Modules that have been made cross-runtime using Denoify:

Video introduction

Watch the video

Limitations

Coming up next is a detailed guide on how to set up denoify with your project and how to publish on deno.land/x but before anything here are the current limitations you need to be aware of.

  • If your module is vanilla JS it needs to be ported to TypeScript first. (1)
  • Not all Node's builtin are supported yet. (2)
  • You will need to fork and denoify(3) manually each of your module's (not dev) dependencies.
  • For the dependencies that can't easily be denoified you will need to write a partial Deno port of the bits your module needs.
  • require() is not yet supported.
  • You can't (yet) fs.readFile files that are part of the module ( files inside a res/ directory for example ). (4)

(1) Don't be afraid, renaming your source with .ts and dropping some any here and there will do the trick. You will be able to pull it off even if you aren't familiar with typescript. Ref

(2) You can consult here the current state of the Node's builtin support.

(3) Glossary: To 'denoify' a module is the process of using this tool to generate a deno distribution of a module and to publish it on GitHub. How to do that is documented in details.

(4) In Deno the files that forms your module won’t be pre-fetched and placed in node_module like in node so you won’t be able to access files that are not on the disk.

GUIDES

Setting up an existing project

Check out this repo to see in practice how to set up Denoify in your project.

Starting a project from scratch

denoify_ci

denoify_ci is a template repo that automates the boring and tedious tasks of:

  • Filling up the package.json
  • Setting up TypeScript and Denoify.
  • Writing a README.md with decent presentation and instructions on how to install/import your module in different environments.
  • Testing with multiple Node and Deno versions before publishing.
  • Publishing on NPM and deno.land/x ( via GitHub releases ).

Get started

TODO LIST / Things that need to change

  • 🔥 Support CDN (Pika, jspm, UNPKG ...) urls as Deno ports and feature side loading of type definitions.
  • index.ts should be rename mod.ts to respect Deno's naming recommendations.
  • Add cli option for specifying the output directory.

denoify's People

Contributors

garronej avatar geopic avatar ksxgithub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.