{"id":22517,"library":"unloader","title":"unloader","description":"A Node.js custom loader framework with a Rollup-like plugin interface (v0.9.0). Requires Node.js >=22.18.0. Provides synchronous hooks (options, resolveId, load, transform) for developing loaders such as TypeScript or Oxc loaders. Supports ESM and CJS, virtual modules, and source maps. Breaking changes in v0.9.0 removed module.register and async/worker support. Integrates with unplugin. Less feature-rich than tsx but offers a familiar plugin system for Rollup developers.","status":"active","version":"0.9.0","language":"javascript","source_language":"en","source_url":"https://github.com/sxzz/unloader","tags":["javascript"],"install":[{"cmd":"npm install unloader","lang":"bash","label":"npm"},{"cmd":"yarn add unloader","lang":"bash","label":"yarn"},{"cmd":"pnpm add unloader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Node.js >=22.18.0 (v0.8.0+)","package":"node","optional":false}],"imports":[{"note":"Type import only; Plugin is a TypeScript interface.","symbol":"Plugin","correct":"import type { Plugin } from 'unloader'"},{"note":"PluginContext is a TypeScript type, cannot be required.","wrong":"const { PluginContext } = require('unloader')","symbol":"PluginContext","correct":"import type { PluginContext } from 'unloader'"},{"note":"Package is ESM-only; named exports require import * or import {}.","wrong":"const unloader = require('unloader')","symbol":"unloader","correct":"import * as unloader from 'unloader'"}],"quickstart":{"code":"import { readFileSync } from 'node:fs'\nimport type { Plugin } from 'unloader'\n\nconst myPlugin: Plugin = {\n  name: 'example',\n  resolveId(source, importer, options) {\n    if (source === 'virtual') return '/virtual.js'\n    return this.resolve(`${source}.js`, importer, options)\n  },\n  load(id) {\n    if (id === '/virtual.js') return { code: 'export const foo = 1' }\n    return readFileSync(id, 'utf8')\n  },\n}\n\nexport default { plugins: [myPlugin] }","lang":"typescript","description":"Creates a minimal unloader plugin with resolveId and load hooks for a virtual module."},"warnings":[{"fix":"Rewrite any async or promise-based plugin hooks to be synchronous. Use sync versions of file I/O, etc.","message":"v0.9.0 removed module.register, dropped async/worker/quansync support; plugin hooks throwing Promises now throws","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Upgrade Node.js to v22.18.0 or above.","message":"v0.8.0 dropped Node <22.18 support","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"In buildStart and other hooks, access meta via 'this.meta', error via 'this.error', etc.","message":"v0.7.0 moved PluginContext to this: use this.meta, this.error instead of context.meta, context.error","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Upgrade to Node.js >=20.19 or use an older version of unloader.","message":"v0.6.0 dropped Node 18 support, requires Node 20.19+","severity":"breaking","affected_versions":"0.6.0 - 0.7.x"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use function() { ... } instead of arrow functions for hooks, or capture context via second argument (resolveId receives context as third argument before v0.7? Actually resolveId uses 'this' as context; ensure you are using normal function, not arrow, to have correct 'this'.","cause":"Custom resolver callback not bound to plugin context; using arrow function with 'this.resolve' incorrectly","error":"TypeError: (intermediate value).resolve is not a function"},{"fix":"Make the hook synchronous; use readFileSync, not readFile.","cause":"Plugin hook (e.g., load, transform) returned a Promise or async function, which is not supported since v0.9.0","error":"Error: Plugin hook returned a Promise. Synchronous hooks only."},{"fix":"Check that resolveId returns a valid absolute path or an object with id, or returns undefined to let default resolver handle.","cause":"resolveId hook returned an invalid file path or failed to resolve correctly","error":"Error: The module '.package.json' was resolved to a non-existent file"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}