Skip to content

Commit

Permalink
Pnpm (#1269)
Browse files Browse the repository at this point in the history
* fix(cssnano): drop is-resolvable dep

Using is-resolvable as a dep does not work inside pnpm monorepos.
Inlining the code solves the issue.

* chore: switch from yarn to pnpm
  • Loading branch information
ludofischer committed Dec 18, 2021
1 parent 277a4d9 commit 6f9c747
Show file tree
Hide file tree
Showing 50 changed files with 13,904 additions and 12,825 deletions.
37 changes: 31 additions & 6 deletions .github/workflows/test.yml
Expand Up @@ -12,17 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6.24.0
- name: Install Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Run lint
run: yarn lint
run: pnpm lint

test:
needs: lint
Expand All @@ -39,20 +43,41 @@ jobs:

- uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2
if: matrix.node-version != '10'
with:
version: 6.24.0

- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
if: matrix.node-version != '10'
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install old pnpm
uses: pnpm/action-setup@v2
if: matrix.node-version == '10'
with:
version: 5.18.4

# No cache support on GH actions for old pnpm
- name: Install Node.js without cache ${{ matrix.node-version }}
uses: actions/setup-node@v2
if: matrix.node-version == '10'
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests with coverage
run: yarn test:coverage
run: pnpm test:coverage

- name: Publish code coverage report
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '16'
uses: codecov/codecov-action@v2
with:
name: codecov

20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Expand Up @@ -9,19 +9,19 @@ you add yourself to the list of contributors, found in [CONTRIBUTORS.md].
## How can I contribute to cssnano's code?

Since version 4, we develop in a monorepo. This is because a lot of transforms overlap with each other; it's
easier to test them together. Other than this, you'll need Node.js, yarn &
easier to test them together. Other than this, you'll need Node.js, pnpm &
git installed. Then, you can run these commands to get the repository set up:

```
git clone git@github.com:cssnano/cssnano.git
cd cssnano
yarn install
pnpm install
```

You can run the tests with:

```
yarn test
pnpm test
```

We recommend that you look in the issue tracker to find anything tagged
Expand All @@ -38,9 +38,9 @@ To help us generate the changelog, follow the [conventional commits](https://www
### Documentation

The documentation website is also included with the repository, under `/site`.
It runs [docusaurus](https://docusaurus.io) and requires a separate `yarn install`
It runs [docusaurus](https://docusaurus.io) and requires a separate `pnpm install`
to pull down the dependencies. You can then browse the documentation locally
by running `yarn start`.
by running `pnpm start`.

Note that some of the documentation is automatically generated and should not
be edited by hand.
Expand All @@ -53,7 +53,7 @@ with the description of the change and the affected packages.
To create a changeset run

```
yarn changeset
pnpm changeset
```

It's best to select the affected packages by hand rather than rely on the tools automatically
Expand All @@ -62,19 +62,19 @@ select the plugin and `cssnano-preset-default` by hand (as well as any other dep
To tag a release and generate the changelog, run:

```
yarn changeset version
pnpm changeset version
```

To publish release to npm, run:

```
yarn all-publish
pnpm all-publish
```

If you don't use the `package.json` script, do not forget to rebuild the packages first!

1. `yarn prepare`
2. `yarn changeset publish`
1. `pnpm prepare`
2. `pnpm changeset publish`

## Are there other ways of contributing?

Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -3,14 +3,14 @@
"private": true,
"scripts": {
"lint": "eslint . --cache --ignore-path .gitignore --ext .js,.mjs",
"fixlint": "yarn lint -- --fix",
"prepare": "yarn workspaces run prepare",
"fixlint": "pnpm lint -- --fix",
"prepare": "pnpm run -r prepare",
"build:integration": "node ./util/buildFrameworks.mjs",
"pretest": "yarn lint",
"pretest": "pnpm lint",
"test:only": "uvu -r @babel/register packages \"__tests__.*\\.js$\"",
"test:coverage": "c8 yarn test:only",
"test": "yarn test:coverage",
"all-publish": "yarn prepare && yarn changeset publish"
"test:coverage": "c8 pnpm test:only",
"test": "pnpm test:coverage",
"all-publish": "pnpm prepare && pnpm changeset publish"
},
"workspaces": [
"./packages/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/css-size/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cssnano-preset-advanced/package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cssnano-preset-default/package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cssnano-preset-lite/package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cssnano-utils/package.json
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"homepage": "https://github.com/cssnano/cssnano",
"bugs": {
Expand Down
3 changes: 1 addition & 2 deletions packages/cssnano/package.json
Expand Up @@ -7,7 +7,7 @@
"bundle-size": "webpack --json --config src/__tests__/_webpack.config.js | webpack-bundle-size-analyzer",
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"funding": {
"type": "opencollective",
Expand All @@ -25,7 +25,6 @@
"license": "MIT",
"dependencies": {
"cssnano-preset-default": "^5.1.9",
"is-resolvable": "^1.1.0",
"lilconfig": "^2.0.3",
"yaml": "^1.10.2"
},
Expand Down
14 changes: 13 additions & 1 deletion packages/cssnano/src/index.js
Expand Up @@ -2,10 +2,22 @@ import path from 'path';
import postcss from 'postcss';
import yaml from 'yaml';
import { lilconfigSync } from 'lilconfig';
import isResolvable from 'is-resolvable';

const cssnano = 'cssnano';

/*
* @param {string} moduleId
* @returns {boolean}
*/
function isResolvable(moduleId) {
try {
require.resolve(moduleId);
return true;
} catch (e) {
return false;
}
}

/*
* preset can be one of four possibilities:
* preset = 'default'
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-colormin/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"color",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-convert-values/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-discard-comments/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-discard-duplicates/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-discard-empty/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"compress",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-discard-overridden/package.json
Expand Up @@ -25,7 +25,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"engines": {
"node": "^10 || ^12 || >=14.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-discard-unused/package.json
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-merge-idents/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-merge-longhand/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-merge-rules/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-minify-font-values/package.json
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"engines": {
"node": "^10 || ^12 || >=14.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-minify-gradients/package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-minify-params/package.json
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"engines": {
"node": "^10 || ^12 || >=14.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-minify-selectors/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-normalize-charset/package.json
Expand Up @@ -22,7 +22,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"engines": {
"node": "^10 || ^12 || >=14.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-normalize-display-values/package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"files": [
"LICENSE-MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-normalize-positions/package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"keywords": [
"css",
Expand Down

0 comments on commit 6f9c747

Please sign in to comment.