{"id":18126,"library":"assemble-handle","title":"assemble-handle","description":"Assemble pipeline plugin for handling custom middleware stages in the Assemble build system. Version 1.0.0 is the latest stable release, updated on npm with monthly downloads. It allows you to create and manage middleware stages like 'onStream', 'preWrite', and 'postWrite', and handle them on files via .pipe(). The package also provides a .once() method to prevent middleware from running multiple times for the same stage. Key differentiator: tightly integrated with Assemble, not a general-purpose middleware runner.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/assemble/assemble-handle","tags":["javascript","assemble","assembleplugin","boilerplate","build","cli","cli-app","command-line","create"],"install":[{"cmd":"npm install assemble-handle","lang":"bash","label":"npm"},{"cmd":"yarn add assemble-handle","lang":"bash","label":"yarn"},{"cmd":"pnpm add assemble-handle","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for handler creation and app instance","package":"assemble-core","optional":false}],"imports":[{"note":"CommonJS module; no default ESM export. Use require.","wrong":"import handle from 'assemble-handle'","symbol":"default","correct":"const handle = require('assemble-handle')"},{"note":"Arguments order: (app, stage).","wrong":"handle.once('stageName', app)","symbol":"handle.once","correct":"handle.once(app, 'stageName')"},{"note":"Must pass app as first argument.","wrong":"handle('stageName', app)","symbol":"handle","correct":"const handle = require('assemble-handle'); handle(app, 'stageName')"}],"quickstart":{"code":"const assemble = require('assemble-core');\nconst handle = require('assemble-handle');\nconst app = assemble();\n\n// Create middleware stages\napp.handler('onStream');\napp.handler('preWrite');\n\n// Add middleware\napp.onStream(/.*/, function(file, next) {\n  console.log('onStream:', file.relative);\n  next();\n});\napp.preWrite(/.*/, function(file, next) {\n  console.log('preWrite:', file.relative);\n  next();\n});\n\n// Task using handle\napp.task('default', function() {\n  return app.src('*.js')\n    .pipe(handle(app, 'onStream'))\n    .pipe(handle(app, 'preWrite'))\n    .pipe(app.dest('dist'));\n});\n\napp.build('default');","lang":"javascript","description":"Demonstrates creating handlers, adding middleware, and using handle in a pipeline task."},"warnings":[{"fix":"Use handle(app, 'stageName'), not handle('stageName', app).","message":"The handle function must be called with app as first argument; order matters.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Understand that .once() resets per stream; use other dedup patterns if needed.","message":"handle.once only prevents multiple calls within the same file stream; not global deduplication.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always call app.handler('stageName') before accessing app.onStage or using handle.","message":"Handlers must be created with app.handler() before being used.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to Gulp or other modern pipelines.","message":"Assemble ecosystem is largely superseded by other build tools; not actively maintained.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you npm install assemble-core and require it before assemble-handle.","cause":"Missing assemble-core dependency or incorrect import.","error":"TypeError: app.handler is not a function"},{"fix":"Add app.handler('onStream') before calling handle(app, 'onStream').","cause":"Forgot to call app.handler('onStream') before using handle.","error":"Error: Middleware stage \"onStream\" is not defined"},{"fix":"Add const handle = require('assemble-handle'); at top of file.","cause":"Package not required properly.","error":"ReferenceError: handle is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}