Skip to content

feat: test each postcss major version #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
435 changes: 422 additions & 13 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/postcss-if-function/.npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*
/*/
!/dist/
examples/
scripts/
2 changes: 1 addition & 1 deletion packages/postcss-if-function/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ module.exports = {

- **Style Functions Not Supported**: This plugin only transforms `media()` and `supports()` functions. For `style()` functions (which depend on runtime DOM state), use the [css-if-polyfill](https://github.com/mfranzke/css-if-polyfill/tree/main/packages/css-if-polyfill/) runtime (browser) library
- **Static Analysis Only**: The plugin performs static analysis and cannot handle dynamically generated CSS
- **PostCSS Compatibility**: Requires PostCSS 8.0.0 or higher
- **PostCSS Compatibility**: Compatible with PostCSS 7 and 8. Automatically detects and adapts to the PostCSS version in use.

## Integration with Runtime Polyfill

Expand Down
61 changes: 61 additions & 0 deletions packages/postcss-if-function/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PostCSS Version Compatibility Testing

This directory contains test environments for different major versions of PostCSS to ensure our plugin works across multiple versions.

## Structure

- `postcss-version-7/` - Test environment for PostCSS v7.x
- `postcss-version-8/` - Test environment for PostCSS v8.x

Each directory contains:

- `package.json` - Specific PostCSS version dependency
- `test.test.js` - Test suite with comprehensive functionality tests
- `vitest.config.js` - Test configuration with version-specific environment

## Usage

### Run all version tests

```bash
npm run test:versions
```

### Run specific version tests

```bash
npm run test:version-7
npm run test:version-8
```

### Update peer dependencies package.json entry based on test results

```bash
npm run update:peer-deps
```

## How it works

1. Each test environment runs the same comprehensive test suite against different PostCSS versions
2. Tests verify core functionality: media() and supports() transformations, complex queries, comments handling, etc.
3. The `update:peer-deps` script runs all version tests and updates the `peerDependencies` field in package.json based on which versions pass
4. This ensures the peerDependencies range only includes actually tested and working versions
5. The plugin automatically detects and adapts to the PostCSS version being used

## Adding new PostCSS versions

To add support for a new PostCSS version:

1. Create a new directory: `postcss-version-X/`
2. Copy the structure from an existing version directory
3. Update the PostCSS version in the new `package.json`
4. Update the version number in `vitest.config.js`
5. Add the new version to the `versions` array in `../scripts/update-peer-deps.js`
6. Add a test script in the main `package.json`

## Current Compatibility

✅ **PostCSS 7.x** - Fully supported
✅ **PostCSS 8.x** - Fully supported

The plugin uses a hybrid approach that automatically detects the PostCSS version and adapts its API usage accordingly.
Loading
Loading