Registry / web-framework / rscute

rscute

JSON →
library1.2.2jsnpmunverified

rscute is an in-memory TypeScript bundler and executor, leveraging `@swc/core` for high-performance AST transformation and compilation. Currently at stable version 1.2.2, it exhibits an active release cadence with frequent updates. Its core functionality involves intercepting Node.js `require` calls, recursively resolving TypeScript and JavaScript dependencies, and evaluating them as a single, flattened bundle entirely within memory. Key differentiators include its transparent runtime execution capabilities for TypeScript files, a dedicated API for in-memory bundling without execution, and automatic symbol mangling to prevent name collisions in the flattened module scope. It supports various entry points, including a CLI, a Node.js `-r` flag hook, and dedicated programmatic APIs for code execution in a sandboxed VM context or for bundling to a string.

npm install rscute
INSTALL
IMPORT
SIG · RSCUTE
R
rscute
web-frameworkjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

register
const { register } = require('rscute/register');
import { register } from 'rscute/register';
The `register` function is specifically designed for CommonJS environments as a Node.js runtime hook, typically used with `node -r` or directly via `require()`.
execute
import { execute } from 'rscute/vm';
const { execute } = require('rscute/vm');
The `execute` API, introduced in v1.1.0, is primarily intended for use in ESM contexts to compile and run code in a VM sandbox.
bundle
import { bundle } from 'rscute/bundle';
const { bundle } = require('rscute/bundle');
The `bundle` API was introduced in v1.2.0 for programmatic in-memory bundling and is designed for ESM module usage.

This example demonstrates how to use `rscute` programmatically to first bundle a TypeScript file and its dependencies into a single JavaScript string, and then execute that bundled string within an isolated Node.js `vm.Context` to access its exports. It highlights `rscute`'s capabilities for both in-memory compilation and runtime execution.

import { bundle } from 'rscute/bundle'; import { execute } from 'rscute/vm'; import path from 'path'; import fs from 'fs'; // Create a temporary script.ts for the example const tempScriptContent = ` export const getMessage = (name: string): string => { return \`Hello, \${name} from bundled code!\`; }; export const someValue = 42; `; const tempScriptPath = path.resolve(__dirname, 'temp-script.ts'); fs.writeFileSync(tempScriptPath, tempScriptContent); try { // 1. Bundle the TypeScript file into a single JavaScript string console.log('Bundling temp-script.ts...'); const bundledCode = bundle(tempScriptPath); console.log('\n--- Bundled Code (truncated) ---'); console.log(bundledCode.substring(0, 200) + '...'); // 2. Execute the bundled code in a VM context console.log('\nExecuting bundled code in VM...'); const moduleExports = execute(bundledCode); // 3. Use the exports from the executed code if (moduleExports && typeof moduleExports.getMessage === 'function') { console.log(`Result from executed bundle: ${moduleExports.getMessage('rscute user')}`); console.log(`Exported value: ${moduleExports.someValue}`); } else { console.error('Failed to get expected exports from bundled code.'); } } catch (error) { console.error('An error occurred:', error); } finally { // Clean up the temporary file fs.unlinkSync(tempScriptPath); }
rscute --version
Debug
Known issues
breakingVersion 1.2.0 introduced a major architectural refactoring, cleanly separating the core AST engine from execution environments. While new APIs (`rscute/bundle`) were added, this change may affect applications relying on older undocumented programmatic interfaces or internal structures.
fix
Review release notes for `v1.2.0` and update programmatic usage to leverage the new `rscute/bundle` API or `rscute/vm` module as demonstrated in the documentation.
affects: >=1.2.0
breakingVersion 1.0.0 replaced regular expression processing with full AST parsing. While this generally improves accuracy and robustness, it might introduce subtle breaking changes for projects with highly specific or unusual TypeScript syntax that was implicitly handled (or mishandled) by the previous regex-based approach.
fix
Thoroughly test your codebase after upgrading to `v1.0.0` or later, especially if using complex or experimental TypeScript features. Report any regressions to the `rscute` maintainers.
affects: >=1.0.0
gotchaWhen using `pnpm` as your package manager, direct `npx rscute` commands may not work as expected due to how `npx` resolves packages with `pnpm`.
fix
Use `pnpm exec rscute` instead of `npx rscute` for running CLI commands with pnpm.
affects: >=0.0.0
breakingVersion 1.2.2 removed `baseUrl` logic for TS6. This change might impact projects that rely on specific `baseUrl` configurations within their `tsconfig.json` for module resolution, potentially leading to "Cannot find module" errors.
fix
Ensure your module resolution paths are explicit or adjust your project's import statements if they were implicitly relying on `baseUrl` behavior removed in `rscute@1.2.2`. Consider using `paths` mapping in `tsconfig.json` for explicit resolution.
affects: >=1.2.2
gotcha`rscute` provides both CommonJS (`rscute/register`) and ESM-focused (`rscute/vm`, `rscute/bundle`) APIs. Mixing `require()` for ESM-only modules or `import` for CommonJS-only modules will lead to errors.
fix
Use `require('rscute/register')` for the CommonJS hook. Use `import { ... } from 'rscute/vm'` or `rscute/bundle` within an ESM module context (e.g., `"type": "module"` in `package.json` or `.mjs` files).
affects: >=1.2.0
breakingVersion 1.1.5 included a "supply-chain security update" and enabled npm provenance. While specific details were not provided, users on older versions should upgrade to `>=1.1.5` to ensure they receive critical security patches related to the package's integrity.
fix
Upgrade to `rscute@1.1.5` or newer immediately to benefit from security improvements.
affects: <1.1.5
Errors
Common errors & fixes
Error: Cannot find module 'some-module' from 'path/to/file.ts'
`rscute` could not resolve an imported module's path, possibly due to incorrect `baseUrl` settings (especially after v1.2.2), missing `node_modules` entry, or incorrect relative paths.
fix
Verify the module path is correct relative to the importing file or `filePath` option. Ensure dependencies are installed. If using `baseUrl`, review your `tsconfig.json` and module resolution after `rscute@1.2.2`.
TypeError: register is not a function
Attempting to use `import { register } from 'rscute/register'` in an ESM context, or trying to access `register` without destructuring in CommonJS.
fix
For CommonJS, ensure `const { register } = require('rscute/register');` is used. The `register` API is primarily a CommonJS hook.
SyntaxError: Cannot use import statement outside a module
Running a file with `import` statements (e.g., `rscute/vm` or `rscute/bundle` APIs) in a Node.js environment configured for CommonJS.
fix
Ensure your Node.js project is configured for ESM by setting `"type": "module"` in `package.json` or by using `.mjs` file extensions for files containing `import` statements.
ReferenceError: require is not defined
Attempting to use `require()` within an ESM module context (e.g., a file with `import`s or a `.mjs` file).
fix
Replace `require()` calls with `import` statements where appropriate, or ensure you are in a CommonJS context if `require()` is necessary.
SWC compilation error: [specific SWC error message]
An error occurred during the SWC transformation process, often due to invalid TypeScript syntax, unsupported language features, or configuration issues.
fix
Review the specific SWC error message for details. Check your TypeScript code for syntax errors. Ensure `@swc/core` is up-to-date and compatible with your Node.js version.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
@swc/corerequiredCore dependency for high-performance TypeScript compilation and AST transformation.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rscute — npm install rscute · libregistry