Skip to content

Commit

Permalink
Replace __OXIDE__ at build time to prevent @tailwindcss/oxide lea…
Browse files Browse the repository at this point in the history
…ks in the stable engine (tailwindlabs#10988)

* replace `env.OXIDE` with global `__OXIDE__`

This will allow us to replace the `__OXIDE__` at build time, and fully
remove the branches from the final code so that there is not even any
reference to `@tailwindcss/oxide` on the stable engine.

* update changelog

* use `env.ENGINE` in integration tests

* drop oxide branching for the PostCSS plugin for now

This is currently a redirect to the same file, so doesn't hurt.

* Enable better dead-code elimination

* Update CLI tests

Fix indentation

* Fix indentation

---------

Co-authored-by: Jordan Pittman <[email protected]>
  • Loading branch information
RobinMalfait and thecrypticace authored Apr 18, 2023
1 parent 9f86019 commit 72bc318
Show file tree
Hide file tree
Showing 23 changed files with 195 additions and 169 deletions.
5 changes: 5 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"parser": {
"syntax": "typescript",
"tsx": false
},
"minify": {
"compress": {
"unused": true
}
}
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don’t move unknown pseudo-elements to the end of selectors ([#10943](https://github.com/tailwindlabs/tailwindcss/pull/10943), [#10962](https://github.com/tailwindlabs/tailwindcss/pull/10962))
- Inherit gradient stop positions when using variants ([#11002](https://github.com/tailwindlabs/tailwindcss/pull/11002))
- Honor default `to` position of gradient when using implicit transparent colors ([#11002](https://github.com/tailwindlabs/tailwindcss/pull/11002))
- Replace `__OXIDE__` at build time to prevent `@tailwindcss/oxide` leaks in the stable engine ([#10988](https://github.com/tailwindlabs/tailwindcss/pull/10988))

## [3.3.1] - 2023-03-30

Expand Down
20 changes: 10 additions & 10 deletions integrations/parcel/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('static build', () => {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
Expand All @@ -85,7 +85,7 @@ describe('static build', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('static build', () => {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
Expand All @@ -149,7 +149,7 @@ describe('static build', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('watcher', () => {
await appendToInputFile('index.html', html`<div class="bg-red-500"></div>`)
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -219,7 +219,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('watcher', () => {
await appendToInputFile('glob/index.html', html`<div class="bg-red-500"></div>`)
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -291,7 +291,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('watcher', () => {
)
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.btn {
Expand All @@ -461,7 +461,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.btn {
Expand Down
12 changes: 6 additions & 6 deletions integrations/postcss-cli/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('watcher', () => {
await appendToInputFile('index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -78,7 +78,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('watcher', () => {
await appendToInputFile('glob/index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -145,7 +145,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('watcher', () => {
)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.btn {
Expand All @@ -303,7 +303,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
/* prettier-ignore */
Expand Down
16 changes: 8 additions & 8 deletions integrations/rollup-sass/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('watcher', () => {
await appendToInputFile('index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -78,7 +78,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('watcher', () => {
await appendToInputFile('glob/index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -145,7 +145,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('watcher', () => {
)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand All @@ -298,7 +298,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('watcher', () => {
)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand All @@ -393,7 +393,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand Down
20 changes: 10 additions & 10 deletions integrations/rollup/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('static build', () => {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
Expand All @@ -73,7 +73,7 @@ describe('static build', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('static build', () => {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
Expand All @@ -131,7 +131,7 @@ describe('static build', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('watcher', () => {
await appendToInputFile('index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -192,7 +192,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('watcher', () => {
await appendToInputFile('glob/index.html', html`<div class="bg-red-500"></div>`)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand All @@ -259,7 +259,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-red-500 {
Expand Down Expand Up @@ -396,7 +396,7 @@ describe('watcher', () => {
)
await runningProcess.onStderr(ready)

if (!env.OXIDE) {
if (env.ENGINE === 'stable') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand All @@ -415,7 +415,7 @@ describe('watcher', () => {
)
}

if (env.OXIDE) {
if (env.ENGINE === 'oxide') {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
Expand Down
Loading

0 comments on commit 72bc318

Please sign in to comment.