Skip to content

Commit 167668e

Browse files
authored
Ensure to transpile the PostCSS Nesting plugin (tailwindcss/nesting) (#7080)
* ensure that we compile the postcss nesting plugin * re-add optional chaining This will allow us to be 100% sure that we can safely call hasOwnProperty in case we get some very strange objects. This will now also be compiled/transpiled by esbuild. * import the internal postcss nesting plugin This allows us to work on it without re-compiling while running tests. Just like we do with all other code. * update changelog
1 parent 61b68a2 commit 167668e

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Ensure to transpile the PostCSS Nesting plugin (tailwindcss/nesting) ([#7080](https://github.com/tailwindlabs/tailwindcss/pull/7080))
1113

1214
## [3.0.15] - 2022-01-15
1315

nesting/index.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
let nesting = require('./plugin')
2-
3-
module.exports = (opts) => {
4-
return {
5-
postcssPlugin: 'tailwindcss/nesting',
6-
Once(root, { result }) {
7-
return nesting(opts)(root, result)
8-
},
9-
}
10-
}
11-
12-
module.exports.postcss = true
1+
let nesting = require('../lib/postcss-plugins/nesting')
2+
module.exports = (nesting.__esModule ? nesting : { default: nesting }).default
File renamed without changes.

src/postcss-plugins/nesting/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { nesting } from './plugin'
2+
3+
export default Object.assign(
4+
function (opts) {
5+
return {
6+
postcssPlugin: 'tailwindcss/nesting',
7+
Once(root, { result }) {
8+
return nesting(opts)(root, result)
9+
},
10+
}
11+
},
12+
{ postcss: true }
13+
)

nesting/plugin.js renamed to src/postcss-plugins/nesting/plugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
let postcss = require('postcss')
2-
let postcssNested = require('postcss-nested')
1+
import postcss from 'postcss'
2+
import postcssNested from 'postcss-nested'
33

4-
module.exports = function nesting(opts = postcssNested) {
4+
export function nesting(opts = postcssNested) {
55
return (root, result) => {
66
root.walkAtRules('screen', (rule) => {
77
rule.name = 'media'
@@ -16,7 +16,7 @@ module.exports = function nesting(opts = postcssNested) {
1616
let plugin = (() => {
1717
if (
1818
typeof opts === 'function' ||
19-
(typeof opts === 'object' && opts.hasOwnProperty('postcssPlugin'))
19+
(typeof opts === 'object' && opts?.hasOwnProperty?.('postcssPlugin'))
2020
) {
2121
return opts
2222
}

tests/postcss-plugins/nesting/index.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
let postcss = require('postcss')
2-
let postcssNested = require('postcss-nested')
3-
let plugin = require('../../../nesting')
1+
import postcss from 'postcss'
2+
import postcssNested from 'postcss-nested'
3+
import plugin from '../../../src/postcss-plugins/nesting'
44

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

0 commit comments

Comments
 (0)