postcss-normalize-charset 8.0.4 → 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 CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "postcss-normalize-charset",
3
- "version": "8.0.4",
3
+ "version": "9.0.0",
4
4
  "description": "Add necessary or remove extra charset 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
- "./package.json": "./package.json"
9
+ }
14
10
  },
15
11
  "keywords": [
16
12
  "postcss",
@@ -34,7 +30,7 @@
34
30
  },
35
31
  "homepage": "https://github.com/cssnano/cssnano",
36
32
  "engines": {
37
- "node": "^22.11.0 || ^24.11.0 || >=26.0"
33
+ "node": "^22.22.3 || ^24.15.0 || >=26.0"
38
34
  },
39
35
  "devDependencies": {
40
36
  "postcss": "^8.5.26"
@@ -42,6 +38,7 @@
42
38
  "peerDependencies": {
43
39
  "postcss": "^8.5.26"
44
40
  },
41
+ "type": "module",
45
42
  "scripts": {
46
43
  "test": "node --test"
47
44
  }
package/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
- 'use strict';
2
1
  const charset = 'charset';
3
2
  // eslint-disable-next-line no-control-regex
4
3
  const nonAscii = /[^\x00-\x7F]/;
@@ -23,11 +22,16 @@ function pluginCreator(opts = {}) {
23
22
  let charsetRule;
24
23
  /** @type {import('postcss').Node | undefined} */
25
24
  let nonAsciiNode;
25
+ /** @type {string | undefined} */
26
+ let charsetSeparator;
26
27
 
27
28
  css.walk((node) => {
28
29
  if (node.type === 'atrule' && node.name === charset) {
29
30
  if (!charsetRule) {
30
31
  charsetRule = node;
32
+ if (node === css.first) {
33
+ charsetSeparator = node.next()?.raws.before;
34
+ }
31
35
  }
32
36
  node.remove();
33
37
  } else if (
@@ -49,13 +53,17 @@ function pluginCreator(opts = {}) {
49
53
  if (charsetRule) {
50
54
  charsetRule.source = nonAsciiNode.source;
51
55
  css.prepend(charsetRule);
56
+ const nextNode = charsetRule.next();
57
+ if (charsetSeparator !== undefined && nextNode) {
58
+ nextNode.raws.before = charsetSeparator;
59
+ }
52
60
  }
53
61
  }
54
62
  },
55
63
  };
56
64
  }
57
-
65
+ /** @type {true} */
58
66
  pluginCreator.postcss = true;
59
- module.exports = /** @type {import('postcss').PluginCreator<Options>}*/ (
60
- pluginCreator
61
- );
67
+ const moduleExports = pluginCreator;
68
+
69
+ export { moduleExports as default, moduleExports as 'module.exports' };
package/types/index.d.ts CHANGED
@@ -1,6 +1,17 @@
1
- declare const _exports: import("postcss").PluginCreator<Options>;
2
- export = _exports;
3
1
  export type Options = {
4
2
  add?: boolean;
5
3
  };
4
+ /**
5
+ * @typedef {{add?: boolean}} Options
6
+ */
7
+ /**
8
+ * @param {Options} opts
9
+ * @return {import('postcss').Plugin}
10
+ */
11
+ declare function pluginCreator(opts?: Options): import('postcss').Plugin;
12
+ declare namespace pluginCreator {
13
+ var postcss: true;
14
+ }
15
+ declare const moduleExports: typeof pluginCreator;
16
+ export { moduleExports as default, moduleExports as 'module.exports' };
6
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;AAMG,YAA2B,OAAO,GAAxB;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAC,CAAS"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAKG,YAA2B,OAAO,GAAxB;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAC,CAAS;AADrC;;GAEG;AACH;;;GAGG;AACH,iBAAS,aAAa,CAAC,IAAI,GAHhB,OAGqB,GAFpB,OAAO,SAAS,EAAE,MAAM,CAsDnC;kBApDQ,aAAa;iBAqDX,IAAI;;AAEf,QAAA,MAAM,aAAa,sBAAgB,CAAC;AAEpC,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}