Skip to content

Commit

Permalink
chore(deps): replace cosmiconfig with lilconfig
Browse files Browse the repository at this point in the history
Remove about 22 dependencies according to npm i --production (from 110 to 88 deps)

* reduce node_modules after `yarn install cssnano` in empty project from 14MB to 13MB
* add YAML dep to preserve YAML configuration compatibility
  YAML configuration was only implicitly documented by referring to cosmiconfig,
  but removing it would be a breaking change
  • Loading branch information
ludofischer committed Jul 18, 2021
1 parent 786969b commit a1db6ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/cssnano/package.json
Expand Up @@ -24,7 +24,8 @@
],
"license": "MIT",
"dependencies": {
"cosmiconfig": "^7.0.0",
"lilconfig": "^2.0.3",
"yaml": "^1.10.2",
"cssnano-preset-default": "^5.1.3",
"is-resolvable": "^1.1.0"
},
Expand Down
12 changes: 9 additions & 3 deletions packages/cssnano/src/index.js
@@ -1,6 +1,7 @@
import path from 'path';
import postcss from 'postcss';
import { cosmiconfigSync } from 'cosmiconfig';
import yaml from 'yaml';
import { lilconfigSync } from 'lilconfig';
import isResolvable from 'is-resolvable';

const cssnano = 'cssnano';
Expand Down Expand Up @@ -59,7 +60,7 @@ function resolvePreset(preset) {

/*
* cssnano will look for configuration firstly as options passed
* directly to it, and failing this it will use cosmiconfig to
* directly to it, and failing this it will use lilconfig to
* load an external file.
*/

Expand All @@ -76,7 +77,12 @@ function resolveConfig(options) {
configPath = path.resolve(process.cwd(), options.configFile);
}

const configExplorer = cosmiconfigSync(cssnano);
const configExplorer = lilconfigSync(cssnano, {
loaders: {
'.yaml': (filepath, content) => yaml.parse(content),
'.yml': (filepath, content) => yaml.parse(content),
},
});
const config = configPath
? configExplorer.load(configPath)
: configExplorer.search(searchPath);
Expand Down
16 changes: 11 additions & 5 deletions yarn.lock
Expand Up @@ -6325,6 +6325,11 @@ libnpmpublish@^4.0.0:
semver "^7.1.3"
ssri "^8.0.1"

lilconfig@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.3.tgz#68f3005e921dafbd2a2afb48379986aa6d2579fd"
integrity sha512-EHKqr/+ZvdKCifpNrJCKxBTgk5XupZA3y/aCPY9mxfgBzmgh93Mt/WqjjQ38oMxXuvDokaKiM3lAgvSH2sjtHg==

lines-and-columns@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
Expand Down Expand Up @@ -7942,12 +7947,13 @@ postcss-font-magician@^3.0.0:
google-fonts-complete "^2.1.1"

postcss-load-config@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.0.1.tgz#d214bf9cfec1608ffaf0f4161b3ba20664ab64b9"
integrity sha512-/pDHe30UYZUD11IeG8GWx9lNtu1ToyTsZHnyy45B4Mrwr/Kb6NgYl7k753+05CJNKnjbwh4975amoPJ+TEjHNQ==
version "3.1.0"
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.0.tgz#d39c47091c4aec37f50272373a6a648ef5e97829"
integrity sha512-ipM8Ds01ZUophjDTQYSVP70slFSYg3T0/zyfII5vzhN6V57YSxMgG5syXuwi5VtS8wSf3iL30v0uBdoIVx4Q0g==
dependencies:
cosmiconfig "^7.0.0"
import-cwd "^3.0.0"
lilconfig "^2.0.3"
yaml "^1.10.2"

postcss-reporter@^1.3.0:
version "1.4.1"
Expand Down Expand Up @@ -10270,7 +10276,7 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@^1.10.0:
yaml@^1.10.0, yaml@^1.10.2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
Expand Down

0 comments on commit a1db6ff

Please sign in to comment.