Skip to content

Commit a1a3140

Browse files
fix: resolving problems on windows
1 parent de1360f commit a1a3140

File tree

14 files changed

+2993
-745
lines changed

14 files changed

+2993
-745
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ Type:
6969
```ts
7070
type stylusOptions =
7171
| {
72-
use: Array<string | Function>;
73-
include: Array<string>;
74-
import: Array<string>;
75-
define: Array;
72+
use: (string | ((stylusOptions: StylusOptions) => void))[];
73+
include: string[];
74+
import: string[];
75+
define: any[];
7676
includeCSS: false;
77-
resolveURL: boolean | Object;
77+
resolveURL: boolean | object;
7878
lineNumbers: boolean;
7979
hoistAtrules: boolean;
8080
compress: boolean;
8181
}
82-
| (loaderContext: LoaderContext) => Array<string>;
82+
| ((loaderContext: LoaderContext) => string[]);
8383
```
8484

8585
Default: `{}`
@@ -337,11 +337,11 @@ Type:
337337
```ts
338338
type additionalData =
339339
| string
340-
| (
340+
| ((
341341
content: string | Buffer,
342342
loaderContext: LoaderContext,
343-
meta: any
344-
) => string;
343+
meta: any,
344+
) => string);
345345
```
346346

347347
Default: `undefined`
@@ -455,7 +455,7 @@ module.exports = {
455455
Type:
456456

457457
```ts
458-
type implementation = Function | string;
458+
type implementation = (() => typeof import("stylus")) | string;
459459
```
460460

461461
The `implementation` option allows you to specify which `Stylus implementation` to use.

bench/fixtures/imports/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
const path = require("node:path");
2+
13
module.exports = {
24
context: __dirname,
35
entry: "./index.js",
46
output: {
5-
path: `${__dirname}/tmp`,
7+
path: path.join(__dirname, "./tmp"),
68
filename: "bundle.js",
79
},
810
module: {

bench/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
const fs = require("node:fs");
22
const path = require("node:path");
3-
43
const Benchmark = require("benchmark");
5-
6-
const MemoryFileSystem = require("memory-fs");
4+
const { Volume, createFsFromVolume } = require("memfs");
75
const stylus = require("stylus");
86
const webpack = require("webpack");
97

108
const importWebpackConfig = require("./fixtures/imports/webpack.config");
119

1210
function resolveOnComplete(fn) {
13-
return () => {
11+
return (...args) => {
1412
const _this = this;
15-
const args = arguments;
1613

1714
return new Promise((resolve) => {
1815
const result = fn.apply(_this, args);
@@ -29,7 +26,8 @@ const source = fs.readFileSync(sourceFile).toString();
2926
const styl = stylus(source);
3027

3128
const compiler = webpack(importWebpackConfig);
32-
compiler.outputFileSystem = new MemoryFileSystem();
29+
30+
compiler.outputFileSystem = createFsFromVolume(new Volume());
3331

3432
Promise.resolve()
3533
.then(
@@ -60,14 +58,15 @@ Promise.resolve()
6058
return suite;
6159
}),
6260
)
61+
// eslint-disable-next-line unicorn/prefer-top-level-await
6362
.then(
6463
resolveOnComplete(() => {
6564
const suite = new Benchmark.Suite();
6665
suite
6766
.add("Stylus loader", {
6867
defer: true,
6968
fn(deferred) {
70-
compiler.run((error, stats) => {
69+
compiler.run((error, _stats) => {
7170
if (error) {
7271
throw error;
7372
}

0 commit comments

Comments
 (0)