-
Notifications
You must be signed in to change notification settings - Fork 775
feat(tailwind): Smaller bundle size #1383
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
Merged
Merged
Changes from all commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
2092215
feat(head): iOS formatting meta tag as default (#1369)
endymion1818 be72c02
fix(create-email): Tailwind imported from @react-email/tailwind which…
hank619 af59dc4
feat(tailwind): Context-aware treatment for components inside of Tail…
gabrielmfern 522fccd
chore(tailwind): Add a unit test to check if context is working insid…
gabrielmfern 8405061
chore: Add postcss-selector-parser
gabrielmfern 2a82fa9
feat(tailwind/hooks): useTailwind() hook that allows to straight up g…
gabrielmfern 931c0d4
feat(tailwind): Function to convert css property to React property
gabrielmfern 09fca98
feat(tailwind): Function to sanitize media queries using postcss util…
gabrielmfern bdba3ec
feat(tailwind): Function to generate JSX inline styles from a postcss…
gabrielmfern 7cc4084
feat(tailwind): Function to sanitize a postcss declaration
gabrielmfern 96fde73
feat(tailwind): Rewrite with the new utilities
gabrielmfern de39375
chore: Update the unit tests
gabrielmfern 8d207df
fix(tailwind): No Head error being thrown with a Head inside of a com…
gabrielmfern e9d6e0a
chore: Remove unused utilities
gabrielmfern 780f575
feat(tailwind): Sanitize all digits at the start of classes into the …
gabrielmfern e61542c
fix(tailwind): Unit test with wrong expected class name
gabrielmfern bfd3b30
fix(tailwind): Missing keys after head processing
gabrielmfern 51cb876
fix(tailwind): Media rules not being merged when sanitizing
gabrielmfern 37fa1a5
feat(tailwind): A utiltiy for walking and processing all of the eleme…
gabrielmfern 60aff21
feat(tailwind): Component rewrite using the new walkElements utility
gabrielmfern dd5a6a1
chore(tailwind): Update the unit tests
gabrielmfern 4dcc010
chore(tailwind): Rename the inlineStyles utility to makeInlineStylesFor
gabrielmfern 6cc0760
feat(tailwind): Separate hook for cloning element with inlined styles
gabrielmfern 07227e7
feat(tailwind): INline styles with the useCloneElementWIthInlinedStyl…
gabrielmfern 00c3155
feat(tailwind): Unit test to check if the media queries are found out…
gabrielmfern 28a8db2
fix(tailwind): Wrongly improted Node from postcss
gabrielmfern d1017e5
chore(tailwind): Remove things that would allow for React hooks to ru…
gabrielmfern 5bd576d
chore(tailwind): Remove polyfills
gabrielmfern eb64545
feat(tailwind): Integration test for building a Next app using the Ta…
gabrielmfern f8e3cd1
fix(tailwind): next app build test running infinitely on watch
gabrielmfern fafeb98
chore(tailwind): Ignore automated-test-next-app
gabrielmfern a9ff8a4
fix(tailwind): Automated testing Next app not using pnpm to install d…
gabrielmfern 2be9cd4
chore(tailwind): Use pnpm to run build script on testing Next app
gabrielmfern 83a6907
chore(tailwind): Add manual production environment for vite to build …
gabrielmfern 60575f8
chore(tailwind): Update comment for mapReactTree utility
gabrielmfern b9577da
chore: update lock
gabrielmfern 8750a97
chore(tailwind): Update tests to remove escaping characters on tests
gabrielmfern 5830dd6
chore(tailwind): Move automated-test-next-app into using npm
gabrielmfern 4fc00a0
chore(tailwind): remove unused get-css-for-markup utility
gabrielmfern 89c7345
chore(tailwind): Move automated-test-next-app into integrations/nextjs
gabrielmfern 9ead21c
chore(tailwind): Format
gabrielmfern 5831990
chore(tailwind): Remove unused rulesFor utility
gabrielmfern 1d9e044
chore(tailwind): Update the `ignorePatterns` of the eslint config
gabrielmfern d7ff7cf
chore(tailwind): Update the styles ordering in the <Button> test
gabrielmfern 615759d
chore(deps): update dependency postcss to v8.4.38 (#1392)
renovate[bot] db68c92
chore(tailwind): Update the integration README
gabrielmfern ffbdb61
feat(tailwind): Vite with React integration test
gabrielmfern 2a0513a
chore(tailwind): Attempt removing the yalc files to check if tests st…
gabrielmfern 93ffa8b
fix(tailwind): React.forwardRef components not working (#1335)
nzben 5aae339
Merge branch 'canary' into fix/tailwind-context-issues
gabrielmfern d81734f
chore(tailwind): Format
gabrielmfern 0fa5ad6
fix(tailwind): Grammar for the missing `<head>` element error
gabrielmfern fbb3283
fix(tailwind): Escaped characters inside of recently merged test
gabrielmfern 41ae846
chore(tailwind): Format
gabrielmfern 6297e7b
feat(head): iOS formatting meta tag as default (#1369)
endymion1818 45c69f6
fix(create-email): Tailwind imported from @react-email/tailwind which…
hank619 a6f4809
chore(deps): update dependency postcss to v8.4.38 (#1392)
renovate[bot] 85a0771
fix(tailwind): React.forwardRef components not working (#1335)
nzben 44427a3
chore(components, create-email, head, tailwind): Bump for canary rele…
gabrielmfern 4d8b119
fix(tailwind): Children always being transformed into an array (#1397)
gabrielmfern de8597f
chore(components, create-email, react-email, tailwind): Bump for cana…
gabrielmfern b7ad24b
fix(render): Tests for the web env not using the server.browser versi…
gabrielmfern 74052e2
fix(react-email): Issue with `email dev` when there is a `browserslis…
gabrielmfern 3312f09
feat(react-email): Improved error stack traces for preview server (#1…
gabrielmfern 3e84153
fix(react-email, render): Dependabot security vulnerabilities from de…
gabrielmfern 2c2b070
chore(deps): update dependency vite [security] (#1399)
renovate[bot] 6ff630a
fix(react-email): Missing URLSearchParams on global context for email…
vlaforet ba50d8d
Merge branch 'canary' into fix/tailwind-context-issues
gabrielmfern 342eff3
fix: artifcats from merging with canary
gabrielmfern dbd181c
chore: format
gabrielmfern a173dbd
chore: lint
gabrielmfern c6658fa
chore: rename wrong describe content of the map-react-tree utilility'…
gabrielmfern 13bf3a4
chore: remove duplicate test for React.forwardRef with Tailwind
gabrielmfern 0e796d8
chore: update locks for integrations
gabrielmfern 4adadfe
Merge branch 'canary' into fix/tailwind-context-issues
gabrielmfern 72a130e
remove test that should have been deleted during rebase
gabrielmfern 3ad43ba
remove extra forward ref unit test
gabrielmfern 63752ba
update test for mapReactTree to account for the new way of inlining s…
gabrielmfern 86f83da
update so that our implementation of CSS variable resolution is not a…
gabrielmfern 5dbc1bc
update tests
gabrielmfern f3d2258
update integration tests
gabrielmfern 328f399
update react-email tests using vercel-invite-user template
gabrielmfern eb7683a
add changeset
gabrielmfern 6250043
remove some unused dependencies
gabrielmfern 7d40a27
update snapshots
gabrielmfern 080c1a9
make class manipulation test more thorough
gabrielmfern 2336757
fix style manipulation
gabrielmfern 4b9aebd
fix Button test and one other snapshot
gabrielmfern dbbbb02
update CLI snapshots
gabrielmfern 62b0069
format
gabrielmfern ff69f3c
fix rebase artifacts
gabrielmfern d3e644d
format
gabrielmfern 3ecc61b
sort web's package json
gabrielmfern f32468d
Use proper casing for emailHtml variable
gabrielmfern ba2ff94
Remove unecessary comment
gabrielmfern 560c789
use node instead of element
gabrielmfern bd8f344
remove unecessary comment for makeInlineStylesFor
gabrielmfern b628b75
add as const for better type-safety
gabrielmfern 1e54278
Update packages/tailwind/src/utils/compatibility/convert-css-property…
gabrielmfern d70bca3
Update packages/tailwind/src/utils/compatibility/convert-css-property…
gabrielmfern 4bb0907
remove cssFloat property usage to match previous changes
gabrielmfern db5ec7b
use a type-definition instead of casting
gabrielmfern 1a4aa50
rename useTailwind to setupTailwind
gabrielmfern 101f23a
remove unused useSuspendedPromise
gabrielmfern 47621af
format
gabrielmfern 8e42a37
Revert "remove unused useSuspendedPromise"
gabrielmfern 2c3db71
update tailwind
gabrielmfern a4aaf89
call extra functions that newer Tailwind versions call
gabrielmfern a9cf355
properly await and suspend for the one async step that Tailwind takes…
gabrielmfern 4fe351e
Revert "update tailwind"
gabrielmfern 5cb18c5
update snapshots due to suspense
gabrielmfern 34d3185
update locks
gabrielmfern b029406
format
gabrielmfern 99d26b7
make the whole code sync again and remove suspension
gabrielmfern bdcf3ef
remove unecesssary uuid
gabrielmfern 856575f
fix build issues
gabrielmfern 650dae4
update snapshots
gabrielmfern 939576b
format
gabrielmfern 7709146
fix mapReactTree test
gabrielmfern 500a9af
improve name for rgb parser regex
gabrielmfern 47b3d56
remove unecessary comment
gabrielmfern 9444227
remove unecessary linting rule disable
gabrielmfern 4402797
sort dependencies
gabrielmfern 2c9203c
move rgb parser regex to be recreated each time
gabrielmfern 6b1ee48
fix linting
gabrielmfern f33e946
remove previous version's tailwind patch
gabrielmfern 1a0d92b
update lock
gabrielmfern 6219b1b
format
gabrielmfern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@react-email/tailwind": minor | ||
--- | ||
|
||
Refactored internally to have a much smaller bundle size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,6 @@ | |
"overrides": { | ||
"@types/react": "npm:[email protected]", | ||
"@types/react-dom": "npm:[email protected]" | ||
}, | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]", | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import path from "node:path"; | ||
import { $ } from "./utils/run-testing-command"; | ||
|
||
test.sequential("Tailwind works on the Next App's build process", () => { | ||
const nextAppLocation = path.resolve(__dirname, "../nextjs"); | ||
$("npm install", nextAppLocation); | ||
$("npm run build", nextAppLocation); | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/tailwind/integrations/_tests/utils/run-testing-command.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import path from "path"; | ||
import shell from "shelljs"; | ||
|
||
/** | ||
* Just a function that runs `shell.exec` and expects it returns code 0, i.e. expects command not to fail | ||
* | ||
* Defaults the CWD to the @react-email/tailwind project's directory | ||
*/ | ||
export const $ = ( | ||
command: string, | ||
cwd: string = path.resolve(__dirname, ".."), | ||
) => { | ||
expect( | ||
shell.exec(command, { cwd, fatal: true }).code, | ||
`Expected command "${command}" to work properly but it returned a non-zero exit code`, | ||
).toBe(0); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import path from "node:path"; | ||
import { $ } from "./utils/run-testing-command"; | ||
|
||
test.sequential("Tailwind works on the Vite App's build process", () => { | ||
const viteAppLocation = path.resolve(__dirname, "../vite"); | ||
$("npm install", viteAppLocation); | ||
$("npm run build", viteAppLocation); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.yalc | ||
yalc.lock | ||
.pnp.js | ||
yalc.lock | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This is a NextJS project bootstrapped with `create-next-app@latest` that contains a Tailwind | ||
email using most of the features we provide that will be auto-built on testing to | ||
make sure this new release works properly with the latest version of NextJS when being built. | ||
|
||
We do this testing so that things are more reliable and this couldn't be done using pnpm | ||
workspaces as they link code instead of actually copying the content into node_modules. | ||
The solution we use to copy the code in a way that mimics the actual `npm install @react-email/tailwind` is `yalc`. | ||
|
||
Se [the test file](../_tests/nextjs.spec.ts) for more info. |
152 changes: 152 additions & 0 deletions
152
packages/tailwind/integrations/nextjs/emails/vercel-invite-user.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { | ||
Body, | ||
Button, | ||
Container, | ||
Column, | ||
Head, | ||
Heading, | ||
Hr, | ||
Html, | ||
Img, | ||
Link, | ||
Preview, | ||
Row, | ||
Section, | ||
Text, | ||
} from "@react-email/components"; | ||
import { Tailwind } from "@react-email/tailwind"; | ||
import * as React from "react"; | ||
|
||
interface VercelInviteUserEmailProps { | ||
username?: string; | ||
userImage?: string; | ||
invitedByUsername?: string; | ||
invitedByEmail?: string; | ||
teamName?: string; | ||
teamImage?: string; | ||
inviteLink?: string; | ||
inviteFromIp?: string; | ||
inviteFromLocation?: string; | ||
} | ||
|
||
const baseUrl = process.env.VERCEL_URL | ||
? `https://${process.env.VERCEL_URL}` | ||
: ""; | ||
|
||
export const VercelInviteUserEmail = ({ | ||
username, | ||
userImage, | ||
invitedByUsername, | ||
invitedByEmail, | ||
teamName, | ||
teamImage, | ||
inviteLink, | ||
inviteFromIp, | ||
inviteFromLocation, | ||
}: VercelInviteUserEmailProps) => { | ||
const previewText = `Join ${invitedByUsername} on Vercel`; | ||
|
||
return ( | ||
<Html> | ||
<Head /> | ||
<Preview>{previewText}</Preview> | ||
<Tailwind> | ||
<Body className="bg-white my-auto mx-auto font-sans px-2"> | ||
<Container className="border border-solid border-[#eaeaea] rounded my-[40px] mx-auto p-[20px] max-w-[465px]"> | ||
<Section className="mt-[32px]"> | ||
<Img | ||
src={`${baseUrl}/static/vercel-logo.png`} | ||
width="40" | ||
height="37" | ||
alt="Vercel" | ||
className="my-0 mx-auto" | ||
/> | ||
</Section> | ||
<Heading className="text-black text-[24px] font-normal text-center p-0 my-[30px] mx-0"> | ||
Join <strong>{teamName}</strong> on <strong>Vercel</strong> | ||
</Heading> | ||
<Text className="text-black text-[14px] leading-[24px]"> | ||
Hello {username}, | ||
</Text> | ||
<Text className="text-black text-[14px] leading-[24px]"> | ||
<strong>{invitedByUsername}</strong> ( | ||
<Link | ||
href={`mailto:${invitedByEmail}`} | ||
className="text-blue-600 no-underline" | ||
> | ||
{invitedByEmail} | ||
</Link> | ||
) has invited you to the <strong>{teamName}</strong> team on{" "} | ||
<strong>Vercel</strong>. | ||
</Text> | ||
<Section> | ||
<Row> | ||
<Column align="right"> | ||
<Img | ||
className="rounded-full" | ||
src={userImage} | ||
width="64" | ||
height="64" | ||
/> | ||
</Column> | ||
<Column align="center"> | ||
<Img | ||
src={`${baseUrl}/static/vercel-arrow.png`} | ||
width="12" | ||
height="9" | ||
alt="invited you to" | ||
/> | ||
</Column> | ||
<Column align="left"> | ||
<Img | ||
className="rounded-full" | ||
src={teamImage} | ||
width="64" | ||
height="64" | ||
/> | ||
</Column> | ||
</Row> | ||
</Section> | ||
<Section className="text-center mt-[32px] mb-[32px]"> | ||
<Button | ||
className="bg-[#000000] rounded text-white text-[12px] font-semibold no-underline text-center px-5 py-3" | ||
href={inviteLink} | ||
> | ||
Join the team | ||
</Button> | ||
</Section> | ||
<Text className="text-black text-[14px] leading-[24px]"> | ||
or copy and paste this URL into your browser:{" "} | ||
<Link href={inviteLink} className="text-blue-600 no-underline"> | ||
{inviteLink} | ||
</Link> | ||
</Text> | ||
<Hr className="border border-solid border-[#eaeaea] my-[26px] mx-0 w-full" /> | ||
<Text className="text-[#666666] text-[12px] leading-[24px]"> | ||
This invitation was intended for{" "} | ||
<span className="text-black">{username}</span>. This invite was | ||
sent from <span className="text-black">{inviteFromIp}</span>{" "} | ||
located in{" "} | ||
<span className="text-black">{inviteFromLocation}</span>. If you | ||
were not expecting this invitation, you can ignore this email. If | ||
you are concerned about your account's safety, please reply to | ||
this email to get in touch with us. | ||
</Text> | ||
</Container> | ||
</Body> | ||
</Tailwind> | ||
</Html> | ||
); | ||
}; | ||
|
||
VercelInviteUserEmail.PreviewProps = { | ||
username: "alanturing", | ||
userImage: `${baseUrl}/static/vercel-user.png`, | ||
invitedByUsername: "Alan", | ||
invitedByEmail: "[email protected]", | ||
teamName: "Enigma", | ||
teamImage: `${baseUrl}/static/vercel-team.png`, | ||
inviteLink: "https://vercel.com/teams/invite/foo", | ||
inviteFromIp: "204.13.186.218", | ||
inviteFromLocation: "São Paulo, Brazil", | ||
} as VercelInviteUserEmailProps; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
compress: false, | ||
swcMinify: false, | ||
}; | ||
|
||
export default nextConfig; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.