Registry / web-framework / fbjs
library3.0.5jsnpmunverified

FBJS (Facebook JavaScript) is a collection of utility libraries developed by Facebook primarily for internal consumption within their JavaScript projects, such as React and Relay. Currently at version 3.0.5, this package does not follow strict semantic versioning and APIs may change or disappear without public notice. It is explicitly not designed for broader public use, and external projects consuming it should anticipate instability and a lack of support. Its core purpose is to facilitate code sharing across Facebook's internal monorepo, leveraging a custom `@providesModule` system that is transformed into CommonJS `require('fbjs/lib/moduleName')` paths during a build step. There is no stated public release cadence, as its releases are tied directly to Facebook's internal development needs.

npm install fbjs
INSTALL
IMPORT
SIG · FBJS
F
fbjs
web-frameworkjavascriptv3.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

emptyFunction
const emptyFunction = require('fbjs/lib/emptyFunction');
import { emptyFunction } from 'fbjs/lib/emptyFunction';
FBJS primarily ships as CommonJS. The `import` syntax will typically fail without specific build tooling or will result in incorrect interop behavior. Always use `require` for FBJS utilities.
warning
const warning = require('fbjs/lib/warning');
import warning from 'fbjs/lib/warning';
The `warning` utility is a named export within its module. Attempting a default import or incorrect named ESM import will fail.
invariant
const invariant = require('fbjs/lib/invariant');
import { invariant } from 'fbjs';
Like other FBJS utilities, `invariant` is a CommonJS module exported from a specific path. The root `fbjs` package does not directly export these utilities.

Demonstrates direct CommonJS `require` usage of core FBJS utilities like `emptyFunction`, `warning`, `invariant`, and `identity`, illustrating their typical functionality.

// This example demonstrates direct CommonJS usage of FBJS utilities. // Note: FBJS is primarily intended for internal Facebook projects and // is not guaranteed to follow semver or provide stable public APIs. const emptyFunction = require('fbjs/lib/emptyFunction'); const warning = require('fbjs/lib/warning'); const invariant = require('fbjs/lib/invariant'); const identity = require('fbjs/lib/identity'); console.log('Calling emptyFunction:', emptyFunction()); // Should print undefined let shouldWarn = true; warning( !shouldWarn, // Condition for warning to trigger (true means no warning, false means warning) 'This is a development warning from FBJS. Condition was %s.', // Message shouldWarn // Args for message formatting ); // invariant example (will throw if condition is false) try { const value = null; invariant(value != null, 'Value must not be null or undefined.'); console.log('Value is:', value); } catch (e) { console.error('Invariant failed:', e.message); } console.log('Identity of 123 is:', identity(123)); // Should print 123
Debug
Known issues
breakingFBJS is not intended for public consumption and does not adhere to semantic versioning (semver). APIs may change, break, or be removed without notice, leading to frequent breaking changes in patch or minor versions.
fix
Avoid using FBJS directly in non-Facebook projects. If absolutely necessary, pin exact versions and be prepared for frequent manual updates and compatibility checks.
affects: >=1.0.0
gotchaOfficial support and feature requests for FBJS are limited to internal Facebook projects. External projects will not receive support for issues or new features.
fix
Consider implementing similar utilities yourself or finding widely-supported alternatives if you require external support or stable APIs.
affects: >=1.0.0
gotchaFBJS heavily relies on a custom `@providesModule` system and Babel transforms (like `babel-preset/plugins/rewrite-modules.js`) to resolve module paths. Without this specific build setup, direct `require()` calls to relative paths like `emptyFunction` will fail.
fix
Ensure your build system correctly applies the FBJS Babel transforms, or explicitly `require('fbjs/lib/moduleName')` for specific utilities. However, direct external usage is strongly discouraged.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'emptyFunction'
Your build system is not configured to resolve `@providesModule` references from FBJS, or you are trying to use a non-existent module.
fix
Ensure your Babel configuration includes the FBJS `rewrite-modules` plugin, or explicitly `require('fbjs/lib/emptyFunction')`. However, external use is not recommended.
TypeError: (0 , _warning.default) is not a function
Attempting to use a named export (like `warning`) as a default import in an ESM context, or incorrect interop with CommonJS modules.
fix
Use CommonJS `const warning = require('fbjs/lib/warning');` pattern, as FBJS primarily ships as CommonJS. Avoid ESM imports unless specifically compiled to work with FBJS.
Invariant Violation: Value must not be null or undefined.
An `invariant` check failed, meaning a critical condition expected by the FBJS utility (or the calling code) was not met.
fix
Review the conditions leading to the invariant call and ensure all preconditions for the operation are satisfied before calling the FBJS utility.
Upgrade
Version history
3.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fbjs — npm install fbjs · libregistry