GithubHelp home page GithubHelp logo

cahuzacf / denoify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garronej/denoify

0.0 0.0 0.0 288 KB

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

TypeScript 86.34% JavaScript 13.66%

denoify's Introduction

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


WARNING: This is a pre-release that might be broken in some way. Polished release coming soon.

What it is

This tool 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 that are ready to be deployed as a Deno module.

Denoify does for Deno what browserify does for the browser.

What it isn't

A way to import node modules in Deno projects. For that purpose you can try CommonJS module Loading

Motivations

Although it is quite easy to port a module to Deno it is a chore to maintain two codebases.

Example of modules using Denoify

Modules that have been made cross-runtime using Denoify:

Will it work with my module ?

  • Does your users need to have @types/node installed to use your module ? If yes then, unfortunately, your module is not denoifiable as it is. Even if you are allowed to use (some, not all) node builtins such as fs, path or event you will need to remove all Node reference from your exposed API before you can use Denoify. You can't for example expose a class that extends EventEmitter or if you do you will have to export a type definition for EventEmitter.
  • You will need to provide a Deno polyfill for each of your project dependencies that are not known by Denoify. Here is the list of modules for which Denoify has already a polyfill for. Note that Denoify work recursively meaning that you can fork your dependencies repo and Denoify them yourself.
    However, depending on how deep your dependency tree goes it might not be feasible.
  • Is your module a vanilla JS project? If yes you will have to port it into TypeScript first.

Roadmap to 1.0

The project is at an early stage. Current TODO list;

  • Allows require() ( synchronous dynamic loading of modules )
  • Using the typescript compiler API to parse source files instead of making the change with RegExps. ts-morph seems to be a good option here.
  • Polyfills global node API that are not imported like Buffer and process. ( Language parsing must land first. )

TUTORIALS

Porting an existing project

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

Starting a project from scratch

denoify_ci

denoify_ci is a template repo that automate 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.
  • Testing on multiples Node and Deno version before publishing.
  • Maintaining a CHANGELOG
  • Publishing on NPM and deno.land/x on your behalf.

All you have to do is write the code.

denoify's People

Contributors

garronej avatar geopic avatar ksxgithub 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.