{"id":22022,"library":"rollup-plugin-fable","title":"rollup-plugin-fable","description":"Rollup plugin for Fable, the F# to JavaScript compiler. Current version 2.0.0 enables bundling F# projects with Rollup by invoking the Fable compiler during the build process. Maintained as part of the Fable ecosystem, it integrates with Babel for transpilation and supports options like custom compiler directives, typed arrays, and Fable plugins. Key differentiators: seamless integration with F# tooling, supports Fable's compile-time metaprogramming, and requires careful path resolution to avoid conflicts with NuGet cache.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/fable-compiler/Fable/tree/master/src/js/rollup-plugin-fable","tags":["javascript","fable","fsharp","F#","rollup","plugin"],"install":[{"cmd":"npm install rollup-plugin-fable","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-fable","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-fable","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for Babel transpilation of compiled JS","package":"@babel/core","optional":false}],"imports":[{"note":"This package is ESM-only and does not support CommonJS require().","wrong":"const fable = require('rollup-plugin-fable')","symbol":"default","correct":"import fable from 'rollup-plugin-fable'"},{"note":"The default export is the plugin function; named exports are not available.","wrong":"import { fable } from 'rollup-plugin-fable'","symbol":"default","correct":"import fable from 'rollup-plugin-fable'"},{"note":"For CommonJS require, use dynamic import or upgrade to ESM.","wrong":"const fable = require('rollup-plugin-fable')","symbol":"default","correct":"const fable = (await import('rollup-plugin-fable')).default"}],"quickstart":{"code":"import path from 'path';\nimport fableUtils from 'fable-utils';\nimport fable from 'rollup-plugin-fable';\nimport nodeResolve from 'rollup-plugin-node-resolve';\n\nfunction resolve(relativePath) {\n  return path.join(__dirname, relativePath);\n}\n\nvar babelOptions = fableUtils.resolveBabelOptions({\n  'presets': [\n    ['es2015', {'modules': false}]\n  ]\n});\n\nexport default {\n  entry: resolve('./my-app.fsproj'),\n  dest: resolve('./dist/bundle.js'),\n  plugins: [\n    fable({ babel: babelOptions }),\n    nodeResolve({\n      customResolveOptions: {\n        moduleDirectory: resolve('./node_modules')\n      }\n    })\n  ],\n  format: 'cjs'\n};","lang":"javascript","description":"Configures Rollup to bundle an F# project using Fable, with Babel for transpilation and node-resolve for module resolution."},"warnings":[{"fix":"Use path.join(__dirname, relativePath) for all file paths.","message":"Path resolution: Must use absolute paths for entry and node_modules to avoid conflicts with Fable pulling files from NuGet cache.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use fableUtils.resolveBabelOptions() to create babel options object.","message":"Babel options must be resolved via fableUtils.resolveBabelOptions to share the same instance across plugins.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass array of compiler directives via define option, e.g., fable({ define: ['DEBUG'] }).","message":"DefineConstants property in .fsproj is ignored; use the 'define' option instead.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install @babel/core: npm install --save-dev @babel/core","message":"Requires @babel/core as a peer dependency. Missing it causes runtime errors.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install --save-dev @babel/core","cause":"Missing peer dependency @babel/core.","error":"Error: Cannot find module '@babel/core'"},{"fix":"Ensure fable is invoked as a function in the plugins array, e.g., plugins: [fable({ babel: babelOptions })]","cause":"Incorrect usage of the plugin in rollup.config.js (e.g., calling fable() incorrectly).","error":"Error: Plugin returned an object which has a function but not a generateBundle property"},{"fix":"npm install --save-dev fable-utils","cause":"Missing dependency fable-utils.","error":"Error: Cannot resolve module 'fable-utils'"},{"fix":"Ensure fable-utils is installed and imported correctly: import fableUtils from 'fable-utils'","cause":"Incorrect import or version of fable-utils.","error":"TypeError: fableUtils.resolveBabelOptions is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}