Skip to content
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

Ensure to transpile the PostCSS Nesting plugin (tailwindcss/nesting) #7080

Merged
merged 4 commits into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Ensure to transpile the PostCSS Nesting plugin (tailwindcss/nesting) ([#7080](https://github.com/tailwindlabs/tailwindcss/pull/7080))

## [3.0.15] - 2022-01-15

Expand Down
14 changes: 2 additions & 12 deletions nesting/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
let nesting = require('./plugin')

module.exports = (opts) => {
return {
postcssPlugin: 'tailwindcss/nesting',
Once(root, { result }) {
return nesting(opts)(root, result)
},
}
}

module.exports.postcss = true
let nesting = require('../lib/postcss-plugins/nesting')
module.exports = (nesting.__esModule ? nesting : { default: nesting }).default
File renamed without changes.
13 changes: 13 additions & 0 deletions src/postcss-plugins/nesting/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { nesting } from './plugin'

export default Object.assign(
function (opts) {
return {
postcssPlugin: 'tailwindcss/nesting',
Once(root, { result }) {
return nesting(opts)(root, result)
},
}
},
{ postcss: true }
)
8 changes: 4 additions & 4 deletions nesting/plugin.js → src/postcss-plugins/nesting/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let postcss = require('postcss')
let postcssNested = require('postcss-nested')
import postcss from 'postcss'
import postcssNested from 'postcss-nested'

module.exports = function nesting(opts = postcssNested) {
export function nesting(opts = postcssNested) {
return (root, result) => {
root.walkAtRules('screen', (rule) => {
rule.name = 'media'
Expand All @@ -16,7 +16,7 @@ module.exports = function nesting(opts = postcssNested) {
let plugin = (() => {
if (
typeof opts === 'function' ||
(typeof opts === 'object' && opts.hasOwnProperty('postcssPlugin'))
(typeof opts === 'object' && opts?.hasOwnProperty?.('postcssPlugin'))
) {
return opts
}
Expand Down
6 changes: 3 additions & 3 deletions tests/postcss-plugins/nesting/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let postcss = require('postcss')
let postcssNested = require('postcss-nested')
let plugin = require('../../../nesting')
import postcss from 'postcss'
import postcssNested from 'postcss-nested'
import plugin from '../../../src/postcss-plugins/nesting'

it('should be possible to load a custom nesting plugin', async () => {
let input = css`
Expand Down