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.
# npm
npm install rollup-plugin-node-deno
# yarn
yarn add rollup-plugin-node-deno
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()
]
}
Deno Node compatibility (https://deno.land/[email protected]/node/README.md):
assert
assert/strict
partlyasync_hooks
partlybuffer
child_process
partlycluster
partlyconsole
partlyconstants
partlycrypto
partlydgram
partlydiagnostics_channel
dns
partlyevents
fs
partlyfs/promises
partlyhttp
partlyhttp2
https
partlyinspector
partlymodule
net
os
partlypath
path/posix
path/win32
perf_hooks
process
partlypunycode
querystring
readline
repl
partlystream
stream/promises
stream/web
partlystring_decoder
sys
timers
timers/promises
tls
trace_events
tty
partlyurl
util
partlyutil/types
partlyv8
vm
partlywasi
webcrypto
worker_threads
zlib
Extras: (see ./lib/extras)
node-fetch
(using nativefetch
)chalk
(using deno.land/x/chalk_deno)
Globals:
process
global
(~>globalThis
)Buffer
- Timers (
setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate
)
MIT