{"id":26499,"library":"traceur","title":"Traceur Compiler","description":"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.","status":"maintenance","version":"0.0.111","language":"javascript","source_language":"en","source_url":"https://github.com/google/traceur-compiler","tags":["javascript","ecmascript","language","es5","es6","ES.next","harmony","compiler"],"install":[{"cmd":"npm install traceur","lang":"bash","label":"npm"},{"cmd":"yarn add traceur","lang":"bash","label":"yarn"},{"cmd":"pnpm add traceur","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for file matching in the compiler's node API, but not a direct user dependency.","package":"glob","optional":true},{"reason":"Used to check Node.js version compatibility in the executable.","package":"semver","optional":true}],"imports":[{"note":"Traceur uses CommonJS. ESM import may fail in Node < 13 or without proper configuration.","wrong":"import traceur from 'traceur';","symbol":"traceur","correct":"const traceur = require('traceur');"},{"note":"Deprecated: access via destructuring is preferred since 0.0.108.","wrong":"const compile = require('traceur').compile;","symbol":"compile","correct":"const { compile } = require('traceur');"},{"note":"The Compiler class is not exported from the main entry point; it must be imported from the specific module path.","wrong":"const Compiler = require('traceur').Compiler;","symbol":"TraceurCompiler","correct":"const { Compiler } = require('traceur/dist/commonjs/Compiler');"}],"quickstart":{"code":"const traceur = require('traceur');\nconst fs = require('fs');\n\nconst code = fs.readFileSync('example.es6', 'utf8');\ntry {\n  const result = traceur.compile(code, {\n    sourceMaps: false,\n    modules: 'commonjs'\n  });\n  if (result.errors && result.errors.length) {\n    console.error('Errors:', result.errors);\n  } else {\n    console.log(result.js);\n    if (result.sourceMap) {\n      console.log('Source map generated');\n    }\n  }\n} catch (e) {\n  console.error('Compilation failed:', e);\n}","lang":"javascript","description":"Compiles an ES6 file to CommonJS with error handling and optional source maps."},"warnings":[{"fix":"Change import from require('traceur').Compiler to require('traceur/dist/commonjs/Compiler').Compiler","message":"The Compiler class is no longer exported from the main 'traceur' module. Import it from 'traceur/dist/commonjs/Compiler' instead.","severity":"breaking","affected_versions":">=0.0.108"},{"fix":"Use Compiler instance: new Compiler().compile()","message":"The `compile` function exported from the main module is deprecated in favor of using the Compiler class.","severity":"deprecated","affected_versions":">=0.0.108"},{"fix":"Use `npx traceur` or install globally: `npm install -g traceur`","message":"When using the command-line tool, you must install Traceur globally or use npx. The bin/traceur file may have a shebang issue on Windows.","severity":"gotcha","affected_versions":">=0.0.100"},{"fix":"Import specific runtime modules as needed, e.g., require('traceur/dist/commonjs/runtime/modules/call.js')","message":"In 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.","severity":"breaking","affected_versions":">=0.0.108"},{"fix":"Use specific feature flags like `--async-functions` instead.","message":"The `--experimental` flag has been deprecated and may not work as expected in recent versions.","severity":"deprecated","affected_versions":">=0.0.109"},{"fix":"Update Node.js to >=0.10 or use an older version of Traceur.","message":"Node.js must be >=0.10 (engines field). Using Traceur with very old Node <0.10 will fail.","severity":"gotcha","affected_versions":"<0.0.109"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: const { Compiler } = require('traceur/dist/commonjs/Compiler');","cause":"The Compiler module was restructured in 0.0.108 and is no longer at the old path.","error":"Cannot find module 'traceur/dist/commonjs/Compiler'"},{"fix":"Use the Compiler class or ensure you are using a version that exports compile (e.g., <0.0.108).","cause":"The compile function is deprecated and not exported as a standalone function in some versions.","error":"TypeError: traceur.compile is not a function"},{"fix":"Use the browser build: <script src='node_modules/traceur/bin/traceur.js'></script>","cause":"Trying to use Traceur in a browser environment without a bundler.","error":"ReferenceError: require is not defined"},{"fix":"Install 'glob' as a dependency: npm install glob","cause":"Missing optional dependency 'glob' which is required for some internal operations.","error":"Error: Cannot find module 'glob'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}