Registry / serialization / stringify

stringify

JSON →
library0.1.1jsnpmunverified

Browserify transform to require() text files (HTML, templates, etc.) as strings in client-side JavaScript. Version 5.2.0 is the latest release; the package is no longer actively maintained by the author but accepts PRs. It supports Node >=4.0.0 (tested up to 8.1.3). Key differentiators: simple setup, optional minification via html-minifier, Node.js require hook. Alternatives like brfs or rawify are more actively maintained.

npm install stringify
INSTALL
IMPORT
SIG · STRINGIFY
S
stringify
serializationjavascriptv0.1.1
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.

stringify
const stringify = require('stringify');
import stringify from 'stringify';
Package is CommonJS only; no ESM or default export.
stringify.registerWithRequire
stringify.registerWithRequire({...});
require('stringify').registerWithRequire({...}); (works but less common)
Called after requiring stringify as shown.
browserify transform
browserify().transform(stringify, { appliesTo: { includeExtensions: ['.html'] } })
browserify().transform('stringify', ...)
The transform must be passed as a function, not a string, and MUST be called before .add()

Shows how to use stringify with Browserify to bundle HTML files as strings.

const browserify = require('browserify'); const stringify = require('stringify'); const fs = require('fs'); const b = browserify(); b.transform(stringify, { appliesTo: { includeExtensions: ['.html'] } }); b.add('./entry.js'); b.bundle().pipe(fs.createWriteStream('bundle.js')); // entry.js: // const template = require('./template.html'); // console.log(template);
Debug
Known issues
deprecatedPackage no longer actively maintained; open issues may not be addressed.
fix
Consider migrating to brfs, rawify, or other actively maintained transforms.
affects: *
gotchaThe transform MUST be applied via .transform() before .add() — order matters.
fix
Always call .transform() first, then .add().
affects: *
gotchaNode.js usage via stringify.registerWithRequire() might conflict with Browserify usage if both are used in same process.
fix
Use separate processes or modules for Node.js and Browserify builds.
affects: *
gotchaRequiring configuration from package.json may lead to unexpected behavior if key is a file path relative to cwd.
fix
Ensure the path in the 'stringify' key is correct relative to process.cwd().
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'html-minifier'
Missing dependency when minify option is enabled.
fix
Run 'npm install html-minifier --save' or disable minify option.
TypeError: Cannot read property 'includeExtensions' of undefined
appliesTo option not provided correctly when calling .transform().
fix
Provide an object with appliesTo.includeExtensions array, e.g., { appliesTo: { includeExtensions: ['.html'] } }.
SyntaxError: Unexpected token ILLEGAL in JSON at position 0
Using require() on a file without applying the transform first.
fix
Ensure stringify transform is applied in Browserify config before bundling.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
html-minifieroptionalUsed for optional minification of stringified files
through2requiredTransform stream dependency for Browserify
browserify-transform-toolsrequiredRequired for Browserify transform functionality
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
stringify — npm install stringify · libregistry