diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 72e943291f29..e44facdc6407 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -9,6 +9,9 @@ on: permissions: contents: read +env: + CI: true + jobs: test: runs-on: ubuntu-latest @@ -47,8 +50,6 @@ jobs: - name: Install dependencies # if: steps.cache-tailwindcss.outputs.cache-hit != 'true' run: npm install - env: - CI: true - name: Build Tailwind CSS run: npm run prepublishOnly @@ -65,8 +66,6 @@ jobs: - name: Install shared dependencies if: steps.cache-integrations.outputs.cache-hit != 'true' run: npm run install:integrations - env: - CI: true - name: Test ${{ matrix.integration }} run: npm test --prefix ./integrations/${{ matrix.integration }} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 25b0f037ef99..9ddd77b8b8ce 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -12,6 +12,9 @@ on: permissions: contents: read +env: + CI: true + jobs: build: runs-on: ubuntu-latest @@ -40,17 +43,40 @@ jobs: - name: Install dependencies # if: steps.cache.outputs.cache-hit != 'true' run: npm install - env: - CI: true - name: Build Tailwind CSS run: npm run swcify - env: - CI: true - name: Test - run: | - ln -nfs `pwd` node_modules/tailwindcss # So that Prettier can use the local version - npm test - env: - CI: true + run: npm test + + lint: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + # cache: 'npm' + # + # - name: Use cached node_modules + # id: cache + # uses: actions/cache@v3 + # with: + # path: node_modules + # key: nodeModules-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }} + # restore-keys: | + # nodeModules- + + - name: Install dependencies + # if: steps.cache.outputs.cache-hit != 'true' + run: npm install + + - name: Lint + run: npm run style diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 6dfeb3a84179..04f44e59158e 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -68,13 +68,6 @@ jobs: tag_name: ${{ env.TAG_NAME }} body: | ${{ env.RELEASE_NOTES }} - - * [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-arm64) - * [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-armv7) - * [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-x64) - * [macOS (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-arm64) - * [macOS (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-x64) - * [Windows (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-windows-x64.exe) files: | standalone-cli/dist/tailwindcss-linux-arm64 standalone-cli/dist/tailwindcss-linux-armv7 diff --git a/.github/workflows/release-insiders.yml b/.github/workflows/release-insiders.yml index 2e55b18d7053..e91173d4a3ba 100644 --- a/.github/workflows/release-insiders.yml +++ b/.github/workflows/release-insiders.yml @@ -7,6 +7,9 @@ on: permissions: contents: read +env: + CI: true + jobs: build: runs-on: ubuntu-latest @@ -37,26 +40,12 @@ jobs: - name: Install dependencies # if: steps.cache.outputs.cache-hit != 'true' run: npm install - env: - CI: true - - name: Link and build Tailwind CSS - run: | - npm run swcify - ln -nfs `pwd` node_modules/tailwindcss - env: - CI: true + - name: Build Tailwind CSS + run: npm run swcify - name: Test run: npm test - env: - CI: true - - - name: Unlink Tailwind CSS (for prettier) - run: | - unlink node_modules/tailwindcss - env: - CI: true - name: Resolve version id: vars @@ -69,7 +58,6 @@ jobs: - name: Publish run: npm publish --tag insiders env: - CI: true NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Trigger Tailwind Play update diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dbd03894a7fd..9b9bca15e4bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,9 @@ on: permissions: contents: read +env: + CI: true + jobs: build: runs-on: ubuntu-latest @@ -37,13 +40,9 @@ jobs: - name: Install dependencies # if: steps.cache.outputs.cache-hit != 'true' run: npm install - env: - CI: true - name: Test run: npm test - env: - CI: true - name: Calculate environment variables run: | @@ -53,7 +52,6 @@ jobs: - name: Publish run: npm publish --tag ${{ env.RELEASE_CHANNEL }} env: - CI: true NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Trigger Tailwind Play update diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d40abaa07c..b60a8520d7f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nothing yet! +## [3.2.1] - 2022-10-21 + +### Fixed + +- Fix missing `supports` in types ([#9616](https://github.com/tailwindlabs/tailwindcss/pull/9616)) +- Fix missing PostCSS dependencies in the CLI ([#9617](https://github.com/tailwindlabs/tailwindcss/pull/9617)) +- Ensure `micromatch` is a proper CLI dependency ([#9620](https://github.com/tailwindlabs/tailwindcss/pull/9620)) +- Ensure modifier values exist when using a `modifiers` object for `matchVariant` ([ba6551db0f2726461371b4f3c6cd4c7090888504](https://github.com/tailwindlabs/tailwindcss/commit/ba6551db0f2726461371b4f3c6cd4c7090888504)) + ## [3.2.0] - 2022-10-19 ### Added @@ -2079,7 +2088,8 @@ No release notes - Everything! -[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.0...HEAD +[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.1...HEAD +[3.2.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.0...v3.2.1 [3.2.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.8...v3.2.0 [3.1.8]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.7...v3.1.8 [3.1.7]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.6...v3.1.7 diff --git a/README.md b/README.md index c03e56de8c5a..3c020f9023c8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@
diff --git a/integrations/tailwindcss-cli/tests/cli.test.js b/integrations/tailwindcss-cli/tests/cli.test.js index 41ff2de4ebab..b43f2975aa1f 100644 --- a/integrations/tailwindcss-cli/tests/cli.test.js +++ b/integrations/tailwindcss-cli/tests/cli.test.js @@ -411,6 +411,31 @@ describe('Build command', () => { ` ) + await writeInputFile( + 'imported.css', + css` + @layer utilities { + .something-cool { + color: blue; + } + } + ` + ) + + await runningProcess.onStderr(function ready(message) { + return message.includes('Done in') + }) + + expect(await readOutputFile('main.css')).toIncludeCss( + css` + @media (min-width: 768px) { + .md\:something-cool { + color: blue; + } + } + ` + ) + return runningProcess.stop() }) diff --git a/integrations/tailwindcss-cli/tests/integration.test.js b/integrations/tailwindcss-cli/tests/integration.test.js index fbfdc6f0db96..4a76cdfeff26 100644 --- a/integrations/tailwindcss-cli/tests/integration.test.js +++ b/integrations/tailwindcss-cli/tests/integration.test.js @@ -605,4 +605,105 @@ describe('watcher', () => { return runningProcess.stop() }) + + test('classes are generated (and kept) when the index.html file changes (and removed when css/config files are changed)', async () => { + let runningProcess = $('node ../../lib/cli.js -i ./src/index.css -o ./dist/main.css -w') + + // Start with a simple single class + await writeInputFile('index.html', html``) + await runningProcess.onStderr(ready) + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .font-bold { + font-weight: 700; + } + ` + ) + + // Add another class + await writeInputFile('index.html', html``) + await runningProcess.onStderr(ready) + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .flex { + display: flex; + } + + .font-bold { + font-weight: 700; + } + ` + ) + + // Remove a class, because of performance reasons both classes will still be in the css file + await writeInputFile('index.html', html``) + await runningProcess.onStderr(ready) + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .flex { + display: flex; + } + + .font-bold { + font-weight: 700; + } + ` + ) + + // Save the index.css file, this should trigger a fresh context + await writeInputFile( + 'index.css', + css` + @tailwind base; + @tailwind components; + @tailwind utilities; + ` + ) + await runningProcess.onStderr(ready) + + // Only 1 class should stay, because we started from scratch + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .font-bold { + font-weight: 700; + } + ` + ) + + // Add another class + await writeInputFile('index.html', html``) + await runningProcess.onStderr(ready) + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .flex { + display: flex; + } + + .font-bold { + font-weight: 700; + } + ` + ) + + // Remove a class, because of performance reasons both classes will still be in the css file + await writeInputFile('index.html', html``) + await runningProcess.onStderr(ready) + + // If everything goes right, then both classes should still be here (because of the performance + // improvement). If we didn't solve the bug where from now on every save is a fresh context + // then this only has 1 class. So let's hope there are 2! + expect(await readOutputFile('main.css')).toIncludeCss( + css` + .flex { + display: flex; + } + + .font-bold { + font-weight: 700; + } + ` + ) + + return runningProcess.stop() + }) }) diff --git a/package-lock.json b/package-lock.json index 987b1c7984bd..79df575d50ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tailwindcss", - "version": "3.2.0", + "version": "3.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tailwindcss", - "version": "3.2.0", + "version": "3.2.1", "license": "MIT", "dependencies": { "arg": "^5.0.2", @@ -19,6 +19,7 @@ "glob-parent": "^6.0.2", "is-glob": "^4.0.3", "lilconfig": "^2.0.6", + "micromatch": "^4.0.5", "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", @@ -50,7 +51,6 @@ "jest": "^28.1.3", "jest-diff": "^28.1.3", "prettier": "^2.7.1", - "prettier-plugin-tailwindcss": "^0.1.13", "rimraf": "^3.0.0", "source-map-js": "^1.0.2" }, @@ -5250,12 +5250,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" @@ -5614,9 +5614,9 @@ "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "node_modules/picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "engines": { "node": ">=8.6" }, @@ -6205,18 +6205,6 @@ "node": ">=6.0.0" } }, - "node_modules/prettier-plugin-tailwindcss": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.1.13.tgz", - "integrity": "sha512-/EKQURUrxLu66CMUg4+1LwGdxnz8of7IDvrSLqEtDqhLH61SAlNNUSr90UTvZaemujgl3OH/VHg+fyGltrNixw==", - "dev": true, - "engines": { - "node": ">=12.17.0" - }, - "peerDependencies": { - "prettier": ">=2.2.0" - } - }, "node_modules/pretty-format": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", @@ -10832,12 +10820,12 @@ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" }, "dependencies": { "braces": { @@ -11100,9 +11088,9 @@ "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" }, "pify": { "version": "2.3.0", @@ -11449,13 +11437,6 @@ "fast-diff": "^1.1.2" } }, - "prettier-plugin-tailwindcss": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.1.13.tgz", - "integrity": "sha512-/EKQURUrxLu66CMUg4+1LwGdxnz8of7IDvrSLqEtDqhLH61SAlNNUSr90UTvZaemujgl3OH/VHg+fyGltrNixw==", - "dev": true, - "requires": {} - }, "pretty-format": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", diff --git a/package.json b/package.json index 0317a3a56d64..b2f60694b925 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tailwindcss", - "version": "3.2.0", + "version": "3.2.1", "description": "A utility-first CSS framework for rapidly building custom user interfaces.", "license": "MIT", "main": "lib/index.js", @@ -23,7 +23,6 @@ "test": "jest", "test:integrations": "npm run test --prefix ./integrations", "install:integrations": "node scripts/install-integrations.js", - "posttest": "npm run style", "generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js", "generate:types": "node -r @swc/register scripts/generate-types.js", "generate": "npm run generate:plugin-list && npm run generate:types", @@ -57,7 +56,6 @@ "jest": "^28.1.3", "jest-diff": "^28.1.3", "prettier": "^2.7.1", - "prettier-plugin-tailwindcss": "^0.1.13", "rimraf": "^3.0.0", "source-map-js": "^1.0.2" }, @@ -75,6 +73,7 @@ "glob-parent": "^6.0.2", "is-glob": "^4.0.3", "lilconfig": "^2.0.6", + "micromatch": "^4.0.5", "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", diff --git a/src/cli/build/plugin.js b/src/cli/build/plugin.js index 51177db79113..a06bca3be1ae 100644 --- a/src/cli/build/plugin.js +++ b/src/cli/build/plugin.js @@ -328,6 +328,26 @@ export async function createProcessor(args, cliConfigPath) { return readInput() .then((css) => processor.process(css, { ...postcssOptions, from: input, to: output })) + .then((result) => { + if (!state.watcher) { + return result + } + + env.DEBUG && console.time('Recording PostCSS dependencies') + for (let message of result.messages) { + if (message.type === 'dependency') { + state.contextDependencies.add(message.file) + } + } + env.DEBUG && console.timeEnd('Recording PostCSS dependencies') + + // TODO: This needs to be in a different spot + env.DEBUG && console.time('Watch new files') + state.watcher.refreshWatchedFiles() + env.DEBUG && console.timeEnd('Watch new files') + + return result + }) .then((result) => { if (!output) { process.stdout.write(result.css) diff --git a/src/cli/build/watching.js b/src/cli/build/watching.js index 8ebceccf5cc7..9b5462a244fd 100644 --- a/src/cli/build/watching.js +++ b/src/cli/build/watching.js @@ -62,7 +62,7 @@ export function createWatcher(args, { state, rebuild }) { extension: path.extname(file).slice(1), }) - chain = chain.then(() => rebuild(changedContent)) + chain = chain.then(() => rebuild(changedContent.splice(0))) return chain } diff --git a/src/util/pluginUtils.js b/src/util/pluginUtils.js index d5ad3fa3142b..6295bd2bfff2 100644 --- a/src/util/pluginUtils.js +++ b/src/util/pluginUtils.js @@ -233,14 +233,20 @@ export function coerceValue(types, modifier, options, tailwindConfig) { export function* getMatchingTypes(types, rawModifier, options, tailwindConfig) { let modifiersEnabled = flagEnabled(tailwindConfig, 'generalizedModifiers') + let [modifier, utilityModifier] = splitUtilityModifier(rawModifier) + let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && - (options.modifiers === 'any' || typeof options.modifiers === 'object') - - let [modifier, utilityModifier] = canUseUtilityModifier - ? splitUtilityModifier(rawModifier) - : [rawModifier, undefined] + (options.modifiers === 'any' || + (typeof options.modifiers === 'object' && + ((utilityModifier && isArbitraryValue(utilityModifier)) || + utilityModifier in options.modifiers))) + + if (!canUseUtilityModifier) { + modifier = rawModifier + utilityModifier = undefined + } if (utilityModifier !== undefined && modifier === '') { modifier = 'DEFAULT' diff --git a/standalone-cli/package.json b/standalone-cli/package.json index aa7b6f539ee0..13328a65dfd5 100644 --- a/standalone-cli/package.json +++ b/standalone-cli/package.json @@ -31,5 +31,8 @@ "node16-linuxstatic-armv7" ], "outputPath": "dist" + }, + "jest": { + "testTimeout": 30000 } } diff --git a/stubs/defaultConfig.stub.js b/stubs/defaultConfig.stub.js index 6b6931e548cb..d8e55eb4eab3 100644 --- a/stubs/defaultConfig.stub.js +++ b/stubs/defaultConfig.stub.js @@ -11,6 +11,7 @@ module.exports = { xl: '1280px', '2xl': '1536px', }, + supports: {}, colors: ({ colors }) => ({ inherit: colors.inherit, current: colors.current, diff --git a/types/config.d.ts b/types/config.d.ts index 0df3620611c9..34e1621cf069 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -84,6 +84,7 @@ type ScreensConfig = string[] | KeyValuePair