vitest-config-silverwind 8.0.2 → 8.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +23 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,6 +3,27 @@ import {fileURLToPath} from "node:url";
|
|
|
3
3
|
import {stringPlugin} from "vite-string-plugin";
|
|
4
4
|
|
|
5
5
|
const uniq = arr => Array.from(new Set(arr));
|
|
6
|
+
const uniquePluginName = ({name, apply, enforce} = {}) => `${name}-${apply}-${enforce}`;
|
|
7
|
+
|
|
8
|
+
function dedupePlugins(plugins) {
|
|
9
|
+
const seen = new Set([]);
|
|
10
|
+
const ret = [];
|
|
11
|
+
|
|
12
|
+
for (const plugin of plugins.reverse()) {
|
|
13
|
+
const name = plugin ? uniquePluginName(plugin) : null;
|
|
14
|
+
|
|
15
|
+
if (seen.has(name)) {
|
|
16
|
+
continue;
|
|
17
|
+
} else {
|
|
18
|
+
ret.push(plugin);
|
|
19
|
+
if (name) {
|
|
20
|
+
seen.add(name);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ret;
|
|
26
|
+
}
|
|
6
27
|
|
|
7
28
|
const base = ({url, test: {setupFiles = [], ...otherTest}, plugins = [], ...other} = {}) => ({
|
|
8
29
|
test: {
|
|
@@ -36,8 +57,8 @@ const base = ({url, test: {setupFiles = [], ...otherTest}, plugins = [], ...othe
|
|
|
36
57
|
},
|
|
37
58
|
...otherTest,
|
|
38
59
|
},
|
|
39
|
-
plugins:
|
|
40
|
-
stringPlugin,
|
|
60
|
+
plugins: dedupePlugins([
|
|
61
|
+
stringPlugin(),
|
|
41
62
|
...plugins,
|
|
42
63
|
]),
|
|
43
64
|
...other,
|