Skip to content
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

feat(tailwind): Smaller bundle size #1124

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e2a47e6
fix(tailwind): utils grouping and organization
gabrielmfern Jan 3, 2024
83dde0e
feat(tailwind): make use of the direct tailwind features to avoid bun…
gabrielmfern Jan 3, 2024
54aad09
fix(tailwind): export TailwindConfig
gabrielmfern Jan 3, 2024
b126080
fix(tailwind): add key to all processed elements
gabrielmfern Jan 3, 2024
80e5169
feat(benchmarks): Use 0.0.13 compared to the latest instead of 0.0.12
gabrielmfern Jan 3, 2024
ac74005
chore(tailwind): format
gabrielmfern Jan 3, 2024
d885ef2
chore(tailwind): remove polyfills dependencies and the patch on the p…
gabrielmfern Jan 3, 2024
cbc7cb7
fix(deps): Dead patch on process package
gabrielmfern Jan 3, 2024
21901c4
fix(tailwind): useRgbNonSpacedSyntax not using the same regex
gabrielmfern Jan 3, 2024
b4582ab
fix(tailwind): Non global regex for rgbs causing issues
gabrielmfern Jan 3, 2024
e3f8785
chore(tailwind): format
gabrielmfern Jan 3, 2024
8e1bce2
fix(tailwind): bundle postcss as well to avoid next build errors with…
gabrielmfern Jan 9, 2024
7d23f7c
chore(deps): Update lock
gabrielmfern Jan 22, 2024
adfb66d
fix(tailwind): Type issue with postcssCssVariables
gabrielmfern Jan 22, 2024
a79c279
chore(root): Update lock
gabrielmfern Jan 28, 2024
2705174
fix(tailwind): React internal being bundled in as well
gabrielmfern Jan 29, 2024
e837754
Merge branch 'canary' into feat/decrease-tailwind-bundle-size
gabrielmfern Feb 23, 2024
f5809b0
chore(deps): Update lock
gabrielmfern Feb 23, 2024
1e216d0
feat(tailwind): Integration test for building a Next app using the Ta…
gabrielmfern Feb 23, 2024
9f5713b
fix(tailwind): Build process issue where the resulting compiled JSX w…
gabrielmfern Feb 23, 2024
3ffeda4
chore(tailwind):Format
gabrielmfern Feb 23, 2024
5937c90
fix(tailwind): next app build test running infinitely on watch
gabrielmfern Feb 23, 2024
b362c40
chore(tailwind): Ignore automated-test-next-app
gabrielmfern Feb 23, 2024
3042d3c
chore: Format
gabrielmfern Feb 23, 2024
066a5e4
fix(tailwind): Automated testing Next app not using pnpm to install d…
gabrielmfern Feb 29, 2024
8a2c7e1
chore(tailwind): Use pnpm to run build script on testing Next app
gabrielmfern Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"totalTime":12038.617523986846,"min":103.67929299920797,"max":159.12310099974275,"hz":8.306601634344709,"period":120.38617523986846,"samples":[103.67929299920797,105.21537199988961,105.42615700140595,106.07665099948645,106.37340800091624,106.42210000008345,106.94859899953008,107.04294800013304,107.76807000115514,107.96288700029254,108.07823400199413,108.35426300019026,108.59506599977612,109.02817900106311,109.05898800119758,109.12921999767423,109.15932599827647,109.55055199936032,109.60058600082994,109.77846100181341,109.85651699826121,110.3762039989233,111.15072999894619,111.17128900066018,111.18644699826837,111.29167499765754,112.28759799897671,112.5253240019083,112.5420360006392,113.1479649990797,113.18393300101161,113.26294099912047,113.3146480023861,113.57648099958897,113.6285380013287,113.77276999875903,113.8291859999299,113.87677500024438,113.91487699747086,114.08545700088143,114.15173299983144,114.5101259984076,114.66707099974155,115.09689899906516,115.28191700205207,115.33678100258112,115.51951399818063,115.75755199790001,115.8184460029006,115.9816830009222,116.02089600265026,116.29580299928784,117.04034299775958,117.16970700025558,117.42955499887466,117.81526900082827,117.9530789963901,118.26566699892282,118.28102499991655,118.81687299907207,119.09300199896097,119.1513409987092,120.37130599841475,120.67375399917364,120.86141699925065,121.37692600116134,121.50347400084138,122.36241899803281,122.70810800045729,122.89613199979067,123.11405200138688,123.61617599800229,124.1475649997592,124.34458500146866,126.06378800049424,126.18667799979448,126.64983899891376,126.96603399887681,127.51752000302076,127.85983400046825,128.67044800147414,132.14266699925065,134.0649299994111,135.84123999997973,137.67898400127888,137.87513300031424,138.75194199755788,138.7647969983518,139.1910180002451,139.48946899920702,140.04651600122452,140.52569700032473,141.95115599781275,145.6930919997394,145.84002799913287,148.3565689995885,148.63709700107574,149.61825200170279,156.45174799859524,159.12310099974275],"mean":120.38617523986846,"variance":157.94430766393114,"sd":12.567589572544575,"sem":1.2567589572544575,"df":99,"critical":1.9843,"moe":2.49378679888002,"rme":2.0714893499284037,"p75":126.06378800049424,"p99":156.45174799859524,"p995":159.12310099974275,"p999":159.12310099974275},{"totalTime":332638.3692750111,"min":3204.766656998545,"max":3745.5639889985323,"hz":0.30062677440955193,"period":3326.383692750111,"samples":[3204.766656998545,3214.9845269992948,3219.0279789976776,3220.6312830001116,3220.9293829984963,3222.649466998875,3223.5032120011747,3224.314356997609,3229.5999650023878,3232.916138999164,3234.773299999535,3235.755518000573,3236.6217459999025,3237.2919760011137,3237.8091380000114,3238.249605998397,3239.034701999277,3239.291525002569,3241.345287002623,3242.547295998782,3243.7745740003884,3244.297297000885,3244.8451160006225,3245.592660997063,3245.81346699968,3246.8237159997225,3247.1744250021875,3247.8810040019453,3249.4279730021954,3249.4329419992864,3249.9084559977055,3249.9610540010035,3250.1241609975696,3252.3451669998467,3253.2294390015304,3254.0084140002728,3256.0808099992573,3256.6045839972794,3257.4555049985647,3257.6531870029867,3258.5201559998095,3259.964090999216,3261.0969609990716,3261.9362290017307,3261.9993070028722,3262.276126999408,3264.3573299981654,3267.538520999253,3267.785675998777,3268.367760002613,3272.181471001357,3273.4954000003636,3276.806907001883,3276.8203620016575,3276.8539750017226,3277.237254999578,3279.130855999887,3280.7546079978347,3281.3124570026994,3281.7080099992454,3283.6706300005317,3286.4964330010116,3289.6075330004096,3290.887568999082,3294.2855079993606,3295.766261000186,3300.2926409989595,3302.5084969997406,3312.179950002581,3315.1587700024247,3331.7442319989204,3339.1331029981375,3354.7064530029893,3357.92853000015,3385.8360170014203,3398.4634180031717,3420.3473610021174,3426.1686350032687,3434.8194900006056,3438.820301000029,3441.3845020011067,3452.21779999882,3455.2742060013115,3456.0998480021954,3467.608545001596,3487.191211000085,3487.5488440021873,3493.309683997184,3495.012366000563,3522.858517996967,3530.621022000909,3534.4392809979618,3538.773800998926,3543.9955069981515,3599.68636899814,3600.567795999348,3617.627930998802,3619.995852999389,3681.150396000594,3745.5639889985323],"mean":3326.383692750111,"variance":14763.04411505073,"sd":121.50326791922402,"sem":12.150326791922401,"df":99,"critical":1.9843,"moe":24.10989345321162,"rme":0.7248079500196983,"p75":3385.8360170014203,"p99":3681.150396000594,"p995":3745.5639889985323,"p999":3745.5639889985323}]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"totalTime":12038.617523986846,"min":103.67929299920797,"max":159.12310099974275,"hz":8.306601634344709,"period":120.38617523986846,"samples":[103.67929299920797,105.21537199988961,105.42615700140595,106.07665099948645,106.37340800091624,106.42210000008345,106.94859899953008,107.04294800013304,107.76807000115514,107.96288700029254,108.07823400199413,108.35426300019026,108.59506599977612,109.02817900106311,109.05898800119758,109.12921999767423,109.15932599827647,109.55055199936032,109.60058600082994,109.77846100181341,109.85651699826121,110.3762039989233,111.15072999894619,111.17128900066018,111.18644699826837,111.29167499765754,112.28759799897671,112.5253240019083,112.5420360006392,113.1479649990797,113.18393300101161,113.26294099912047,113.3146480023861,113.57648099958897,113.6285380013287,113.77276999875903,113.8291859999299,113.87677500024438,113.91487699747086,114.08545700088143,114.15173299983144,114.5101259984076,114.66707099974155,115.09689899906516,115.28191700205207,115.33678100258112,115.51951399818063,115.75755199790001,115.8184460029006,115.9816830009222,116.02089600265026,116.29580299928784,117.04034299775958,117.16970700025558,117.42955499887466,117.81526900082827,117.9530789963901,118.26566699892282,118.28102499991655,118.81687299907207,119.09300199896097,119.1513409987092,120.37130599841475,120.67375399917364,120.86141699925065,121.37692600116134,121.50347400084138,122.36241899803281,122.70810800045729,122.89613199979067,123.11405200138688,123.61617599800229,124.1475649997592,124.34458500146866,126.06378800049424,126.18667799979448,126.64983899891376,126.96603399887681,127.51752000302076,127.85983400046825,128.67044800147414,132.14266699925065,134.0649299994111,135.84123999997973,137.67898400127888,137.87513300031424,138.75194199755788,138.7647969983518,139.1910180002451,139.48946899920702,140.04651600122452,140.52569700032473,141.95115599781275,145.6930919997394,145.84002799913287,148.3565689995885,148.63709700107574,149.61825200170279,156.45174799859524,159.12310099974275],"mean":120.38617523986846,"variance":157.94430766393114,"sd":12.567589572544575,"sem":1.2567589572544575,"df":99,"critical":1.9843,"moe":2.49378679888002,"rme":2.0714893499284037,"p75":126.06378800049424,"p99":156.45174799859524,"p995":159.12310099974275,"p999":159.12310099974275},{"totalTime":332638.3692750111,"min":3204.766656998545,"max":3745.5639889985323,"hz":0.30062677440955193,"period":3326.383692750111,"samples":[3204.766656998545,3214.9845269992948,3219.0279789976776,3220.6312830001116,3220.9293829984963,3222.649466998875,3223.5032120011747,3224.314356997609,3229.5999650023878,3232.916138999164,3234.773299999535,3235.755518000573,3236.6217459999025,3237.2919760011137,3237.8091380000114,3238.249605998397,3239.034701999277,3239.291525002569,3241.345287002623,3242.547295998782,3243.7745740003884,3244.297297000885,3244.8451160006225,3245.592660997063,3245.81346699968,3246.8237159997225,3247.1744250021875,3247.8810040019453,3249.4279730021954,3249.4329419992864,3249.9084559977055,3249.9610540010035,3250.1241609975696,3252.3451669998467,3253.2294390015304,3254.0084140002728,3256.0808099992573,3256.6045839972794,3257.4555049985647,3257.6531870029867,3258.5201559998095,3259.964090999216,3261.0969609990716,3261.9362290017307,3261.9993070028722,3262.276126999408,3264.3573299981654,3267.538520999253,3267.785675998777,3268.367760002613,3272.181471001357,3273.4954000003636,3276.806907001883,3276.8203620016575,3276.8539750017226,3277.237254999578,3279.130855999887,3280.7546079978347,3281.3124570026994,3281.7080099992454,3283.6706300005317,3286.4964330010116,3289.6075330004096,3290.887568999082,3294.2855079993606,3295.766261000186,3300.2926409989595,3302.5084969997406,3312.179950002581,3315.1587700024247,3331.7442319989204,3339.1331029981375,3354.7064530029893,3357.92853000015,3385.8360170014203,3398.4634180031717,3420.3473610021174,3426.1686350032687,3434.8194900006056,3438.820301000029,3441.3845020011067,3452.21779999882,3455.2742060013115,3456.0998480021954,3467.608545001596,3487.191211000085,3487.5488440021873,3493.309683997184,3495.012366000563,3522.858517996967,3530.621022000909,3534.4392809979618,3538.773800998926,3543.9955069981515,3599.68636899814,3600.567795999348,3617.627930998802,3619.995852999389,3681.150396000594,3745.5639889985323],"mean":3326.383692750111,"variance":14763.04411505073,"sd":121.50326791922402,"sem":12.150326791922401,"df":99,"critical":1.9843,"moe":24.10989345321162,"rme":0.7248079500196983,"p75":3385.8360170014203,"p99":3681.150396000594,"p995":3745.5639889985323,"p999":3745.5639889985323}]
[{"totalTime":6484.837860926986,"min":59.110867008566856,"max":87.08863599598408,"hz":15.420586010720296,"period":64.84837860926986,"samples":[59.110867008566856,59.1824010014534,59.21477100253105,59.56468799710274,59.814165994524956,59.85072399675846,59.88273400068283,59.912499994039536,60.084803998470306,60.094712004065514,60.10085400938988,60.108729004859924,60.147881999611855,60.23088699579239,60.25690600275993,60.282894998788834,60.2951779961586,60.70771199464798,60.876147985458374,60.97610500454903,60.98465099930763,60.98787701129913,61.02575799822807,61.08262500166893,61.09801399707794,61.16643199324608,61.18458600342274,61.3243989944458,61.369783997535706,61.39241699874401,61.54311899840832,61.54516200721264,61.587502002716064,61.62519299983978,61.63101300597191,61.644989997148514,61.670386999845505,61.69004400074482,61.722786009311676,61.78959099948406,61.81807500123978,61.84595599770546,61.85988299548626,62.19385899603367,62.309826999902725,62.31903399527073,62.39989599585533,62.50789798796177,62.53175300359726,62.56945399940014,62.569755002856255,62.5966539978981,62.60786598920822,62.890405997633934,62.89710898697376,63.23851899802685,63.28581699728966,63.59174199402332,63.66777400672436,63.71417099237442,63.78296999633312,63.87477199733257,63.938391000032425,64.31927600502968,64.39532899856567,64.4111790060997,64.42293000221252,64.44337899982929,64.78506000339985,64.79991799592972,65.03503800928593,65.49701499938965,65.50855699181557,65.84187200665474,65.94699001312256,65.95319099724293,65.99998900294304,66.08319500088692,66.48228299617767,66.78522099554539,67.31182999908924,67.52534998953342,67.66360899806023,68.1775140017271,68.61920200288296,68.89064100384712,69.08179999887943,71.14332599937916,72.27357698976994,72.60403700172901,74.12467899918556,75.49629099667072,75.65519900619984,79.3108460009098,81.63455499708652,82.68580700457096,82.85039599239826,83.41518498957157,84.80138500034809,87.08863599598408],"mean":64.84837860926986,"variance":37.86263667727225,"sd":6.153262279252547,"sem":0.6153262279252547,"df":99,"critical":1.9843,"moe":1.220991834072083,"rme":1.8828409595695677,"p75":65.94699001312256,"p99":84.80138500034809,"p995":87.08863599598408,"p999":87.08863599598408},{"totalTime":8202.31437894702,"min":68.43019700050354,"max":118.78751400113106,"hz":12.191680954910876,"period":82.0231437894702,"samples":[68.43019700050354,68.91907399892807,69.5045619904995,69.54134099185467,69.58971200883389,70.12540699541569,70.226876989007,70.43274399638176,71.03412100672722,71.03584499657154,71.14264500141144,71.15501800179482,71.19879101216793,71.24176099896431,71.29664398729801,71.69098399579525,71.7467180043459,71.82357300817966,72.02321700751781,72.08655498921871,72.10916800796986,72.18135400116444,72.37805299460888,72.49479100108147,72.90464000403881,72.9311999976635,72.9316999912262,72.95439299941063,72.96473298966885,73.60239899158478,73.65014800429344,73.67279100418091,73.90494599938393,73.92232900857925,74.07671900093555,74.28066100180149,74.31397299468517,74.39040699601173,75.00527000427246,75.04041600227356,75.20914299786091,75.50760300457478,75.56523001194,76.16936299204826,76.37575098872185,76.5730210095644,76.87455600500107,77.01131299138069,77.75172200798988,77.92608898878098,78.31904599070549,78.39142200350761,78.7987459897995,78.87123200297356,79.4152820110321,79.4499370008707,79.88060499727726,80.59483501315117,81.03545100986958,81.72705899178982,82.331571996212,82.46139600872993,82.53383199870586,82.6266960054636,83.0465029925108,84.38883098959923,84.58172300457954,84.80459100008011,84.86059600114822,86.39394199848175,87.0072529911995,87.07985900342464,87.10671900212765,87.33471700549126,87.62457999587059,88.54253199696541,88.70247299969196,89.07718499004841,89.43451599776745,91.60444600880146,92.55506899952888,92.67437300086021,93.58101400732994,93.81955099105835,94.22523200511932,94.45705699920654,94.46028199791908,95.52897699177265,96.49612100422382,100.0242790132761,102.59572198987007,102.6022850126028,103.5942460000515,106.71463899314404,107.97712698578835,109.3855289965868,109.53472799062729,110.29556499421597,116.05782400071621,118.78751400113106],"mean":82.0231437894702,"variance":141.25572211535538,"sd":11.885105052769006,"sem":1.1885105052769007,"df":99,"critical":1.9843,"moe":2.358361395620954,"rme":2.8752389711789017,"p75":87.62457999587059,"p99":116.05782400071621,"p995":118.78751400113106,"p999":118.78751400113106}]
7 changes: 3 additions & 4 deletions benchmarks/tailwind-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"main": "dist/benchmark.js",
"scripts": {
"with-vs-without": "pnpm compile && node ./dist/benchmark-with-vs-without.js",
"before-perf-vs-after-perf": "pnpm compile && node ./dist/benchmark-0.0.12-vs-local-version",
"0.0.13-vs-local-version": "pnpm compile && node ./dist/benchmark-0.0.13-vs-local-version",
"flamegraph-render-tailwind": "pnpm compile && node --prof ./dist/tailwind-render && node --prof-process --preprocess -j isolate*.log | flamebearer",

"compile": "tsup src/*.ts",
"lint": "eslint ."
},
Expand All @@ -22,14 +21,14 @@
"dependencies": {
"@react-email/components": "workspace:*",
"@react-email/render": "workspace:*",
"@react-email/tailwind": "0.0.12",
"@react-email/tailwind": "0.0.13",
"react": "18.2.0",
"tinybench": "2.5.1"
},
"devDependencies": {
"eslint-config-custom": "workspace:*",
"tsconfig": "workspace:*",
"flamebearer": "1.1.3",
"tsconfig": "workspace:*",
"tsup": "7.2.0",
"typescript": "5.1.6"
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/tailwind/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
extends: ["custom/react-internal"],
ignorePatterns: ["automated-test-next-app/**/*"],
plugins: [
/* just a plugin to create custom linting rules with regex */
"regex"
Expand Down
37 changes: 37 additions & 0 deletions packages/tailwind/automated-test-next-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Plus Five Five, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@react-email/tailwind",
"version": "0.0.14",
"description": "A React component to wrap emails with Tailwind CSS",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"license": "MIT",
"scripts": {
"build": "tsc && NODE_ENV=production vite build --mode production",
"dev": "vite build --watch",
"clean": "rm -rf dist",
"lint": "eslint .",
"test:watch": "vitest",
"test": "vitest run"
},
"repository": {
"type": "git",
"url": "https://github.com/resend/react-email.git",
"directory": "packages/tailwind"
},
"keywords": [
"react",
"email",
"tailwind"
],
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"postcss": "8.4.35",
"postcss-combine-media-query": "1.0.1",
"postcss-selector-parser": "6.0.15",
"react": "18.2.0"
},
"peerDependencies": {
"react": "18.2.0"
},
"publishConfig": {
"access": "public"
},
"yalcSig": "27ab287616a9b042b5a1f10b4bb694a1"
}
Loading
Loading