diff --git a/exports/index.js b/exports/index.js index dde9ea2..75484d3 100644 --- a/exports/index.js +++ b/exports/index.js @@ -7,3 +7,5 @@ import DoIUse from '../lib/DoIUse.js'; export default function index(...options) { return new DoIUse(...options); } + +index.postcss = new DoIUse().postcss; diff --git a/package-lock.json b/package-lock.json index 1f8219e..3d194ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "doiuse", - "version": "6.0.1", + "version": "6.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "doiuse", - "version": "6.0.1", + "version": "6.0.2", "license": "MIT", "dependencies": { "browserslist": "^4.21.5", @@ -41,6 +41,7 @@ "eslint-plugin-unicorn": "^47.0.0", "mock-fs": "^4.14.0", "postcss-import": "^14.1.0", + "postcss-load-config": "^4.0.1", "rollup": "^2.79.1", "safe-regex": "^2.1.1", "tap": "^16.3.4", @@ -3999,6 +4000,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/lilconfig": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", + "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -4916,6 +4926,44 @@ "postcss": "^8.0.0" } }, + "node_modules/postcss-load-config": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.1.tgz", + "integrity": "sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==", + "dev": true, + "dependencies": { + "lilconfig": "^2.0.5", + "yaml": "^2.1.1" + }, + "engines": { + "node": ">= 14" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/postcss-load-config/node_modules/yaml": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", + "dev": true, + "engines": { + "node": ">= 14" + } + }, "node_modules/postcss-value-parser": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", diff --git a/package.json b/package.json index c82d589..3161094 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "eslint-plugin-unicorn": "^47.0.0", "mock-fs": "^4.14.0", "postcss-import": "^14.1.0", + "postcss-load-config": "^4.0.1", "rollup": "^2.79.1", "safe-regex": "^2.1.1", "tap": "^16.3.4", diff --git a/test/fixtures/.postcssrc.json b/test/fixtures/.postcssrc.json new file mode 100644 index 0000000..9ffa003 --- /dev/null +++ b/test/fixtures/.postcssrc.json @@ -0,0 +1,5 @@ +{ + "plugins": { + "doiuse": {} + } +} \ No newline at end of file diff --git a/test/postcss-plugin.js b/test/postcss-plugin.js index 271c500..52e7ca3 100644 --- a/test/postcss-plugin.js +++ b/test/postcss-plugin.js @@ -7,6 +7,7 @@ import postcss from 'postcss'; import atImport from 'postcss-import'; import { test } from 'tap'; +import postcssrc from 'postcss-load-config'; import DoIUse from '../lib/DoIUse.js'; import { hasKeys } from './utils.js'; @@ -149,3 +150,11 @@ test('info with no browserslist file or browsers config', (t) => { t.end(); }); + +test('loads postcss plugin with an empty configuration object using postcss-load-config', async (t) => { + const { plugins } = await postcssrc(null, fileURLToPath(`${import.meta.url}/../fixtures/.postcssrc.json`)); + const { messages } = await postcss(plugins).process('html { display: flex }'); + + t.equal(messages[0].text, 'CSS Flexible Box Layout Module only partially supported by: IE (11) (flexbox)'); + t.end(); +});