556 sao GitHub và vẫn tăng — browserify/brfs là dự án JavaScript mà TopGit đang theo dõi trên nền tảng. browserify fs.readFileSync() static asset inliner
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
fs.readFileSync() and fs.readFile() static asset browserify transform
This module is a plugin for browserify to parse the AST
for fs.readFileSync() calls so that you can inline file contents into your
bundles.
Even though this module is intended for use with browserify, nothing about it is
particularly specific to browserify so it should be generally useful in other
projects.
example
for a main.js:
var fs = require('fs');
var html = fs.readFileSync(__dirname + '/robot.html', 'utf8');
console.log(html);
and a robot.html:
<b>beep boop</b>
first npm install brfs into your project, then:
on the command-line
$ browserify -t brfs example/main.js > bundle.js
now in the bundle output file,
var html = fs.readFileSync(__dirname + '/robot.html', 'utf8');
turns into:
var html = "<b>beep boop</b>\n";
or with the api
var browserify = require('browserify');
var fs = require('fs');
var b = browserify('example/main.js');
b.transform('brfs');
b.bundle().pipe(fs.createWriteStream('bundle.js'));
async
You can also use fs.readFile():
var fs = require('fs');
fs.readFile(__dirname + '/robot.html', 'utf8', function (err, html) {
console.log(html);
});
When you run this code through brfs, it turns into:
Inside of each pathExpr, you can use
statically analyzable expressions and
these variables and functions:
__dirname
__filename
path if you var path = require('path') first
require.resolve()
Just like node, the default encoding is null and will give back a Buffer.
If you want differently-encoded file contents for your inline content you can
set enc to 'utf8', 'base64', or 'hex'.
In async mode when a callback cb is given, the contents of pathExpr are
inlined into the source inside of a process.nextTick() call.
When you use a 'file'-event aware watcher such as
watchify, the inlined assets will be
updated automatically.
If you want to use this plugin directly, not through browserify, the api
follows.
var brfs = require('brfs')
var tr = brfs(file, opts)
Return a through stream tr inlining fs.readFileSync() file contents
in-place.
Optionally, you can set which opts.vars will be used in the
static argument evaluation
in addition to __dirname and __filename.
opts.parserOpts can be used to configure the parser brfs uses,
acorn.
events
tr.on('file', function (file) {})
For every file included with fs.readFileSync() or fs.readFile(), the tr
instance emits a 'file' event with the file path.
usage
A tiny command-line program ships with this module to make debugging easier.
usage:
brfs file
Inline `fs.readFileSync()` calls from `file`, printing the transformed file
contents to stdout.
brfs
brfs -
Inline `fs.readFileSync()` calls from stdin, printing the transformed file
contents to stdout.
install
With npm do:
npm install brfs
then use -t brfs with the browserify command or use .transform('brfs') from
the browserify api.
gotchas
Since brfs evaluates your source code statically, you can't use dynamic expressions that need to be evaluated at run time. For example:
// WILL NOT WORK!
var file = window.someFilePath;
var str = require('fs').readFileSync(file, 'utf8');
Instead, you must use simpler expressions that can be resolved at build-time:
var str = require('fs').readFileSync(__dirname + '/file.txt', 'utf8');
Another gotcha: brfs does not yet support ES module import statements. See brfs-babel for an experimental replacement that supports this syntax.
browserify/brfs có 556 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/browserify/brfs. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
browserify/brfs có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho browserify/brfs. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
browserify/brfs còn đang phát triển không?
Commit gần nhất trên browserify/brfs là 1.7 năm trước (theo timestamp GitHub). Repo có 58 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
browserify/brfs là gì?
browserify/brfs (browserify/brfs) là dự án JavaScript trên GitHub. Theo mô tả gốc: browserify fs.readFileSync() static asset inliner
browserify/brfs viết bằng ngôn ngữ gì?
browserify/brfs chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc brfs có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về brfs.