native-ext-loader
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -0,4 +1,10 @@ | ||
# 2.0.0 | ||
* Remove `loader-utils` dependency. (5156da688769f861cf657ee5f7087310f7ec6819) | ||
* Remove configurable `name` option. (5156da688769f861cf657ee5f7087310f7ec6819) | ||
* Assume that custom options are a valid hash object. (5156da688769f861cf657ee5f7087310f7ec6819) | ||
# 1.1.0 | ||
* Add a support for Webpack 4.0.x. ([#1](https://github.com/smt116/node-native-ext-loader/pull/1) by [@matsnow](https://github.com/matsnow)) | ||
* Add a support for Webpack 4.0.x. (#1 by @matsnow) | ||
@@ -5,0 +11,0 @@ # 1.0.0 |
13
index.js
@@ -1,18 +0,11 @@ | ||
var loaderUtils = require("loader-utils"); | ||
var path = require("path"); | ||
module.exports = function(content) { | ||
module.exports = function (content) { | ||
const defaultConfig = { | ||
name: "[name].[ext]", | ||
rewritePath: undefined | ||
}; | ||
const config = Object.assign(defaultConfig, loaderUtils.getOptions(this)); | ||
const config = Object.assign(defaultConfig, this.query); | ||
const fileName = path.basename(this.resourcePath); | ||
const context = this.options ? this.options.context : this.rootContext; | ||
const fileName = loaderUtils.interpolateName(this, config.name, { | ||
context: context, | ||
content: content | ||
}); | ||
if (this.emitFile) { | ||
@@ -19,0 +12,0 @@ this.emitFile(fileName, content, false); |
{ | ||
"name": "native-ext-loader", | ||
"version": "1.1.0", | ||
"author": "Maciej Małecki <smt116@gmail.com>", | ||
"dependencies": {}, | ||
"description": "Loader for Node native extensions", | ||
"main": "index.js", | ||
"repository": "https://github.com/smt116/node-native-loader", | ||
"scripts": {}, | ||
"keywords": [ | ||
"electron", | ||
"loader", | ||
"native", | ||
"node", | ||
"native", | ||
"loader" | ||
"webpack" | ||
], | ||
"author": "Maciej Małecki <smt116@gmail.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"loader-utils": "^1.1.0" | ||
} | ||
"main": "index.js", | ||
"name": "native-ext-loader", | ||
"repository": "https://github.com/smt116/node-native-loader", | ||
"scripts": {}, | ||
"version": "2.0.0" | ||
} |
# Node Native Loader | ||
Module for loading native files in Node and Electron applications. The project is inspired by the [node-addon-loader](https://github.com/ushu/node-addon-loader). It works in the similar way but **allows to build path in the runtime**. | ||
Package for loading native files in Node and Electron applications. The project is inspired by the [node-addon-loader](https://github.com/ushu/node-addon-loader). It works in the similar way but **allows to build path at runtime**. | ||
## Install | ||
Add the package to the `package.json` file: | ||
Add the package to the development dependencies: | ||
```bash | ||
# using npm: | ||
$ npm install native-ext-loader --save-dev | ||
# using yarn: | ||
$ yarn add --dev native-ext-loader | ||
@@ -15,3 +19,3 @@ ``` | ||
Update `webpack.config.js` file's rules: | ||
Update rules entry in the Webpack configuration file: | ||
@@ -29,3 +33,3 @@ ```javascript | ||
It is possible to adjust options: | ||
Options are configurable using `options` hash: | ||
@@ -38,3 +42,2 @@ ```javascript | ||
options: { | ||
name: '[hex].[ext]', | ||
rewritePath: path.resolve(__dirname, 'dist') | ||
@@ -46,8 +49,6 @@ } | ||
### `name` | ||
### `rewritePath` (default: `undefined`) | ||
This option allows to change the file name in the output directory. You can use all placeholders defined in the [loader-utils](https://github.com/webpack/loader-utils/tree/v1.1.0#interpolatename) package. | ||
It allows to set an absolute paths to native files. | ||
### `rewritePath` | ||
This options allows to set an absolute path. Note that it needs to remain `undefined` if you are building a package with embedded files. | ||
Note that it needs to remain `undefined` if you are building a package with embedded files. This way, the compiled application will work no matter of its location. This is important when building Electron applications that can be placed in any directory by the end user. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
51
4154
5
25
- Removedloader-utils@^1.1.0
- Removedbig.js@5.2.2(transitive)
- Removedemojis-list@3.0.0(transitive)
- Removedjson5@1.0.2(transitive)
- Removedloader-utils@1.4.2(transitive)
- Removedminimist@1.2.8(transitive)