{"name":"node-loader","version":"2.1.0","description":"A Node loader module for enhanced-require","license":"MIT","repository":{"type":"git","url":"git+https://github.com/webpack-contrib/node-loader.git"},"author":{"name":"Tobias Koppers @sokra"},"homepage":"https://github.com/webpack-contrib/node-loader","bugs":{"url":"https://github.com/webpack-contrib/node-loader/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"main":"dist/cjs.js","engines":{"node":">= 10.13.0"},"scripts":{"start":"npm run build -- -w","clean":"del-cli dist","prebuild":"npm run clean","build":"cross-env NODE_ENV=production babel src -d dist --copy-files","commitlint":"commitlint --from=master","security":"npm audit --production","lint:prettier":"prettier --list-different .","lint:js":"eslint --cache .","lint:spelling":"cspell \"**/*.*\"","lint":"npm-run-all -l -p \"lint:**\"","fix:js":"npm run lint:js -- --fix","fix:prettier":"npm run lint:prettier -- --write","fix":"npm-run-all -l fix:js fix:prettier","pretest:only":"cd test/fixtures/example && npm i","test:only":"cross-env NODE_ENV=test jest","test:watch":"npm run test:only -- --watch","test:coverage":"npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage","pretest":"npm run lint","test":"npm run test:coverage","prepare":"husky install && npm run build","release":"standard-version"},"peerDependencies":{"webpack":"^5.0.0"},"dependencies":{"loader-utils":"^2.0.3"},"devDependencies":{"@babel/cli":"^7.21.5","@babel/core":"^7.22.1","@babel/preset-env":"^7.22.4","@commitlint/cli":"^12.1.4","@commitlint/config-conventional":"^12.1.4","@webpack-contrib/eslint-config-webpack":"^3.0.0","babel-jest":"^27.5.1","cross-env":"^7.0.3","cspell":"^6.31.1","del":"^6.1.1","del-cli":"^3.0.1","eslint":"^7.32.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.27.5","husky":"^6.0.0","jest":"^27.5.1","lint-staged":"^10.5.4","memfs":"^3.5.1","npm-run-all":"^4.1.5","prettier":"^2.8.8","standard-version":"^9.5.0","webpack":"^5.85.0"},"keywords":["webpack"],"gitHead":"bdd596e747c27d5d5b5bfa47be845726c5312bb4","_id":"node-loader@2.1.0","_nodeVersion":"22.11.0","_npmVersion":"9.6.0","dist":{"integrity":"sha512-OwjPkyh8+7jW8DMd/iq71uU1Sspufr/C2+c3t0p08J3CrM9ApZ4U53xuisNrDXOHyGi5OYHgtfmmh+aK9zJA6g==","shasum":"8c4eb926e8bdcacb7349d17b40ebcc49fd2458d5","tarball":"http://registry-npm.ywwl.com/node-loader/download/node-loader-2.1.0.tgz","fileCount":6,"unpackedSize":10195,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChVmybr8MbNY2PnlotlvEmYg84DJpc9h64PpkbDzNNAAIhANIrU/CmY28CFWEq30g6jSfGU69Q2UPmnvHzkq9lXs43"}],"size":3952,"noattachment":false,"key":"/node-loader/-/node-loader-2.1.0.tgz"},"_npmUser":{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-loader_2.1.0_1731500236962_0.17234283431245578"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# node-loader\n\nA [Node.js add-ons](https://nodejs.org/dist/latest/docs/api/addons.html) loader.\n\nAllows to connect native node modules with `.node` extension.\n\n> ⚠ `node-loader` only works on the `node`/`async-node`/`electron-main`/`electron-renderer`/`electron-preload` targets.\n\n## Getting Started\n\nTo begin, you'll need to install `node-loader`:\n\n```console\nnpm install node-loader --save-dev\n```\n\nor\n\n```console\nyarn add -D node-loader\n```\n\nor\n\n```console\npnpm add -D node-loader\n```\n\nSetup the `target` option to `node`/`async-node`/`electron-main`/`electron-renderer`/`electron-preload` value and do not mock the `__dirname` global variable.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  resolve: {\n    extensions: [\"...\", \".node\"],\n  },\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n      },\n    ],\n  },\n};\n```\n\n### Inline\n\n**index.js**\n\n```js\nimport node from \"node-loader!./file.node\";\n```\n\nAnd run `webpack` via your preferred method.\n\n### Configuration\n\n**index.js**\n\n```js\nimport node from \"file.node\";\n```\n\nThen add the loader to your `webpack` config. For example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n      },\n    ],\n  },\n};\n```\n\nAnd run `webpack` via your preferred method.\n\n## Options\n\n|         Name          |         Type         |         Default         | Description                                                  |\n| :-------------------: | :------------------: | :---------------------: | :----------------------------------------------------------- |\n| **[`flags`](#flags)** |      `{Number}`      |       `undefined`       | Enables/Disables `url`/`image-set` functions handling        |\n|  **[`name`](#name)**  | `{String\\|Function}` | `'[contenthash].[ext]'` | Specifies a custom filename template for the target file(s). |\n\n### `flags`\n\nType: `Number`\nDefault: `undefined`\n\nThe `flags` argument is an integer that allows to specify dlopen behavior.\nSee the [`process.dlopen`](https://nodejs.org/api/process.html#process_process_dlopen_module_filename_flags) documentation for details.\n\n**index.js**\n\n```js\nimport node from \"file.node\";\n```\n\n**webpack.config.js**\n\n```js\nconst os = require(\"os\");\n\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          flags: os.constants.dlopen.RTLD_NOW,\n        },\n      },\n    ],\n  },\n};\n```\n\n### `name`\n\nType: `String|Function`\nDefault: `'[contenthash].[ext]'`\n\nSpecifies a custom filename template for the target file(s).\n\n#### `String`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          name: \"[path][name].[ext]\",\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `Function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          name(resourcePath, resourceQuery) {\n            // `resourcePath` - `/absolute/path/to/file.js`\n            // `resourceQuery` - `?foo=bar`\n\n            if (process.env.NODE_ENV === \"development\") {\n              return \"[path][name].[ext]\";\n            }\n\n            return \"[contenthash].[ext]\";\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/node-loader.svg\n[npm-url]: https://npmjs.com/package/node-loader\n[node]: https://img.shields.io/node/v/node-loader.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack-contrib/node-loader/workflows/node-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/node-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/node-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/node-loader\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=node-loader\n[size-url]: https://packagephobia.now.sh/result?p=node-loader\n","publish_time":1731500237137,"maintainers":[{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"jhnns","email":"mail@johannesewald.de"}],"_cnpm_publish_time":1731500237137,"dist-tags":{"latest":"2.1.0"}}