{"id":21337,"library":"fib-rollup","title":"fib-rollup","description":"A wrapper for running Rollup inside fibjs, a JavaScript runtime optimized for async I/O with coroutines. Version 0.4.0 allows using Rollup's JavaScript API with top-level await in fibjs's coroutine context. It provides a patched virtual machine (vbox) to emulate Node.js 'module' and other globals, enabling many Rollup plugins to run despite fibjs lacking full Node.js compatibility. Key differentiators: integrates Rollup's ES module bundling with fibjs's fiber-based concurrency; includes an internal 'rollup-plugin-fibjs-resolve' plugin as a fibjs-compatible alternative to 'rollup-plugin-node-resolve'. Limitations: not all Rollup plugins work, and CLI support is planned but not yet implemented.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/fibjs/fib-rollup","tags":["javascript","fibjs","rollup","typescript"],"install":[{"cmd":"npm install fib-rollup","lang":"bash","label":"npm"},{"cmd":"yarn add fib-rollup","lang":"bash","label":"yarn"},{"cmd":"pnpm add fib-rollup","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"fib-rollup exports a default object containing rollup and plugins. Use destructured default import.","wrong":"const rollup = require('fib-rollup')","symbol":"rollup","correct":"import { default as rollup } from 'fib-rollup'"},{"note":"The plugins object includes internal plugins like 'rollup-plugin-fibjs-resolve'. Available as named export.","wrong":"const plugins = require('fib-rollup').plugins","symbol":"plugins","correct":"import { plugins } from 'fib-rollup'"},{"note":"Utilities like vbox are exported under the 'utils' namespace. Direct subpath imports may not work.","wrong":"const utils = require('fib-rollup/utils')","symbol":"utils","correct":"import { utils } from 'fib-rollup'"}],"quickstart":{"code":"const path = require('path');\nconst { default: rollup, plugins } = require('fib-rollup');\n\nasync function build() {\n    const bundle = await rollup.rollup({\n        input: './src/index.js',\n        plugins: [\n            plugins['rollup-plugin-fibjs-resolve']()\n        ]\n    }).catch(e => console.error(e));\n\n    if (bundle) {\n        const { code } = await bundle.generate({ format: 'cjs' }).catch(e => console.error(e));\n        console.log(code);\n    }\n}\n\nbuild();","lang":"javascript","description":"Demonstrates using fib-rollup to bundle a JavaScript file with the fibjs-resolve plugin, generating CommonJS output."},"warnings":[{"fix":"Use only plugins known to work (e.g., rollup-plugin-commonjs) or test with fibjs's vbox. See plugin compatibility list in the docs.","message":"Not all Rollup plugins are compatible with fibjs due to missing Node.js APIs.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"If a plugin fails, try using the provided vbox.getCustomizedVBox to patch missing modules.","message":"fib-rollup uses a custom module resolution; some plugin imports may fail.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Upgrade fibjs to version >=0.26.1 or wrap code in an async function.","message":"Top-level await is only supported in fibjs >=0.26.1.","severity":"gotcha","affected_versions":"<0.26.1"},{"fix":"Use the programmatic API as shown in the quickstart.","message":"CLI mode is not implemented; only JavaScript API is available.","severity":"gotcha","affected_versions":"<=0.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'rollup-plugin-fibjs-resolve' (built-in) instead.","cause":"The plugin is not compatible with fibjs's module system.","error":"Error: Cannot find module 'rollup-plugin-node-resolve'"},{"fix":"Ensure your script runs inside the vbox by using 'vbox.require' or the default rollup export.","cause":"fibjs lacks the Node.js 'module' module.","error":"TypeError: module is not a function"},{"fix":"Wrap your code in an async function or upgrade fibjs.","cause":"fibjs version <0.26.1 does not support top-level await.","error":"SyntaxError: await is only valid in async function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}