{"id":22141,"library":"rollup-plugin-native","title":"rollup-plugin-native","description":"A Rollup plugin that enables importing native .node modules (N-API addons) by resolving platform-specific binary paths during bundling. Version 1.2.16, last updated in 2024, with low release cadence (no breaking changes in recent versions). It uses substitution patterns like ${nodePlatform} and ${nativeArchitecture} to dynamically select the correct precompiled binary for the current OS/arch, avoiding the need for node-gyp at runtime. Differentiators: simplifies cross-platform native module bundling without manual conditional requires, and integrates directly into Rollup's plugin system. No other known alternative for Rollup-focused native module import.","status":"active","version":"1.2.16","language":"javascript","source_language":"en","source_url":"https://github.com/arlac77/rollup-plugin-native","tags":["javascript","rollup-plugin","native","napi"],"install":[{"cmd":"npm install rollup-plugin-native","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-native","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-native","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require() will work but is not recommended for Rollup configs.","wrong":"const native = require('rollup-plugin-native')","symbol":"default (native)","correct":"import native from 'rollup-plugin-native'"},{"note":"The plugin exports a default function, not a named export. Use default import.","wrong":"import { native } from 'rollup-plugin-native'","symbol":"native","correct":"import native from 'rollup-plugin-native'"},{"note":"TypeScript types may not be shipped; use JSDoc or custom type definitions.","wrong":"undefined","symbol":"RollupPluginNativeOptions","correct":"/** @type {import('rollup-plugin-native').PluginOptions} */"}],"quickstart":{"code":"// rollup.config.js\nimport native from 'rollup-plugin-native';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs'\n  },\n  plugins: [\n    native({\n      platformName: 'precompiled/${nodePlatform}-${nodeArchitecture}/native.node'\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to resolve native .node modules with platform-specific binary paths using substitution variables."},"warnings":[{"fix":"Use output.format: 'cjs' instead of 'cfs'.","message":"Format 'cfs' in documentation is a typo; use 'cjs' for CommonJS output.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure output format is 'cjs' when using native modules, or use plugin options to generate conditional require.","message":"Dynamic require of .node files may not work in all Rollup output formats (e.g., esm).","severity":"gotcha","affected_versions":"all"},{"fix":"Use ${basename} without .node in the path template, as the extension is handled internally.","message":"Substitution ${basename} strips .node extension; ensure paths are correct.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Upgrade Rollup to version 3 or later.","message":"The plugin only supports Rollup >=3.0.0; older versions may fail.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.16':28 '2024':32 'addon':17 'altern':94 'api':16 'avoid':62 'binari':23,57 'break':38 'bundl':26,78 'cadenc':36 'chang':39 'condit':81 'correct':55 'cross':74 'cross-platform':73 'current':60 'differenti':71 'direct':85 'dynam':52 'enabl':9 'focus':98 'gyp':68 'import':10,101 'integr':84 'javascript':102 'known':93 'last':29 'like':47 'low':34 'manual':80 'modul':13,77,100 'n':15 'n-api':14 'napi':107 'nativ':4,11,76,99,106 'nativearchitectur':50 'need':64 'node':12,67 'node-gyp':66 'nodeplatform':48 'os/arch':61 'path':24 'pattern':46 'platform':21,75 'platform-specif':20 'plugin':3,7,89,105 'precompil':56 'recent':41 'releas':35 'requir':82 'resolv':19 'rollup':2,6,87,97,104 'rollup-focus':96 'rollup-plugin':103 'rollup-plugin-n':1 'runtim':70 'select':53 'simplifi':72 'specif':22 'substitut':45 'system':90 'updat':30 'use':44 'version':27,42 'without':79","created_at":"2026-04-27T17:03:36.668008+00:00","updated_at":"2026-04-27T17:03:36.668008+00:00","problems":[{"fix":"Verify platformName template resolves correctly; check process.platform() and process.arch() values.","cause":"platformName pattern does not match the actual file path","error":"Error: Cannot find module '../module.node'"},{"fix":"Use default import: import native from 'rollup-plugin-native'","cause":"Named import used instead of default import","error":"TypeError: native is not a function"},{"fix":"Pass an options object with a 'platformName' property to native().","cause":"Plugin instantiated without options but platformName is required","error":"(!) Plugin native: Options object is required"},{"fix":"Upgrade Rollup to 3.x or later: npm install rollup@latest --save-dev","cause":"Using an older version of Rollup","error":"Error: Rollup plugin native requires Rollup >=3.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/arlac77/rollup-plugin-native","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-native","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}