postcss-discard-comments 8.0.3 → 9.0.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/package.json +7 -11
- package/src/index.js +7 -8
- package/src/lib/commentParser.js +4 -5
- package/src/lib/commentRemover.js +8 -7
- package/types/index.d.ts +15 -2
- package/types/index.d.ts.map +1 -1
- package/types/lib/commentParser.d.ts +9 -9
- package/types/lib/commentParser.d.ts.map +1 -1
- package/types/lib/commentRemover.d.ts +2 -2
- package/types/lib/commentRemover.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-discard-comments",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Discard comments in your CSS files with PostCSS.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./types/index.d.ts",
|
|
8
8
|
"default": "./src/index.js"
|
|
9
|
-
}
|
|
10
|
-
"./src": "./src/index.js",
|
|
11
|
-
"./src/index": "./src/index.js",
|
|
12
|
-
"./src/index.js": "./src/index.js",
|
|
13
|
-
"./src/lib/*": "./src/lib/*.js",
|
|
14
|
-
"./src/lib/*.js": "./src/lib/*.js",
|
|
15
|
-
"./package.json": "./package.json"
|
|
9
|
+
}
|
|
16
10
|
},
|
|
17
11
|
"files": [
|
|
18
12
|
"src",
|
|
@@ -34,7 +28,7 @@
|
|
|
34
28
|
},
|
|
35
29
|
"repository": {
|
|
36
30
|
"type": "git",
|
|
37
|
-
"url": "cssnano/cssnano"
|
|
31
|
+
"url": "git+https://github.com/cssnano/cssnano.git"
|
|
38
32
|
},
|
|
39
33
|
"dependencies": {
|
|
40
34
|
"postcss-selector-parser": "^7.1.5"
|
|
@@ -43,7 +37,7 @@
|
|
|
43
37
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
44
38
|
},
|
|
45
39
|
"engines": {
|
|
46
|
-
"node": "^22.
|
|
40
|
+
"node": "^22.22.3 || ^24.15.0 || >=26.0"
|
|
47
41
|
},
|
|
48
42
|
"devDependencies": {
|
|
49
43
|
"postcss": "^8.5.26",
|
|
@@ -53,7 +47,9 @@
|
|
|
53
47
|
"peerDependencies": {
|
|
54
48
|
"postcss": "^8.5.26"
|
|
55
49
|
},
|
|
50
|
+
"type": "module",
|
|
56
51
|
"scripts": {
|
|
57
|
-
"test": "node --test"
|
|
52
|
+
"test": "node --test",
|
|
53
|
+
"test:mutation": "node ../../util/mutation-testing/mutation-runner.mjs --catalog mutation-catalog.mjs"
|
|
58
54
|
}
|
|
59
55
|
}
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const selectorParser = require('postcss-selector-parser');
|
|
1
|
+
import CommentRemover from './lib/commentRemover.js';
|
|
2
|
+
import commentParser from './lib/commentParser.js';
|
|
3
|
+
import selectorParser from 'postcss-selector-parser';
|
|
5
4
|
|
|
6
5
|
/** @typedef {object} Options
|
|
7
6
|
* @property {boolean=} removeAll
|
|
@@ -245,8 +244,8 @@ function pluginCreator(opts = {}) {
|
|
|
245
244
|
},
|
|
246
245
|
};
|
|
247
246
|
}
|
|
248
|
-
|
|
247
|
+
/** @type {true} */
|
|
249
248
|
pluginCreator.postcss = true;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
const moduleExports = pluginCreator;
|
|
250
|
+
|
|
251
|
+
export { moduleExports as default, moduleExports as 'module.exports' };
|
package/src/lib/commentParser.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
// State machine states reused between parses for better perf
|
|
4
2
|
const STATES = {
|
|
5
3
|
NORMAL: 0,
|
|
@@ -94,7 +92,7 @@ function handleCommentState(context, nextChar) {
|
|
|
94
92
|
* @param {string} input
|
|
95
93
|
* @return {[number, number, number][]}
|
|
96
94
|
*/
|
|
97
|
-
|
|
95
|
+
function commentParser(input) {
|
|
98
96
|
/** @type {ParserContext} */
|
|
99
97
|
const context = {
|
|
100
98
|
input,
|
|
@@ -144,6 +142,7 @@ module.exports = function commentParser(input) {
|
|
|
144
142
|
// Add final non-comment token
|
|
145
143
|
context.tokens.push([0, context.tokenStart, context.length]);
|
|
146
144
|
}
|
|
147
|
-
|
|
148
145
|
return context.tokens;
|
|
149
|
-
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default commentParser;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class CommentRemover {
|
|
2
|
+
/** @type {boolean} */
|
|
3
|
+
#hasFirst;
|
|
4
|
+
|
|
4
5
|
/** @param {import('../index.js').Options} options */
|
|
5
6
|
constructor(options) {
|
|
6
7
|
this.options = options;
|
|
8
|
+
this.#hasFirst = false;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* @param {string} comment
|
|
@@ -21,15 +23,14 @@ class CommentRemover {
|
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
if (this.options.removeAll || this
|
|
26
|
+
if (this.options.removeAll || this.#hasFirst) {
|
|
25
27
|
return true;
|
|
26
|
-
} else if (this.options.removeAllButFirst && !this
|
|
27
|
-
this
|
|
28
|
+
} else if (this.options.removeAllButFirst && !this.#hasFirst) {
|
|
29
|
+
this.#hasFirst = true;
|
|
28
30
|
return false;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
return false;
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
module.exports = CommentRemover;
|
|
36
|
+
export default CommentRemover;
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
declare const _exports: import("postcss").PluginCreator<Options>;
|
|
2
|
-
export = _exports;
|
|
3
1
|
export type Options = {
|
|
4
2
|
removeAll?: boolean | undefined;
|
|
5
3
|
removeAllButFirst?: boolean | undefined;
|
|
6
4
|
remove?: ((s: string) => boolean) | undefined;
|
|
7
5
|
};
|
|
6
|
+
/** @typedef {object} Options
|
|
7
|
+
* @property {boolean=} removeAll
|
|
8
|
+
* @property {boolean=} removeAllButFirst
|
|
9
|
+
* @property {(s: string) => boolean=} remove
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @param {Options} opts
|
|
13
|
+
* @return {import('postcss').Plugin}
|
|
14
|
+
*/
|
|
15
|
+
declare function pluginCreator(opts?: Options): import('postcss').Plugin;
|
|
16
|
+
declare namespace pluginCreator {
|
|
17
|
+
var postcss: true;
|
|
18
|
+
}
|
|
19
|
+
declare const moduleExports: typeof pluginCreator;
|
|
20
|
+
export { moduleExports as default, moduleExports as 'module.exports' };
|
|
8
21
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAII,YAAkB,OAAO,GACzB;IAAqB,SAAS,AAA9B,CACA,EADW,OAAO,YAAC,CACnB;IAAqB,iBAAiB,AAAtC,CACA,EADW,OAAO,YAAC,CACnB;IAAoC,MAAM,AAA1C,CACH,EADc,CAAA,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,aAAC,CACrC;CAAA,CAAA;AAJD;;;;GAIG;AACH;;;GAGG;AACH,iBAAS,aAAa,CAAC,IAAI,GAHhB,OAGqB,GAFpB,OAAO,SAAS,EAAE,MAAM,CA0OnC;kBAxOQ,aAAa;iBAyOX,IAAI;;AAEf,QAAA,MAAM,aAAa,sBAAgB,CAAC;AAEpC,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export = commentParser;
|
|
2
|
-
/**
|
|
3
|
-
* CSS Comment Parser with context awareness
|
|
4
|
-
* Properly handles comments inside strings, URLs, and escaped characters
|
|
5
|
-
*
|
|
6
|
-
* @param {string} input
|
|
7
|
-
* @return {[number, number, number][]}
|
|
8
|
-
*/
|
|
9
|
-
declare function commentParser(input: string): [number, number, number][];
|
|
10
1
|
export type ParserContext = {
|
|
11
2
|
input: string;
|
|
12
3
|
tokens: [number, number, number][];
|
|
@@ -16,4 +7,13 @@ export type ParserContext = {
|
|
|
16
7
|
tokenStart: number;
|
|
17
8
|
commentStart: number;
|
|
18
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* CSS Comment Parser with context awareness
|
|
12
|
+
* Properly handles comments inside strings, URLs, and escaped characters
|
|
13
|
+
*
|
|
14
|
+
* @param {string} input
|
|
15
|
+
* @return {[number, number, number][]}
|
|
16
|
+
*/
|
|
17
|
+
declare function commentParser(input: string): [number, number, number][];
|
|
18
|
+
export default commentParser;
|
|
19
19
|
//# sourceMappingURL=commentParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commentParser.d.ts","sourceRoot":"","sources":["../../src/lib/commentParser.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commentParser.d.ts","sourceRoot":"","sources":["../../src/lib/commentParser.js"],"names":[],"mappings":"AASG,YAAkB,aAAa,GAC/B;IAAmB,KAAK,EAAb,MAAM,CACjB;IAAuC,MAAM,EAAlC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CACrC;IAAmB,MAAM,EAAd,MAAM,CACjB;IAAmB,GAAG,EAAX,MAAM,CACjB;IAAmB,KAAK,EAAb,MAAM,CACjB;IAAmB,UAAU,EAAlB,MAAM,CACjB;IAAmB,YAAY,EAApB,MAAM,CACnB;CAAA,CAAA;AAsED;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,KAAK,EAHjB,MAGiB,GAFhB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAqDrC;eAEc,aAAa"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export = CommentRemover;
|
|
2
1
|
declare class CommentRemover {
|
|
2
|
+
#private;
|
|
3
3
|
options: import("../index.js").Options;
|
|
4
|
-
_hasFirst: boolean | undefined;
|
|
5
4
|
/** @param {import('../index.js').Options} options */
|
|
6
5
|
constructor(options: import('../index.js').Options);
|
|
7
6
|
/**
|
|
@@ -10,4 +9,5 @@ declare class CommentRemover {
|
|
|
10
9
|
*/
|
|
11
10
|
canRemove(comment: string): boolean | undefined;
|
|
12
11
|
}
|
|
12
|
+
export default CommentRemover;
|
|
13
13
|
//# sourceMappingURL=commentRemover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commentRemover.d.ts","sourceRoot":"","sources":["../../src/lib/commentRemover.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commentRemover.d.ts","sourceRoot":"","sources":["../../src/lib/commentRemover.js"],"names":[],"mappings":"AAAA,cAAM,cAAc;;IAMX,OAAO;IAFd,qDAAqD;IACrD,YAAY,OAAO,EADP,OAAO,aAAa,EAAE,OACf,EAGlB;IACD;;;OAGG;IACH,SAAS,CAAC,OAAO,EAHN,MAGM,GAFL,OAAO,GAAG,SAAS,CAsB9B;CACF;eACc,cAAc"}
|