Registry / http-networking / react-native-hardwired-transpiler

react-native-hardwired-transpiler

JSON →
library0.10.1jsnpmunverified

A transpiler module for the react-native-hardwired ecosystem that transforms ES6+ JavaScript code into a format compatible with Hardwired's dynamic module loading in React Native. This package is part of the Hardwired library enabling runtime code transformation and execution. Version 0.10.1 is the current stable release. It is designed specifically for React Native environments and relies on Babel for transpilation. Differentiates from other transpilers by tight integration with Hardwired's dynamic loading system.

npm install react-native-hardwired-transpiler
INSTALL
IMPORT
SIG · REACT-NATIVE-HARDW
R
react-native-hardwired-transpiler
http-networkingjavascriptv0.10.1
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 'react-native-hardwired-transpiler'
const transpile = require('react-native-hardwired-transpiler').transpile
ESM-only; CommonJS require may lead to 'exports is not defined' errors.
HardwiredTranspiler
import HardwiredTranspiler from 'react-native-hardwired-transpiler'
import { HardwiredTranspiler } from 'react-native-hardwired-transpiler'
Default export is a class; named import will be undefined.
TranspilerOptions
import type { TranspilerOptions } from 'react-native-hardwired-transpiler'
import { TranspilerOptions } from 'react-native-hardwired-transpiler'
TypeScript only; importing as value will fail at runtime.

Shows how to transpile ES6 code and register it with Hardwired's dynamic module loader.

import { transpile } from 'react-native-hardwired-transpiler'; import { HardwiredRegistry } from 'react-native-hardwired'; const code = `export default () => { return 'Hello from Hardwired!'; }`; const options = { filename: 'dynamic.js', presets: ['@babel/preset-env'] }; transpile(code, options).then(result => { HardwiredRegistry.register('dynamic', result.code); const module = HardwiredRegistry.load('dynamic'); console.log(module.default()); // 'Hello from Hardwired!' }).catch(err => console.error(err));
Debug
Known issues
breakingThe transpile() function now returns a Promise instead of a synchronous result. Code using .code directly will break.
fix
Use async/await or .then() to access the result.
affects: >=0.8.0
deprecatedThe 'options' parameter no longer accepts 'sourceMaps' as a boolean; use 'sourceMaps: false' or omit.
fix
Remove sourceMaps or set to an explicit object.
affects: >=0.9.0
gotchaThe transpiler requires @babel/core to be installed as a peer dependency. Missing it causes cryptic 'Cannot find module' errors.
fix
Run 'npm install @babel/core'.
affects: all
gotchaUsing transpile() in React Native's Hermes engine may fail due to missing global objects. Transpiled code should avoid certain ES6 features.
fix
Add 'useBuiltIns: false' to options or avoid importing large polyfills.
affects: all
deprecatedThe default export HardwiredTranspiler class is deprecated in favor of the named transpile function.
fix
Switch to import { transpile } from 'react-native-hardwired-transpiler'.
affects: >=0.10.0
Errors
Common errors & fixes
TypeError: (0 , _transpiler.transpile) is not a function
Using CommonJS require() on an ES module default export.
fix
Use import { transpile } from 'react-native-hardwired-transpiler'.
Error: Cannot find module '@babel/core'
Missing peer dependency @babel/core.
fix
Run 'npm install @babel/core'.
TypeError: Cannot read property 'code' of undefined
Calling transpile() without awaiting the promise (result is undefined).
fix
Use await transpile(code, options) or .then(result => { ... }).
SyntaxError: Unexpected token (1:0) in file 'dynamic.js'
Transpiled code contains syntax that is not supported by Hermes or React Native's JavaScript engine.
fix
Add a Babel preset like '@babel/preset-env' with modules: false and appropriate targets.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
@babel/corerequiredUsed for transpiling ES6+ code to a format compatible with Hardwired's dynamic module loading.
@babel/preset-envrequiredProvides preset configurations for Babel transpilation targeting specific environments.
react-native-hardwiredrequiredCore library that this transpiler works with for dynamic module loading.
Agent activity
2 hits · last 30 days
node
2
Resources
react-native-hardwired-transpiler — npm install react-native-hardwired-transpiler · libregistry