Registry / devops / dr-transpiler

dr-transpiler

JSON →
library1.0.3jsnpmunverified

dr-transpiler is a JavaScript transpiler that replaces import statements with the actual imported code, effectively inlining dependencies. The current stable version is 1.0.3. It serves as a simple bundling alternative for small projects, performing static analysis to resolve local and npm imports. Unlike full-featured bundlers (Webpack, Rollup), it focuses solely on import replacement without tree-shaking or advanced optimizations.

npm install dr-transpiler
INSTALL
IMPORT
SIG · DR-TRANSPILER
D
dr-transpiler
devopsjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

transpile
import { transpile } from 'dr-transpiler'
const transpile = require('dr-transpiler')
Package is ESM-only; CommonJS require will not work.
default
import drt from 'dr-transpiler'; drt(code)
const drt = require('dr-transpiler').default
Default import is available but named import 'transpile' is preferred.
transpileFile
import { transpileFile } from 'dr-transpiler'
import { transpileFile } from 'dr-transpiler/transpileFile'
Subpath exports may not exist; use main export.

Shows how to transpile a string of code with a custom resolver to replace imports.

import { transpile } from 'dr-transpiler'; const code = ` import { add } from './math'; console.log(add(1, 2)); `; const result = transpile(code, { resolve: (specifier) => { if (specifier === './math') { return `export const add = (a, b) => a + b;`; } throw new Error('Cannot resolve ' + specifier); } }); console.log(result.code); // Output: "const add = (a, b) => a + b;\nconsole.log(add(1, 2));"
Debug
Known issues
gotchaOnly static import statements are replaced; dynamic import() is not supported.
fix
Avoid using dynamic imports or pre-process them.
affects: <=1.0.3
deprecatedThe resolve callback must return a string; no async support yet.
fix
Use synchronous resolution only or consider a bundler for async needs.
affects: <=1.0.3
gotchaFile system access is not provided; you must implement file resolution manually.
fix
Provide a resolve function that reads files or maps content.
affects: <=1.0.3
Errors
Common errors & fixes
Cannot find module 'dr-transpiler'
Package not installed or ESM-only and using require.
fix
Install with npm install dr-transpiler and use import syntax.
The 'resolve' function must return a string
Provided resolver returned undefined or non-string.
fix
Ensure resolve function returns a string (the source code) for every specifier.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
dr-transpiler — npm install dr-transpiler · libregistry