Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Convert NodeJS to Deno compatible code with rollup

Notifications You must be signed in to change notification settings

unjs/rollup-plugin-node-deno

Repository files navigation

rollup-plugin-node-deno

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-deno

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
  • assert/strict partly
  • async_hooks partly
  • buffer
  • child_process partly
  • cluster partly
  • console partly
  • constants partly
  • crypto partly
  • dgram partly
  • diagnostics_channel
  • dns partly
  • events
  • fs partly
  • fs/promises partly
  • http partly
  • http2
  • https partly
  • inspector partly
  • module
  • net
  • os partly
  • path
  • path/posix
  • path/win32
  • perf_hooks
  • process partly
  • punycode
  • querystring
  • readline
  • repl partly
  • stream
  • stream/promises
  • stream/web partly
  • string_decoder
  • sys
  • timers
  • timers/promises
  • tls
  • trace_events
  • tty partly
  • url
  • util partly
  • util/types partly
  • v8
  • vm partly
  • wasi
  • webcrypto
  • worker_threads
  • zlib

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

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •