postcss-reduce-initial 6.0.3 → 6.1.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,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-reduce-initial",
3
- "version": "6.0.3",
3
+ "version": "6.1.0",
4
4
  "description": "Reduce initial definitions to the actual initial value, where possible.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
package/src/index.js CHANGED
@@ -1,14 +1,21 @@
1
1
  'use strict';
2
+ const { dirname } = require('path');
2
3
  const browserslist = require('browserslist');
3
4
  const { isSupported } = require('caniuse-api');
4
5
  const fromInitial = require('./data/fromInitial.json');
5
6
  const toInitial = require('./data/toInitial.json');
7
+ const ignoreProps = require('./lib/ignoreProps.js');
6
8
 
7
9
  const initial = 'initial';
8
10
 
9
11
  // In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
10
- const defaultIgnoreProps = ['writing-mode', 'transform-box'];
11
- /** @typedef {{ignore?: string[]}} Options */
12
+ const defaultIgnoreProps = ignoreProps;
13
+
14
+ /**
15
+ * @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
16
+ * @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
17
+ * @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options
18
+ */
12
19
 
13
20
  /**
14
21
  * @type {import('postcss').PluginCreator<Options>}
@@ -18,13 +25,16 @@ const defaultIgnoreProps = ['writing-mode', 'transform-box'];
18
25
  function pluginCreator(options = {}) {
19
26
  return {
20
27
  postcssPlugin: 'postcss-reduce-initial',
21
- /** @param {import('postcss').Result & {opts: browserslist.Options & {ignore?: string[]}}} result */
28
+
29
+ /**
30
+ * @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result
31
+ */
22
32
  prepare(result) {
23
- const resultOpts = result.opts || {};
24
- const browsers = browserslist(null, {
25
- stats: resultOpts.stats,
26
- path: __dirname,
27
- env: resultOpts.env,
33
+ const { stats, env, from, file } = result.opts || {};
34
+ const browsers = browserslist(options.overrideBrowserslist, {
35
+ stats: options.stats || stats,
36
+ path: options.path || dirname(from || file || __filename),
37
+ env: options.env || env,
28
38
  });
29
39
 
30
40
  const initialSupport = isSupported('css-initial-value', browsers);
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ module.exports = ['writing-mode', 'transform-box'];
package/types/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export = pluginCreator;
2
- /** @typedef {{ignore?: string[]}} Options */
2
+ /**
3
+ * @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
4
+ * @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
5
+ * @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options
6
+ */
3
7
  /**
4
8
  * @type {import('postcss').PluginCreator<Options>}
5
9
  * @param {Options} options
@@ -7,9 +11,15 @@ export = pluginCreator;
7
11
  */
8
12
  declare function pluginCreator(options?: Options): import('postcss').Plugin;
9
13
  declare namespace pluginCreator {
10
- export { postcss, Options };
14
+ export { postcss, AutoprefixerOptions, BrowserslistOptions, Options };
11
15
  }
12
16
  type Options = {
13
17
  ignore?: string[];
14
- };
18
+ } & AutoprefixerOptions & BrowserslistOptions;
15
19
  declare var postcss: true;
20
+ type AutoprefixerOptions = {
21
+ overrideBrowserslist?: string | string[];
22
+ };
23
+ type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>;
24
+ import browserslist = require("browserslist");
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAaA;;;;GAIG;AAEH;;;;GAIG;AACH,yCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CAsDnC;;;;eA5DY;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,GAAG,mBAAmB,GAAG,mBAAmB;;2BAF/D;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;2BAC5C,KAAK,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _exports: string[];
2
+ export = _exports;
3
+ //# sourceMappingURL=ignoreProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignoreProps.d.ts","sourceRoot":"","sources":["../../src/lib/ignoreProps.js"],"names":[],"mappings":""}