rollup-plugin-native
v1.2.16
Published
Import native code with Rollup
Readme
rollup-plugin-native
Import native code with Rollup.
As there is currently no support for
import {x} from "module.node"Installation
npm install --save-dev rollup-plugin-nativeUsage
// rollup.config.js
import native from 'rollup-plugin-native';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'cfs'
},
plugins: [
native({
platformName: "${dirname}/precompiled/${nodePlatform}-${nodeArchitecture}/node.napi.node",
//platformName: "${dirname}/${basename}-${nativePlatform}-${nativeArchitecture}.node",
})
]
}import { funcA, constB } from "../module.node";
funcA(); // native call
will generate a dlopen / require for "../precompiled/linux-x86/node.napi.node"
Substitution properties in the platformName
- dirname dirname
- basename basename (.node stiped away)
- nodePlatform from process.platform()
- nodeArchitecture from process.arch()
- nativePlatform as given from uname
- nativeArchitecture as used in llvm & gcc
License
BSD

