Skip to content

Commit 04c4de1

Browse files
authored
Deprecate --no-autoprefixer flag in the CLI (#11280)
* enable `--no-autoprefixer` test * handle `--no-autoprefixer` using lightningcss * bump default chrome version for lightningcss plugin * handle `map` being nullable * add `--no-autoprefixer` test including nesting * set Chrome to version 111 as a default value * resolve the output message when resolving the promise * deprecate `--no-autoprefixer` for the CLI * update changelog
1 parent 88ab01c commit 04c4de1

File tree

7 files changed

+40
-23
lines changed

7 files changed

+40
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Reset padding for `<dialog>` elements in preflight ([#11069](https://github.com/tailwindlabs/tailwindcss/pull/11069))
2828
- [Oxide] Disable color opacity plugins by default in the `oxide` engine ([#10618](https://github.com/tailwindlabs/tailwindcss/pull/10618))
2929
- [Oxide] Enable relative content paths for the `oxide` engine ([#10621](https://github.com/tailwindlabs/tailwindcss/pull/10621))
30+
- Deprecate `--no-autoprefixer` flag in the CLI ([#11280](https://github.com/tailwindlabs/tailwindcss/pull/11280))
3031

3132
## [3.3.2] - 2023-04-25
3233

integrations/execute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = function $(command, options = {}) {
6464
messages.splice(0, idx + 1)
6565
let actorIdx = actors.indexOf(next)
6666
actors.splice(actorIdx, 1)
67-
next.resolve()
67+
next.resolve(message)
6868
break
6969
}
7070
}

integrations/tailwindcss-cli/tests/cli.test.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,35 @@ describe('Build command', () => {
9696
expect(withoutMinify.length).toBeGreaterThan(withMinify.length)
9797
})
9898

99-
// TODO: Handle --no-autoprefixer
100-
test.skip('--no-autoprefixer', async () => {
99+
// Deprecated
100+
test('--no-autoprefixer (should produce a warning)', async () => {
101101
await writeInputFile('index.html', html`<div class="select-none"></div>`)
102+
await writeInputFile(
103+
'index.css',
104+
css`
105+
@tailwind utilities;
106+
`
107+
)
102108

103-
await $(`${EXECUTABLE} --output ./dist/main.css`)
104-
let withAutoprefixer = await readOutputFile('main.css')
105-
106-
expect(withAutoprefixer).toIncludeCss(css`
107-
.select-none {
108-
-webkit-user-select: none;
109-
user-select: none;
110-
}
109+
let runningProcess = $(
110+
`${EXECUTABLE} --input ./src/index.css --output ./dist/main.css --no-autoprefixer`
111+
)
112+
let warning = runningProcess.onStderr((message) => message.includes('--no-autoprefixer'))
113+
await runningProcess
114+
expect(await warning).toMatchInlineSnapshot(`
115+
"[deprecation] The --no-autoprefixer flag is deprecated and has no effect.
116+
"
111117
`)
112-
113-
await $(`${EXECUTABLE} --output ./dist/main.css --no-autoprefixer`)
114118
let withoutAutoprefixer = await readOutputFile('main.css')
115119

116-
expect(withoutAutoprefixer).toIncludeCss(css`
117-
.select-none {
120+
// This contains --webkit-user-select which may be strange, but it is expected because we are
121+
// not handling the `--no-autoprefixer` flag anymore at all.
122+
expect(withoutAutoprefixer).toMatchInlineSnapshot(`
123+
".select-none {
124+
-webkit-user-select: none;
118125
user-select: none;
119126
}
127+
"
120128
`)
121129
})
122130

@@ -492,7 +500,6 @@ describe('Build command', () => {
492500
--postcss Load custom PostCSS configuration
493501
-m, --minify Minify the output
494502
-c, --config Path to a custom config file
495-
--no-autoprefixer Disable autoprefixer
496503
-h, --help Display usage information
497504
`)
498505
)

src/cli/build/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export async function build(args) {
2525
process.exit(9)
2626
}
2727

28+
if (args['--no-autoprefixer']) {
29+
console.error('[deprecation] The --no-autoprefixer flag is deprecated and has no effect.')
30+
}
31+
2832
// TODO: Reference the @config path here if exists
2933
let configPath = args['--config'] ? args['--config'] : resolveDefaultConfigPath()
3034

src/cli/build/plugin.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ import { validateConfig } from '../../util/validateConfig'
2626
import { handleImportAtRules } from '../../lib/handleImportAtRules'
2727
import { flagEnabled } from '../../featureFlags'
2828

29-
async function lightningcss(shouldMinify, result, options = {}) {
30-
// TODO: handle --no-autoprefixer option if possible
29+
async function lightningcss(result, { map = true, minify = true } = {}) {
3130
try {
3231
let transformed = lightning.transform({
3332
filename: result.opts.from || 'input.css',
3433
code: Buffer.from(result.css, 'utf-8'),
35-
minify: shouldMinify,
36-
sourceMap: result.map === undefined ? options.map : !!result.map,
34+
minify,
35+
sourceMap: result.map === undefined ? map : !!result.map,
3736
inputSourceMap: result.map ? result.map.toString() : undefined,
3837
targets: lightning.browserslistToTargets(browserslist(pkg.browserslist)),
3938
drafts: {
@@ -46,7 +45,7 @@ async function lightningcss(shouldMinify, result, options = {}) {
4645
map: result.map
4746
? Object.assign(result.map, {
4847
toString() {
49-
return transformed.map.toString()
48+
return transformed.map?.toString()
5049
},
5150
})
5251
: result.map,
@@ -342,7 +341,12 @@ export async function createProcessor(args, cliConfigPath) {
342341

343342
return readInput()
344343
.then((css) => processor.process(css, options))
345-
.then((result) => lightningcss(!!args['--minify'], result, options))
344+
.then((result) =>
345+
lightningcss(result, {
346+
...options,
347+
minify: !!args['--minify'],
348+
})
349+
)
346350
.then((result) => {
347351
if (!state.watcher) {
348352
return result

src/cli/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ let commands = {
7070
description: 'Path to a custom config file',
7171
},
7272
'--no-autoprefixer': {
73+
deprecated: true,
7374
type: Boolean,
7475
description: 'Disable autoprefixer',
7576
},

src/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = function tailwindcss(configOrPath) {
4949
inputSourceMap: result.map ? result.map.toString() : undefined,
5050
targets:
5151
typeof process !== 'undefined' && process.env.JEST_WORKER_ID
52-
? { chrome: 106 << 16 }
52+
? { chrome: 111 << 16 }
5353
: lightningcss.browserslistToTargets(
5454
browserslist(require('../package.json').browserslist)
5555
),

0 commit comments

Comments
 (0)