Registry / devops / brfs-babel

brfs-babel

JSON →
library2.0.0jsnpmunverified

A browserify transform that inlines static file contents at build time, similar to brfs but built on top of Babel for ES2015+ support. Version 2.0.0 is the current stable release. It handles ES2015 import syntax, supports fs.readFileSync and fs.readdirSync, and evaluates path.join/path.resolve statically. Unlike brfs, it works with Babel AST for cleaner output and source maps, but is experimental and has limitations (e.g., no support for dynamic expressions or inline CommonJS require).

npm install brfs-babel
INSTALL
IMPORT
SIG · BRFS-BABEL
B
brfs-babel
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Shows basic usage of brfs-babel with browserify and ES2015 import syntax.

// Install: npm install brfs-babel // In your browserify build command: // browserify index.js -t brfs-babel // Example file: index.js import { readFileSync } from 'fs'; import { join } from 'path'; const src = readFileSync(join(__dirname, 'hello.txt'), 'utf8'); console.log(src); // With hello.txt containing "Hello, World!", after transform: // import { join } from 'path'; // const src = 'Hello, World!'; // console.log(src);
Debug
Known issues
gotchaOnly fs.readFileSync and fs.readdirSync are supported, not fs.writeFileSync or fs.statSync.
fix
Use brfs for more fs methods or implement custom transform.
affects: >=0.0.0
gotchaDynamic expressions (e.g., __dirname + variable) are not evaluated statically, causing runtime errors.
fix
Use only static string paths with path.join or path.resolve.
affects: >=0.0.0
gotchaInline CommonJS require('fs').readFileSync is not supported; only imported fs works.
fix
Use ES2015 import syntax for fs.
affects: >=0.0.0
deprecatedPackage is experimental and no longer actively maintained. brfs is more stable and widely used.
fix
Consider using brfs or browserify-plugin-fs for production.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'brfs-babel'
brfs-babel not installed globally or locally.
fix
Run `npm install --save-dev brfs-babel` in project directory.
fs.readFileSync(...): path must be a string or Buffer
Dynamic variable used in file path that brfs-babel cannot evaluate.
fix
Use static path like path.join(__dirname, 'file.txt').
Error: Could not transform: ...
brfs-babel encountered unsupported syntax like require('fs').readFileSync.
fix
Use ES2015 import { readFileSync } from 'fs' instead.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
@babel/corerequiredBabel AST manipulation for transform
static-modulerequiredUsed internally for static evaluation of file reads
Agent activity
4 hits · last 30 days
node
4
Resources
brfs-babel — npm install brfs-babel · libregistry