@parcel/utils 2.12.0 → 2.13.0
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/lib/index.js +10224 -9688
- package/lib/index.js.map +1 -1
- package/package.json +10 -11
- package/src/alternatives.js +2 -2
- package/src/config.js +3 -3
- package/src/index.js +1 -0
- package/src/svgo.js +50 -0
- package/test/PromiseQueue.test.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"main": "lib/index.js",
|
|
18
18
|
"source": "src/index.js",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">= 16.0.0"
|
|
21
21
|
},
|
|
22
22
|
"targets": {
|
|
23
23
|
"main": {
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@parcel/codeframe": "2.
|
|
37
|
-
"@parcel/diagnostic": "2.
|
|
38
|
-
"@parcel/logger": "2.
|
|
39
|
-
"@parcel/markdown-ansi": "2.
|
|
40
|
-
"@parcel/rust": "2.
|
|
36
|
+
"@parcel/codeframe": "2.13.0",
|
|
37
|
+
"@parcel/diagnostic": "2.13.0",
|
|
38
|
+
"@parcel/logger": "2.13.0",
|
|
39
|
+
"@parcel/markdown-ansi": "2.13.0",
|
|
40
|
+
"@parcel/rust": "2.13.0",
|
|
41
41
|
"@parcel/source-map": "^2.1.1",
|
|
42
|
-
"chalk": "^4.1.
|
|
42
|
+
"chalk": "^4.1.2",
|
|
43
43
|
"nullthrows": "^1.1.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -51,12 +51,11 @@
|
|
|
51
51
|
"is-glob": "^4.0.0",
|
|
52
52
|
"is-url": "^1.2.2",
|
|
53
53
|
"json5": "^2.2.0",
|
|
54
|
-
"lru-cache": "^
|
|
54
|
+
"lru-cache": "^10.0.0",
|
|
55
55
|
"micromatch": "^4.0.4",
|
|
56
56
|
"node-forge": "^1.2.1",
|
|
57
57
|
"nullthrows": "^1.1.1",
|
|
58
58
|
"open": "^7.0.3",
|
|
59
|
-
"random-int": "^1.0.0",
|
|
60
59
|
"snarkdown": "^2.0.0",
|
|
61
60
|
"strip-ansi": "^6.0.0",
|
|
62
61
|
"terminal-link": "^2.1.1"
|
|
@@ -67,5 +66,5 @@
|
|
|
67
66
|
"./src/openInBrowser.js": false,
|
|
68
67
|
"@parcel/markdown-ansi": false
|
|
69
68
|
},
|
|
70
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "a53f8f3ba1025c7ea8653e9719e0a61ef9717079"
|
|
71
70
|
}
|
package/src/alternatives.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import type {FileSystem} from '@parcel/
|
|
3
|
+
import type {FileSystem} from '@parcel/types';
|
|
4
4
|
import {fuzzySearch} from './schema';
|
|
5
5
|
import {relativePath} from './path';
|
|
6
6
|
import {resolveConfig} from './config';
|
|
@@ -141,5 +141,5 @@ export async function findAlternativeFiles(
|
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
return fuzzySearch(potentialFiles, fileSpecifier).slice(0, 2);
|
|
144
|
+
return fuzzySearch(potentialFiles.sort(), fileSpecifier).slice(0, 2);
|
|
145
145
|
}
|
package/src/config.js
CHANGED
|
@@ -7,7 +7,7 @@ import path from 'path';
|
|
|
7
7
|
import clone from 'clone';
|
|
8
8
|
import json5 from 'json5';
|
|
9
9
|
import {parse as toml} from '@iarna/toml';
|
|
10
|
-
import
|
|
10
|
+
import {LRUCache} from 'lru-cache';
|
|
11
11
|
|
|
12
12
|
export type ConfigOutput = {|
|
|
13
13
|
config: ConfigResult,
|
|
@@ -19,7 +19,7 @@ export type ConfigOptions = {|
|
|
|
19
19
|
parser?: string => any,
|
|
20
20
|
|};
|
|
21
21
|
|
|
22
|
-
const configCache = new
|
|
22
|
+
const configCache = new LRUCache<FilePath, ConfigOutput>({max: 500});
|
|
23
23
|
const resolveCache = new Map();
|
|
24
24
|
|
|
25
25
|
export function resolveConfig(
|
|
@@ -96,7 +96,7 @@ export async function loadConfig(
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
loadConfig.clear = () => {
|
|
99
|
-
configCache.
|
|
99
|
+
configCache.clear();
|
|
100
100
|
resolveCache.clear();
|
|
101
101
|
};
|
|
102
102
|
|
package/src/index.js
CHANGED
package/src/svgo.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
export function detectSVGOVersion(
|
|
3
|
+
config: any,
|
|
4
|
+
): {|version: 3|} | {|version: 2, path: string|} {
|
|
5
|
+
if (!config) {
|
|
6
|
+
return {version: 3};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// These options were removed in v2.
|
|
10
|
+
if (config.full != null || config.svg2js != null) {
|
|
11
|
+
return {version: 2, path: config.full != null ? '/full' : '/svg2js'};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(config.plugins)) {
|
|
15
|
+
// Custom plugins in v2 had additional (required) fields that don't exist anymore.
|
|
16
|
+
let v2Plugin = config.plugins.findIndex(
|
|
17
|
+
p => p?.type != null || (p?.fn && p?.params != null),
|
|
18
|
+
);
|
|
19
|
+
if (v2Plugin !== -1) {
|
|
20
|
+
let field = config.plugins[v2Plugin].type != null ? 'type' : 'params';
|
|
21
|
+
return {version: 2, path: `/plugins/${v2Plugin}/${field}`};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// the cleanupIDs plugin lost the prefix option in v3.
|
|
25
|
+
let cleanupIdsIndex = config.plugins.findIndex(
|
|
26
|
+
p => p?.name === 'cleanupIDs',
|
|
27
|
+
);
|
|
28
|
+
let cleanupIDs =
|
|
29
|
+
cleanupIdsIndex !== -1 ? config.plugins[cleanupIdsIndex] : null;
|
|
30
|
+
if (cleanupIDs?.params?.prefix != null) {
|
|
31
|
+
return {version: 2, path: `/plugins/${cleanupIdsIndex}/params/prefix`};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Automatically migrate some options from SVGO 2 config files.
|
|
35
|
+
config.plugins = config.plugins.filter(p => p?.active !== false);
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < config.plugins.length; i++) {
|
|
38
|
+
let p = config.plugins[i];
|
|
39
|
+
if (p === 'cleanupIDs') {
|
|
40
|
+
config.plugins[i] = 'cleanupIds';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (p?.name === 'cleanupIDs') {
|
|
44
|
+
config.plugins[i].name = 'cleanupIds';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {version: 3};
|
|
50
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import assert from 'assert';
|
|
3
|
-
import randomInt from 'random-int';
|
|
4
3
|
|
|
5
4
|
import PromiseQueue from '../src/PromiseQueue';
|
|
6
5
|
import sinon from 'sinon';
|
|
@@ -66,7 +65,7 @@ describe('PromiseQueue', () => {
|
|
|
66
65
|
running++;
|
|
67
66
|
assert(queue._numRunning === running);
|
|
68
67
|
assert(running <= maxConcurrent);
|
|
69
|
-
await Promise.resolve(
|
|
68
|
+
await Promise.resolve(Math.floor(Math.random() * 10) + 1);
|
|
70
69
|
running--;
|
|
71
70
|
}),
|
|
72
71
|
);
|