Skip to content

Commit

Permalink
feat: postcss@8 support (#789)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: postcss@8 drops support for node version 6.x, 8.x, 11.x, and 13.x.
  • Loading branch information
tivac committed Feb 25, 2021
1 parent 88d643e commit 340a38e
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 38 deletions.
458 changes: 445 additions & 13 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@modular-css/glob": "file:../glob",
"@modular-css/processor": "file:../processor",
"meow": "^7.0.1",
"meow": "^9.0.0",
"mkdirp": "^1.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/postcss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PostCSS plugin to use [`modular-css`](https://github.com/tivac/modular-css) with
## Install

```bash
> npm i @modular-css/postcss
> npm i @modular-css/postcss postcss
```

## Usage
Expand Down
6 changes: 4 additions & 2 deletions packages/postcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
],
"dependencies": {
"@modular-css/processor": "file:../processor",
"mkdirp": "^1.0.3",
"postcss": "^7.0.0"
"mkdirp": "^1.0.3"
},
"peerDependencies": {
"postcss": "^8.0.0"
}
}
12 changes: 7 additions & 5 deletions packages/postcss/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

const fs = require("fs");
const path = require("path");
const postcss = require("postcss");
const mkdirp = require("mkdirp");

const Processor = require("@modular-css/processor");
const { json : createJson } = require("@modular-css/processor/lib/output.js");

module.exports = postcss.plugin("modular-css", (opts = {}) =>
async (root, result) => {
module.exports = (opts = {}) => ({
postcssPlugin : "modular-css-postcss",
Once : async (root, { result }) => {
const processor = new Processor({
__proto__ : null,
...opts,
Expand Down Expand Up @@ -49,5 +49,7 @@ module.exports = postcss.plugin("modular-css", (opts = {}) =>
}

return output;
}
);
},
});

module.exports.postcss = true;
6 changes: 2 additions & 4 deletions packages/postcss/test/__snapshots__/postcss.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ exports[`/postcss.js should accept json args in either position with postcss 1`]

exports[`/postcss.js should accept normal processor options 1`] = `
".fooga_wooga { color: red; }
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBhY2thZ2VzL3Bvc3Rjc3MvdGVzdC9zcGVjaW1lbnMvc2ltcGxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxlQUFTLFVBQVUsRUFBRSIsImZpbGUiOiJwYWNrYWdlcy9wb3N0Y3NzL3Rlc3Qvc3BlY2ltZW5zL3NpbXBsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIud29vZ2EgeyBjb2xvcjogcmVkOyB9XG4iXX0= */"
"
`;

exports[`/postcss.js should be usable like a normal postcss plugin 1`] = `
".a { color: red; }
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBhY2thZ2VzL3Bvc3Rjc3MvdGVzdC9zcGVjaW1lbnMvc2ltcGxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxLQUFTLFVBQVUsRUFBRSIsImZpbGUiOiJwYWNrYWdlcy9wb3N0Y3NzL3Rlc3Qvc3BlY2ltZW5zL3NpbXBsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIud29vZ2EgeyBjb2xvcjogcmVkOyB9XG4iXX0= */"
"
`;

exports[`/postcss.js should output json when used within postcss 1`] = `
Expand Down
10 changes: 3 additions & 7 deletions packages/postcss/test/postcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const namer = require("@modular-css/test-utils/namer.js");
const plugin = require("../postcss.js");

function process(file, opts = {}) {
return plugin.process(
const processor = postcss().use(plugin);

return processor.process(
fs.readFileSync(file),
{
__proto__ : null,
Expand Down Expand Up @@ -46,9 +48,6 @@ describe("/postcss.js", () => {

it("should accept normal processor options", async () => {
const { css } = await process("./packages/postcss/test/specimens/simple.css", {
map : {
inline : true,
},
namer : (f, s) => `fooga_${s}`,
});

Expand Down Expand Up @@ -89,9 +88,6 @@ describe("/postcss.js", () => {
fs.readFileSync("./packages/postcss/test/specimens/simple.css"),
{
from : "./packages/postcss/test/specimens/simple.css",
map : {
inline : true,
},
}
);

Expand Down
8 changes: 4 additions & 4 deletions packages/processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"postcss"
],
"dependencies": {
"dependency-graph": "^0.9.0",
"dependency-graph": "^0.10.0",
"escape-string-regexp": "^4.0.0",
"lodash": "^4.17.0",
"postcss": "^7.0.0",
"postcss": "^8.0.0",
"postcss-selector-parser": "^6.0.2",
"postcss-url": "^8.0.0",
"postcss-url": "^10.0.0",
"postcss-value-parser": "^4.0.0",
"resolve-from": "^5.0.0",
"unique-slug": "^2.0.0"
},
"peerDependencies": {
"postcss": "^7.0.0"
"postcss": "^8.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"esutils": "^2.0.2",
"loader-utils": "^2.0.0",
"lodash": "^4.17.0",
"webpack-sources": "^1.0.1"
"webpack-sources": "^2.0.0"
}
}

0 comments on commit 340a38e

Please sign in to comment.