Registry / devops / traceur

traceur

JSON →
library0.0.111jsnpmunverified

Traceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to use ES6 and experimental ES.next features by transpiling them to ES5. Version 0.0.111 is the latest stable release. It was developed by Google to inform the design of new JavaScript features and supports a wide range of proposals including async functions, generators, spread properties, and JSX. It provides both CommonJS and browser builds. Traceur is now largely superseded by Babel, but remains useful for legacy projects or understanding early transpiler design.

npm install traceur
INSTALL
IMPORT
SIG · TRACEUR
T
traceur
devopsjavascriptv0.0.111
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.

traceur
const traceur = require('traceur');
import traceur from 'traceur';
Traceur uses CommonJS. ESM import may fail in Node < 13 or without proper configuration.
compile
const { compile } = require('traceur');
const compile = require('traceur').compile;
Deprecated: access via destructuring is preferred since 0.0.108.
TraceurCompiler
const { Compiler } = require('traceur/dist/commonjs/Compiler');
const Compiler = require('traceur').Compiler;
The Compiler class is not exported from the main entry point; it must be imported from the specific module path.

Compiles an ES6 file to CommonJS with error handling and optional source maps.

const traceur = require('traceur'); const fs = require('fs'); const code = fs.readFileSync('example.es6', 'utf8'); try { const result = traceur.compile(code, { sourceMaps: false, modules: 'commonjs' }); if (result.errors && result.errors.length) { console.error('Errors:', result.errors); } else { console.log(result.js); if (result.sourceMap) { console.log('Source map generated'); } } } catch (e) { console.error('Compilation failed:', e); }
traceur --version
Debug
Known issues
breakingThe Compiler class is no longer exported from the main 'traceur' module. Import it from 'traceur/dist/commonjs/Compiler' instead.
fix
Change import from require('traceur').Compiler to require('traceur/dist/commonjs/Compiler').Compiler
affects: >=0.0.108
deprecatedThe `compile` function exported from the main module is deprecated in favor of using the Compiler class.
fix
Use Compiler instance: new Compiler().compile()
affects: >=0.0.108
gotchaWhen using the command-line tool, you must install Traceur globally or use npx. The bin/traceur file may have a shebang issue on Windows.
fix
Use `npx traceur` or install globally: `npm install -g traceur`
affects: >=0.0.100
breakingIn version 0.0.108, runtime modules were moved into individual modules under 'traceur/dist/commonjs/runtime/modules/'. Requiring the full runtime is no longer sufficient.
fix
Import specific runtime modules as needed, e.g., require('traceur/dist/commonjs/runtime/modules/call.js')
affects: >=0.0.108
deprecatedThe `--experimental` flag has been deprecated and may not work as expected in recent versions.
fix
Use specific feature flags like `--async-functions` instead.
affects: >=0.0.109
gotchaNode.js must be >=0.10 (engines field). Using Traceur with very old Node <0.10 will fail.
fix
Update Node.js to >=0.10 or use an older version of Traceur.
affects: <0.0.109
Errors
Common errors & fixes
Cannot find module 'traceur/dist/commonjs/Compiler'
The Compiler module was restructured in 0.0.108 and is no longer at the old path.
fix
Use: const { Compiler } = require('traceur/dist/commonjs/Compiler');
TypeError: traceur.compile is not a function
The compile function is deprecated and not exported as a standalone function in some versions.
fix
Use the Compiler class or ensure you are using a version that exports compile (e.g., <0.0.108).
ReferenceError: require is not defined
Trying to use Traceur in a browser environment without a bundler.
fix
Use the browser build: <script src='node_modules/traceur/bin/traceur.js'></script>
Error: Cannot find module 'glob'
Missing optional dependency 'glob' which is required for some internal operations.
fix
Install 'glob' as a dependency: npm install glob
Upgrade
Version history
0.0.111latest on npm
Audit
Dependencies
globoptionalUsed internally for file matching in the compiler's node API, but not a direct user dependency.
semveroptionalUsed to check Node.js version compatibility in the executable.
Agent activity
4 hits · last 30 days
node
4
Resources