Skip to content

Convert NodeJS to Deno compatible code with rollup

Notifications You must be signed in to change notification settings

dami2/rollup-plugin-node-deno

 
 

Repository files navigation

rollup-plugin-deno2

Convert NodeJS to Deno compatible code with rollup.

  • Converts builtin imports to deno node compat
  • Injects polyfills for global built-ins like timers by usage

🧪 Note: This is an experimental plugin.

Install

# npm
npm install rollup-plugin-node-deno

# yarn
yarn add rollup-plugin-node-deno2

Usage

Example rollup.config file:

Note: Config below needs installing @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-json.

import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import deno from 'rollup-plugin-node-deno'

export default {
  input: 'src/index.mjs',
  output: {
    file: 'dist/index.mjs',
    format: 'esm'
  },
  plugins: [
    deno(),
    resolve(),
    json(),
    commonjs()
  ]
}

Support

Deno Node compatibility (https://deno.land/[email protected]/node/README.md):

  • assert
  • buffer
  • cli
  • crypto
  • events
  • fs
  • module
  • os
  • path
  • process
  • querystring
  • stream
  • `timers
  • tty
  • url
  • util

Extras: (see ./lib/extras)

Globals:

  • process
  • global (~> globalThis)
  • Buffer
  • Timers (setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate)

Related

License

MIT

About

Convert NodeJS to Deno compatible code with rollup

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 62.9%
  • JavaScript 37.1%