{"id":18835,"library":"stringify","title":"stringify","description":"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.","status":"maintenance","version":"5.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/JohnPostlethwait/stringify","tags":["javascript","browserify","browserify-transform","require","template","text","txt","client-side"],"install":[{"cmd":"npm install stringify","lang":"bash","label":"npm"},{"cmd":"yarn add stringify","lang":"bash","label":"yarn"},{"cmd":"pnpm add stringify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for optional minification of stringified files","package":"html-minifier","optional":true},{"reason":"Transform stream dependency for Browserify","package":"through2","optional":false},{"reason":"Required for Browserify transform functionality","package":"browserify-transform-tools","optional":false}],"imports":[{"note":"Package is CommonJS only; no ESM or default export.","wrong":"import stringify from 'stringify';","symbol":"stringify","correct":"const stringify = require('stringify');"},{"note":"Called after requiring stringify as shown.","wrong":"require('stringify').registerWithRequire({...}); (works but less common)","symbol":"stringify.registerWithRequire","correct":"stringify.registerWithRequire({...});"},{"note":"The transform must be passed as a function, not a string, and MUST be called before .add()","wrong":"browserify().transform('stringify', ...)","symbol":"browserify transform","correct":"browserify().transform(stringify, { appliesTo: { includeExtensions: ['.html'] } })"}],"quickstart":{"code":"const browserify = require('browserify');\nconst stringify = require('stringify');\nconst fs = require('fs');\n\nconst b = browserify();\nb.transform(stringify, {\n  appliesTo: { includeExtensions: ['.html'] }\n});\nb.add('./entry.js');\n\nb.bundle().pipe(fs.createWriteStream('bundle.js'));\n\n// entry.js:\n// const template = require('./template.html');\n// console.log(template);","lang":"javascript","description":"Shows how to use stringify with Browserify to bundle HTML files as strings."},"warnings":[{"fix":"Consider migrating to brfs, rawify, or other actively maintained transforms.","message":"Package no longer actively maintained; open issues may not be addressed.","severity":"deprecated","affected_versions":"*"},{"fix":"Always call .transform() first, then .add().","message":"The transform MUST be applied via .transform() before .add() — order matters.","severity":"gotcha","affected_versions":"*"},{"fix":"Use separate processes or modules for Node.js and Browserify builds.","message":"Node.js usage via stringify.registerWithRequire() might conflict with Browserify usage if both are used in same process.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure the path in the 'stringify' key is correct relative to process.cwd().","message":"Requiring configuration from package.json may lead to unexpected behavior if key is a file path relative to cwd.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install html-minifier --save' or disable minify option.","cause":"Missing dependency when minify option is enabled.","error":"Error: Cannot find module 'html-minifier'"},{"fix":"Provide an object with appliesTo.includeExtensions array, e.g., { appliesTo: { includeExtensions: ['.html'] } }.","cause":"appliesTo option not provided correctly when calling .transform().","error":"TypeError: Cannot read property 'includeExtensions' of undefined"},{"fix":"Ensure stringify transform is applied in Browserify config before bundling.","cause":"Using require() on a file without applying the transform first.","error":"SyntaxError: Unexpected token ILLEGAL in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}