Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

rollup-plugin-native

1.2.10 • 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

Install

npm i rollup-plugin-native

DownloadsWeekly Downloads

18

Version

1.2.10

License

none

Unpacked Size

12.7 kB

Total Files

4

Last publish

Collaborators

  • avatar