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 rscuteVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
Use `pnpm exec rscute` instead of `npx rscute` for running CLI commands with pnpm.
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.
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).Upgrade to `rscute@1.1.5` or newer immediately to benefit from security improvements.
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`.
For CommonJS, ensure `const { register } = require('rscute/register');` is used. The `register` API is primarily a CommonJS hook.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.
Replace `require()` calls with `import` statements where appropriate, or ensure you are in a CommonJS context if `require()` is necessary.
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.