rollup-plugin-native

1.2.16 • Public • Published

Build Status downloads License minified size npm

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-native

Usage

// 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

Package Sidebar

Install

npm i rollup-plugin-native

Weekly Downloads

7

Version

1.2.16

License

none

Unpacked Size

7.74 kB

Total Files

3

Last publish

Collaborators

  • arlac77