Registry / serialization / runtime-compiler

runtime-compiler

JSON →
library3.2.0jsnpmunverified

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.

npm install runtime-compiler
INSTALL
IMPORT
SIG · RUNTIME-COMPILER
R
runtime-compiler
serializationjavascriptv3.2.0
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.

isHydrating
import { isHydrating } from 'runtime-compiler/config'
import { isHydrating } from 'runtime-compiler'
Must be imported from 'runtime-compiler/config' subpath, not the main package.
onlyBuild
import { onlyBuild } from 'runtime-compiler/config'
import onlyBuild from 'runtime-compiler/config'
Named export, not default. Using default import will result in undefined.
runtime-compiler (default)
import compiler from 'runtime-compiler'
const compiler = require('runtime-compiler')
Package is ESM-only. Use import syntax only.

Shows how to import and use the config utility functions (isHydrating, onlyBuild) to determine the current compiler mode, and a basic compile example.

import { isHydrating, onlyBuild } from 'runtime-compiler/config'; if (isHydrating()) { console.log('Running in hydrate mode - only executing, not building.'); } else if (onlyBuild()) { console.log('Running in build mode - only building, not executing.'); } else { console.log('Running in default mode - building and executing.'); } // Example with compiler mode import compiler from 'runtime-compiler'; const result = compiler.compile('someSourceCode'); console.log(result);
Debug
Known issues
breakingVersion 3.0 changed the config exports from default to named. Previously exported as default object, now must destructure.
fix
Change import from 'import config from 'runtime-compiler/config' to 'import { isHydrating, onlyBuild } from 'runtime-compiler/config'
affects: >=3.0.0
gotchaisHydrating and onlyBuild are functions, not boolean constants. Directly using them as booleans will always be truthy.
fix
Invoke as functions: if (isHydrating()) instead of if (isHydrating)
affects: >=1.0.0
deprecatedThe 'build' and 'hydrate' mode literals are deprecated in favor of the config functions. Using string comparisons may break in future versions.
fix
Use isHydrating() or onlyBuild() from 'runtime-compiler/config' instead of checking process.env.COMPILER_MODE
affects: >=3.0.0
gotchaIn Node.js ESM, top-level process.env checks for mode are not available until import phase; the config functions are safe alternatives.
fix
Always use the config functions to avoid undefined behavior.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'runtime-compiler/config'
Using an older version of the package that does not have the config subpath export.
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).
TypeError: isHydrating is not a function
Using isHydrating as a boolean (e.g., if (isHydrating)) instead of calling it as a function.
fix
Change to if (isHydrating()) to invoke the function.
SyntaxError: The requested module 'runtime-compiler' does not provide an export named 'default'
Trying to import a default export when only named exports are available in that version.
fix
Use named import: import { compile } from 'runtime-compiler' instead of import compiler from 'runtime-compiler'.
Upgrade
Version history
3.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Bingbot
1
Resources
runtime-compiler — npm install runtime-compiler · libregistry