{"name":"rollup-plugin-natives","version":"0.7.1","description":"Extract native modules (.node files) while creating a rollup bundle and put them in one place","main":"src/index.js","peerDependencies":{"rollup":">=0.56.0"},"dependencies":{"fs-extra":"^9.0.1","magic-string":"^0.25.7"},"devDependencies":{"eslint":"^7.17.0","husky":"^4.3.7"},"repository":{"type":"git","url":"git+https://github.com/danielgindi/rollup-plugin-natives.git"},"author":{"name":"Daniel Cohen Gindi"},"license":"MIT","bugs":{"url":"https://github.com/danielgindi/rollup-plugin-natives/issues"},"homepage":"https://github.com/danielgindi/rollup-plugin-natives","scripts":{"lint":"eslint -f codeframe ./","lint-fix":"eslint -f codeframe --fix ./"},"gitHead":"00bcb660d993eaed820ef9313e53b3eeebda22cb","_id":"rollup-plugin-natives@0.7.1","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-dVc+ImchVzqELPULC0fFuqKEhnlUE+elT6D9x8sQmoxEHYLHxDjEnqRJJ2oNYZsqHFfzMYnapDu5j8qfo3Vm3g==","shasum":"e9ae4d06fa0a8da3ce36ee2efe5060d55f830c2d","tarball":"http://registry-npm.ywwl.com/rollup-plugin-natives/download/rollup-plugin-natives-0.7.1.tgz","fileCount":4,"unpackedSize":14085,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAL4HCRA9TVsSAnZWagAAPTsP/1yYuf89b1YYujcxkYlQ\nZcvRC9M0BPRuDKieVpcgJItZP5TVol5y64AndQ44bydGWrwq6tXMH67uACMp\nlhHjKPvAsRO6Q3Q3r8v+Hh9H+geyYcT1aAMvwWeHEpix8O9TdhBU25QvtBbk\nzVe3TlB/QXi8aUimAH3VeG7TzUofh7i5ivYUThsyLAv/enmmbyayvWJfLzUf\ndm9IXt7wfeAh9ZixBdStDXqz/L1lbsM3AGBeU0/yKM71C4JrpNd0/W5rs8Wg\nhYGJh7K8154m4Eb9CRY4fjHWvdIEEbwVJzMQ2uB/ZG9j5IpamBi0v/BT6wxc\nQF9w8NB6wG6o9Ut9L6JyllmEVzGS+9ZtxaH0QwgG3+hNg8Vz944CvvkhkFwm\n05rt6EPyDW8wJBofWLs6045p/K/wAXbRwo95J1lWK07PNjutEaAJk0HvSxLP\n0/+OikFiuOog6ItmhK90wTqG56wsjbcwhQk55ThaIqMsRx3VzAmX8ZwpEqES\n/fhDwJS77bpidvbg+Gmhc2+i3azfAxXQMcIetSsZDAXp+h5CfevIWEB9I9ce\nuwTfI5DvQ4QCYrKdlQwc75g7Yp+3Eopux7KOPdXSExAGyUbKli1Y8ttEgRD/\ns/B/u+Zi/050AjAMM4KFS1Cucm8A2rzmQBOmuwLffJSMBdlrzlmIGw4SO16z\ndyeh\r\n=yXIf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2qIMCA5oPdllf7IzvDjdhHz20NPepFlgJznkKkQ5cdQIhAPbBVIutzyRDG+sTPSb+CG1IWe3ttj4deQ3M+QQ/QIUU"}],"size":4632,"noattachment":false,"key":"/rollup-plugin-natives/-/rollup-plugin-natives-0.7.1.tgz"},"_npmUser":{"name":"danielgindi","email":"danielgindi@gmail.com"},"directories":{},"maintainers":[{"name":"danielgindi","email":"danielgindi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-natives_0.7.1_1610661382792_0.26055250903469007"},"_hasShrinkwrap":false,"readme":"# rollup-plugin-natives\r\n\r\n[![npm Version](https://badge.fury.io/js/rollup-plugin-natives.png)](https://npmjs.org/package/rollup-plugin-natives)\r\n\r\nExtract native modules (.node files) while creating a rollup bundle and put them in one place\"\r\n\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install --save-dev rollup-plugin-natives\r\n```\r\n\r\n\r\n## Usage\r\n\r\nIn some cases you have native dependencies (usually required by `bindings` or `node-pre-gyp`) \r\nand you have to put them somewhere accessible to the rolled-up bundle.  \r\nThis package is just for doing exactly this.\r\n\r\n```js\r\n// rollup.config.js\r\nimport nativePlugin from 'rollup-plugin-natives';\r\n\r\nexport default {\r\n    input: 'main.js',\r\n    output: {\r\n        file: 'dist/bundle.js',\r\n        format: 'cjs'\r\n    },\r\n    plugins: [\r\n        nativePlugin({\r\n            // Where we want to physically put the extracted .node files\r\n            copyTo: 'dist/libs',\r\n\r\n            // Path to the same folder, relative to the output bundle js\r\n            destDir: './libs',\r\n\r\n            // Use `dlopen` instead of `require`/`import`.\r\n            // This must be set to true if using a different file extension that '.node'\r\n            dlopen: false,\r\n\r\n            // Modify the final filename for specific modules\r\n            // A function that receives a full path to the original file, and returns a desired filename\r\n            map: (modulePath) => 'filename.node',\r\n\r\n            // OR you can have a function that returns a desired file name and a specific destination to copy to.\r\n            map: (modulePath) => { name: 'filename.node', copyTo: 'C:\\\\Dist\\\\libs\\\\filename.node' },\r\n\r\n            // A transformer function that allows replacing a given node module path with another.\r\n            // This is good for either handling missing files, or dynamically resolving desired architectures etc.\r\n            originTransform: (path: string, exists: boolean) => (path: string|undefined),\r\n            \r\n            // Generate sourcemap\r\n            sourcemap: true,\r\n            \r\n            // If the target is ESM, so we can't use `require` (and .node is not supported in `import` anyway), we will need to use `createRequire` instead.\r\n            targetEsm: false,\r\n        })\r\n    ]\r\n};\r\n```\r\n\r\n### Using with node-pre-gyp\r\n\r\n`node-pre-gyp` way of determining the require path is supported only if the module code matches (almost) exactly the recommended method, ie if it looks like this:\r\n```js\r\nconst binary = require('@mapbox/node-pre-gyp');\r\nconst binding_path = binary.find(path.resolve(path.join(__dirname, '../package.json')));\r\nconst module = require(binding_path);\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## About...\r\n\r\nThis plugin was created by me and shared with you courtesy of [Silverbolt](http://silverbolt.ai/) which I'm working for.\r\n","publish_time":1610661382984,"_cnpm_publish_time":1610661382984,"dist-tags":{"latest":"0.7.8"}}