transquire

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript abandoned

A require replacement and hook to automatically transpiler module source at runtime. Current stable version 0.0.1. This package provides a mechanism to automatically transpile ES6 or other source code during require() calls by replacing or hooking Node.js's module loading. It is designed for development or sandboxed environments where pre-compilation is not desired. Differentiates from Babel/register by being a more generic hook for transpilers. No active development since 2015.

error Cannot find module 'transquire'
cause Package not installed or missing from node_modules.
fix
Run 'npm install transquire' with the correct registry.
error transquire is not a function
cause Import style mismatch; using default import when not configured.
fix
Ensure you imported with 'import transquire from 'transquire'' or use 'const transquire = require('transquire').default'.
gotcha Package is abandoned (last publish 9+ years ago). Not recommended for use in new projects.
fix Use modern alternatives like @babel/register or ts-node for TypeScript.
gotcha No TypeScript definitions available; usage in TypeScript projects is unsupported.
fix Write custom type declarations if needed, but consider alternative packages.
npm install transquire
yarn add transquire
pnpm add transquire

Shows how to replace require with a transpiling version using transquire.

// Install: npm install transquire
// Then in your code (ESM or CJS):
import transquire from 'transquire';
// Replace require with transpiling version
const originalRequire = require;
require = transquire(require, {
  // transpiler options
  // e.g., for ES6
  extensions: ['.es6', '.js'],
  transform: (code, filename) => {
    // use babel or other transpiler
    return code;
  }
});
// Now require will handle transpilation
const module = require('./some.es6');