{"name":"rollup-plugin-natives","version":"0.7.6","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":"^10.1.0","magic-string":"^0.25.9"},"devDependencies":{"eslint":"^7.32.0","husky":"^7.0.2","pinst":"^2.1.6"},"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 ./","_postinstall":"husky install","prepublishOnly":"pinst --disable","postpublish":"pinst --enable"},"gitHead":"455f101971d12a61ca3bdbb2422ce25a8a14929f","_id":"rollup-plugin-natives@0.7.6","_nodeVersion":"16.13.2","_npmVersion":"6.14.16","dist":{"integrity":"sha512-G3jnCjZJgpOxOz4sYGwAYzemMhCQvb9mzhOrO5zTdNGkG5fiIcpETEURTD5BB+R6lC4j4BdWkHKf+FLofoymJw==","shasum":"c64fa79254cc0debbdfa860787ca00784b88d39e","tarball":"http://registry-npm.ywwl.com/rollup-plugin-natives/download/rollup-plugin-natives-0.7.6.tgz","fileCount":4,"unpackedSize":18657,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA+t43WP92cQTgnc18HbPZlvP510rWzxkNQC0/fksJPWAiBaGxaiYFVPNhvyi/FF+XXSq6RszAt+hCZbePMPPb4WaQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjVMJpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmomvA/+MJzQF5xfBpFampcIgN4MTvBypbog7t25A2dOSinRIvKfAz/c\r\nHT/u1+h1VcoLezjCISV0Fzy8P6rOp7MTsSiPR3vmdQHdB79WykfRMuw3LS9Y\r\nhJ++C+wZhw2bKqKlbAh0aerSJStcC/yDtGiqqhlDzpBLQTP2dZpK3QYVXzrH\r\ndAbjx2w7YYGKEGdMOGVmlpY2Qm0hrak/6OhTcqm2TD3mOPkjmUq9azW0zVhS\r\nKl9j0yfBvzPUGeOym+sROd16Fj4zbNr/u9VD7jCSgbtkZcLL+DmfFHaRjZ76\r\nEdE1S7gFVE3NaFQmiVWOaj13JW7ZpawjTE4Pos3GMXVHCDqiWNl7pFrxehxJ\r\nRRP8sWHMjQjwfoe0GqmEUOPqDF1z6LdgeORS7kfMyyCcolavTJt/uXC/ED/+\r\nxhwV8JycL2mXcrCJ3/0rBengPa19O2qCT0BrvXFSHH27EH+2lYkplTiu+GoT\r\nIG1qMmLRIq53n3e5AGhu8R2C6F+smB+qqeJTp5J3F/I/SX4kE56FrmCLeLM/\r\n46kRQZLRMjQDl4HrSuvDKtaw65A6P3VkA1yWXRjaeVodWVuidlPKAuE23P4p\r\nrCkT40GNBRyfyXT8IREkWb/PC/enBOk8N6HPvIRJYDw/pNscZb8ec5qXXfr4\r\npjZrbyjTp+ux6j9YGlGKRrxzD7Wva/kDP8U=\r\n=T9N6\r\n-----END PGP SIGNATURE-----\r\n","size":5720,"noattachment":false,"key":"/rollup-plugin-natives/-/rollup-plugin-natives-0.7.6.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.6_1666499177178_0.39906405684941215"},"_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":1666499177322,"_cnpm_publish_time":1666499177322,"dist-tags":{"latest":"0.7.8"}}