{"id":26349,"library":"runtime-compiler","title":"Runtime Compiler","description":"Universal compiler system for JavaScript code generation in multiple modes (default, build, hydrate). Version 3.2.0 is current stable. Ships TypeScript types. Key differentiator: build/hydrate mode separation for efficient asset compilation vs runtime hydration. Active development. Alternatives like Babel focus on transpilation, while runtime-compiler provides structured build-and-run orchestrations.","status":"active","version":"3.2.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install runtime-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add runtime-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add runtime-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Must be imported from 'runtime-compiler/config' subpath, not the main package.","wrong":"import { isHydrating } from 'runtime-compiler'","symbol":"isHydrating","correct":"import { isHydrating } from 'runtime-compiler/config'"},{"note":"Named export, not default. Using default import will result in undefined.","wrong":"import onlyBuild from 'runtime-compiler/config'","symbol":"onlyBuild","correct":"import { onlyBuild } from 'runtime-compiler/config'"},{"note":"Package is ESM-only. Use import syntax only.","wrong":"const compiler = require('runtime-compiler')","symbol":"runtime-compiler (default)","correct":"import compiler from 'runtime-compiler'"}],"quickstart":{"code":"import { isHydrating, onlyBuild } from 'runtime-compiler/config';\n\nif (isHydrating()) {\n  console.log('Running in hydrate mode - only executing, not building.');\n} else if (onlyBuild()) {\n  console.log('Running in build mode - only building, not executing.');\n} else {\n  console.log('Running in default mode - building and executing.');\n}\n\n// Example with compiler mode\nimport compiler from 'runtime-compiler';\nconst result = compiler.compile('someSourceCode');\nconsole.log(result);","lang":"typescript","description":"Shows how to import and use the config utility functions (isHydrating, onlyBuild) to determine the current compiler mode, and a basic compile example."},"warnings":[{"fix":"Change import from 'import config from 'runtime-compiler/config' to 'import { isHydrating, onlyBuild } from 'runtime-compiler/config'","message":"Version 3.0 changed the config exports from default to named. Previously exported as default object, now must destructure.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Invoke as functions: if (isHydrating()) instead of if (isHydrating)","message":"isHydrating and onlyBuild are functions, not boolean constants. Directly using them as booleans will always be truthy.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use isHydrating() or onlyBuild() from 'runtime-compiler/config' instead of checking process.env.COMPILER_MODE","message":"The 'build' and 'hydrate' mode literals are deprecated in favor of the config functions. Using string comparisons may break in future versions.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Always use the config functions to avoid undefined behavior.","message":"In Node.js ESM, top-level process.env checks for mode are not available until import phase; the config functions are safe alternatives.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to runtime-compiler@>=3.0.0 or import from the main package: import { isHydrating, onlyBuild } from 'runtime-compiler' (if available in your version).","cause":"Using an older version of the package that does not have the config subpath export.","error":"Error: Cannot find module 'runtime-compiler/config'"},{"fix":"Change to if (isHydrating()) to invoke the function.","cause":"Using isHydrating as a boolean (e.g., if (isHydrating)) instead of calling it as a function.","error":"TypeError: isHydrating is not a function"},{"fix":"Use named import: import { compile } from 'runtime-compiler' instead of import compiler from 'runtime-compiler'.","cause":"Trying to import a default export when only named exports are available in that version.","error":"SyntaxError: The requested module 'runtime-compiler' does not provide an export named 'default'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}