Converts a Redis Lua script into a Node.js module string (CommonJS or ESM) that exports the script's name, key count, and Lua source. Version 6.0.0 supports both CJS and ESM output types. It is a build-time tool meant to integrate with Gulp or hook-based loaders, not for direct runtime use. Compared to alternatives like manually loading Lua files, it automates extracting metadata from Lua comments and provides a standard interface compatible with ioredis. Release cadence is low; last major version dropped support for older Node.js (requires >=20).
npm install redis-lua2jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to convert a Lua script into a module, load it with ioredis, and run a command.
Use import lua2js from 'redis-lua2js' instead of require().
Update Node.js to version 20 or later.
Explicitly set type: 'module' if you want ESM output, or type: 'commonjs' to maintain current behavior.
Ensure Lua script contains comments: -- name <commandname> and -- nkeys <number> if not providing options.
Use requireFromString from 'module-from-string' or compile with Node's vm module.
Switch to dynamic import() or ensure your project is configured for ESM (e.g., type: 'module' in package.json).
Move 'redis-lua2js' from devDependencies to dependencies, or use it only in build scripts.
Use type: 'commonjs' in options or use dynamic import for the generated module.
No dependency data recorded yet.