https://github.com/arlac77/rollup-plugin-native
import native (NAPI) modules
https://github.com/arlac77/rollup-plugin-native
Last synced: about 1 year ago
JSON representation
import native (NAPI) modules
- Host: GitHub
- URL: https://github.com/arlac77/rollup-plugin-native
- Owner: arlac77
- Created: 2019-11-06T22:47:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T13:25:01.000Z (over 1 year ago)
- Last Synced: 2025-03-18T04:23:06.442Z (about 1 year ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](http://travis-ci.org/arlac77/rollup-plugin-native)
[](https://npmjs.org/package/rollup-plugin-native)
[](https://opensource.org/licenses/BSD-3-Clause)
[](https://bundlephobia.com/result?p=rollup-plugin-native)
[](https://www.npmjs.com/package/rollup-plugin-native)
# rollup-plugin-native
Import native code with Rollup.
As there is currently no support for
```js
import {x} from "module.node"
```
## Installation
```bash
npm install --save-dev rollup-plugin-native
```
## Usage
```js
// 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",
})
]
}
```
```js
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