From e1b82feb9cc27f55953b9237708800cb8c07724e Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Fri, 2 Oct 2020 08:07:48 -0400 Subject: [PATCH] fix: PostCSS 8 plugin loading --- package-lock.json | 45 +++++++------------ package.json | 4 +- src/utils.js | 2 + test/config-autoload.test.js | 2 +- .../js/array/postcss.config.js | 4 +- 5 files changed, 23 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09d0158f..f8d2f849 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12046,9 +12046,9 @@ "dev": true }, "postcss": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.0.1.tgz", - "integrity": "sha512-meEhwpdhLneP5AcfXDf1guY63DavkuWUBaHck9SNYrsobFKynrbAzdkFIevxAuQkQ9ZTrX7edt6iPJX6P37ZYA==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.1.1.tgz", + "integrity": "sha512-9DGLSsjooH3kSNjTZUOt2eIj2ZTW0VI2PZ/3My+8TC7KIbH2OKwUlISfDsf63EP4aiRUt3XkEWMWvyJHvJelEg==", "dev": true, "requires": { "colorette": "^1.2.1", @@ -12790,39 +12790,24 @@ } }, "postcss-nested": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-4.2.3.tgz", - "integrity": "sha512-rOv0W1HquRCamWy2kFl3QazJMMe1ku6rCFoAAH+9AcxdbpDeBr6k968MLWuLjvjMcGEip01ak09hKOEgpK9hvw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-5.0.1.tgz", + "integrity": "sha512-ZHNSAoHrMtbEzjq+Qs4R0gHijpXc6F1YUv4TGmGaz7rtfMvVJBbu5hMOH+CrhEaljQpEmx5N/P8i1pXTkbVAmg==", "dev": true, "requires": { - "postcss": "^7.0.32", - "postcss-selector-parser": "^6.0.2" + "postcss-selector-parser": "^6.0.4" }, "dependencies": { - "postcss": { - "version": "7.0.32", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.32.tgz", - "integrity": "sha512-03eXong5NLnNCD05xscnGKGDZ98CyzoqPSMjOe6SuoQY7Z2hIj0Ld1g/O/UQRuOle2aRtiIRDg9tDcTGAkLfKw==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "source-map": "^0.6.1", - "supports-color": "^6.1.0" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "postcss-selector-parser": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.4.tgz", + "integrity": "sha512-gjMeXBempyInaBqpp8gODmwZ52WaYsVOsfr4L4lDQ7n3ncD6mEyySiDtgzCT+NYC0mmeOLvtsF8iaEf0YT6dBw==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "cssesc": "^3.0.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1", + "util-deprecate": "^1.0.2" } } } diff --git a/package.json b/package.json index b353388e..81b909b5 100644 --- a/package.json +++ b/package.json @@ -72,11 +72,11 @@ "memfs": "^3.2.0", "midas": "^2.0.3", "npm-run-all": "^4.1.5", - "postcss": "^8.0.1", + "postcss": "^8.1.1", "postcss-dark-theme-class": "^0.4.0", "postcss-import": "^12.0.1", "postcss-js": "^2.0.0", - "postcss-nested": "^4.2.3", + "postcss-nested": "^5.0.1", "postcss-short": "^5.0.0", "prettier": "^2.1.1", "sass": "^1.26.10", diff --git a/src/utils.js b/src/utils.js index e5ab2a31..aa07c750 100644 --- a/src/utils.js +++ b/src/utils.js @@ -127,6 +127,8 @@ function pluginFactory() { const [name, options] = plugin; listOfPlugins.set(name, options); + } else if (plugin && typeof plugin === 'function') { + listOfPlugins.set(plugin); } else if ( plugin && Object.keys(plugin).length === 1 && diff --git a/test/config-autoload.test.js b/test/config-autoload.test.js index 6a8e2051..91d2b614 100644 --- a/test/config-autoload.test.js +++ b/test/config-autoload.test.js @@ -75,7 +75,7 @@ describe('autoload config', () => { expect(loadedConfig.config.to).toEqual( './test/fixtures/config-autoload/js/object/expect/index.css' ); - expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2); + expect(Object.keys(loadedConfig.config.plugins).length).toEqual(4); expect(loadedConfig.filepath).toEqual( path.resolve(testDirectory, 'js/array', 'postcss.config.js') ); diff --git a/test/fixtures/config-autoload/js/array/postcss.config.js b/test/fixtures/config-autoload/js/array/postcss.config.js index ae46c828..33b130ba 100644 --- a/test/fixtures/config-autoload/js/array/postcss.config.js +++ b/test/fixtures/config-autoload/js/array/postcss.config.js @@ -12,7 +12,9 @@ module.exports = function (api) { { // Options } - ] + ], + require('postcss-nested'), + require('postcss-nested')({ /* Options */ }), ] } };