Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit c9ccc48

Browse files
committed
style: fix formatting
1 parent bbf7a9d commit c9ccc48

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@ module.exports = {
2020
webpack: (config, { dev, isServer, webpack, nextRuntime }) => {
2121
config.module.rules.push({
2222
test: /\.node$/,
23-
use: [{
24-
loader: "nextjs-node-loader",
25-
}],
23+
use: [
24+
{
25+
loader: "nextjs-node-loader",
26+
},
27+
],
2628
});
2729
return config;
2830
},
2931
};
3032
```
33+
3134
And use in e.g. your api route;
35+
3236
```javascript
33-
import module from 'node-module';
37+
import module from "node-module";
3438

3539
export default function handler(req, res) {
3640
// ...
@@ -39,9 +43,9 @@ export default function handler(req, res) {
3943

4044
## Options
4145

42-
| Name | Type | Default | Description |
43-
| :-------------------: | :------------------: | :---------------------: | :----------------------------------------------------------- |
44-
| **[`flags`](#flags)** | `{Number}` | `undefined` | Enables/Disables `url`/`image-set` functions handling |
46+
| Name | Type | Default | Description |
47+
| :-------------------: | :--------: | :---------: | :---------------------------------------------------- |
48+
| **[`flags`](#flags)** | `{Number}` | `undefined` | Enables/Disables `url`/`image-set` functions handling |
4549

4650
### `flags`
4751

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"security": "npm audit --production",
2424
"lint:prettier": "prettier --list-different .",
2525
"lint:js": "eslint --cache .",
26-
"lint:spelling": "cspell \"**/*.*\"",
2726
"lint": "npm-run-all -l -p \"lint:**\"",
2827
"pretest:only": "cd test/fixtures/example && npm i",
2928
"test:only": "cross-env NODE_ENV=test jest",
@@ -52,7 +51,6 @@
5251
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
5352
"babel-jest": "^27.5.1",
5453
"cross-env": "^7.0.3",
55-
"cspell": "^6.20.1",
5654
"del": "^6.1.1",
5755
"del-cli": "^3.0.1",
5856
"eslint": "^7.32.0",
@@ -68,6 +66,11 @@
6866
"webpack": "^5.75.0"
6967
},
7068
"keywords": [
71-
"webpack", "nextjs", "loader", "node.js", "node-loader", "native-modules"
69+
"webpack",
70+
"nextjs",
71+
"loader",
72+
"node.js",
73+
"node-loader",
74+
"native-modules"
7275
]
7376
}

src/index.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
const { interpolateName } = require("loader-utils");
2+
23
const schema = require("./options.json");
34

4-
module.exports = function(content) {
5-
const {rootContext, _compiler, getOptions, emitFile} = this;
5+
function loader(content) {
6+
const { rootContext, _compiler, getOptions, emitFile } = this;
67
const options = getOptions(schema);
7-
const { flags = undefined } = options;
8+
const { flags } = options;
89
const outputPath = _compiler.options.output.path;
910

10-
const name = interpolateName(
11-
this,
12-
"[name].[ext]",
13-
{
14-
context: rootContext,
15-
content,
16-
}
17-
);
11+
const name = interpolateName(this, "[name].[ext]", {
12+
context: rootContext,
13+
content,
14+
});
1815

1916
emitFile(name, content);
2017

2118
return `
2219
try {
23-
process.dlopen(module, ${JSON.stringify(outputPath)} + require("path").sep + __webpack_public_path__ + ${JSON.stringify(
24-
name
25-
)}${
26-
typeof flags !== "undefined"
27-
? `, ${JSON.stringify(options.flags)}`
28-
: ""
20+
process.dlopen(module, ${JSON.stringify(
21+
outputPath
22+
)} + require("path").sep + __webpack_public_path__ + ${JSON.stringify(name)}${
23+
typeof flags !== "undefined" ? `, ${JSON.stringify(options.flags)}` : ""
2924
});
3025
} catch (error) {
3126
throw new Error('nextjs-node-loader:\\n' + error);
3227
}
3328
`;
34-
};
29+
}
3530

31+
module.exports = loader;
3632
module.exports.raw = true;

0 commit comments

Comments
 (0)