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.
npm install rollup-plugin-nativeVerified import paths — ran on the pinned version, not inferred.
Configures Rollup to resolve native .node modules with platform-specific binary paths using substitution variables.
Use output.format: 'cjs' instead of 'cfs'.
Ensure output format is 'cjs' when using native modules, or use plugin options to generate conditional require.
Use ${basename} without .node in the path template, as the extension is handled internally.Upgrade Rollup to version 3 or later.
Verify platformName template resolves correctly; check process.platform() and process.arch() values.
Use default import: import native from 'rollup-plugin-native'
Pass an options object with a 'platformName' property to native().
Upgrade Rollup to 3.x or later: npm install rollup@latest --save-dev
No dependency data recorded yet.