Skip to content

Commit 4d86a65

Browse files
committed
refactor(jit): ♻️ update jit & patch
1 parent f702e51 commit 4d86a65

File tree

3 files changed

+53
-40
lines changed

3 files changed

+53
-40
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"@storybook/addon-links": "^6.2.1",
8989
"@storybook/addon-postcss": "^2.0.0",
9090
"@storybook/react": "^6.2.1",
91-
"@tailwindcss/jit": "^0.1.7",
92-
"@testing-library/dom": "^7.30.2",
91+
"@tailwindcss/jit": "^0.1.17",
92+
"@testing-library/dom": "^7.30.3",
9393
"@testing-library/jest-dom": "^5.11.10",
9494
"@testing-library/react": "^11.2.6",
9595
"@testing-library/react-hooks": "^5.1.1",
@@ -151,6 +151,9 @@
151151
"react": "16.x || 17.x",
152152
"react-dom": "16.x || 17.x"
153153
},
154+
"publishConfig": {
155+
"access": "public"
156+
},
154157
"tsd": {
155158
"directory": "src/theme"
156159
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/node_modules/@tailwindcss/jit/src/lib/generateRules.js b/node_modules/@tailwindcss/jit/src/lib/generateRules.js
2-
index 7c98014..42a357f 100644
2+
index fe48a0d..28abdf5 100644
33
--- a/node_modules/@tailwindcss/jit/src/lib/generateRules.js
44
+++ b/node_modules/@tailwindcss/jit/src/lib/generateRules.js
5-
@@ -65,16 +65,21 @@ function applyPrefix(matches, context) {
5+
@@ -94,12 +94,15 @@ function applyImportant(matches) {
66
// and `focus:hover:text-center` in the same project, but it doesn't feel
77
// worth the complexity for that case.
88

@@ -16,16 +16,10 @@ index 7c98014..42a357f 100644
1616
+ let updateSort =
1717
+ hasLibVariant &&
1818
+ !['sm', 'md', 'lg', 'xl', '2xl', 'motion-safe', 'dark', 'motion-reduce'].includes(variant)
19-
+
2019
let [variantSort, applyThisVariant] = context.variantMap.get(variant)
2120
let result = []
2221

23-
for (let [{ sort, layer, options }, rule] of matches) {
24-
+
25-
if (options.respectVariants === false) {
26-
result.push([{ sort, layer, options }, rule])
27-
continue
28-
@@ -110,7 +115,10 @@ function applyVariant(variant, matches, context) {
22+
@@ -139,7 +142,10 @@ function applyVariant(variant, matches, context) {
2923
continue
3024
}
3125

@@ -37,15 +31,15 @@ index 7c98014..42a357f 100644
3731
result.push(withOffset)
3832
}
3933

40-
@@ -171,6 +179,7 @@ function sortAgainst(toSort, against) {
34+
@@ -200,6 +206,7 @@ function sortAgainst(toSort, against) {
4135
function* resolveMatches(candidate, context) {
4236
let separator = context.tailwindConfig.separator
4337
let [classCandidate, ...variants] = candidate.split(separator).reverse()
4438
+ let hasLibVariant = variants.includes('lib')
39+
let important = false
4540

46-
// Strip prefix
47-
// md:hover:tw-bg-black
48-
@@ -196,7 +205,14 @@ function* resolveMatches(candidate, context) {
41+
if (classCandidate.startsWith('!')) {
42+
@@ -231,7 +238,14 @@ function* resolveMatches(candidate, context) {
4943
for (let ruleSet of [].concat(plugin(modifier, pluginHelpers))) {
5044
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache)
5145
for (let rule of rules) {
@@ -61,24 +55,24 @@ index 7c98014..42a357f 100644
6155
}
6256
}
6357
}
64-
@@ -205,7 +221,14 @@ function* resolveMatches(candidate, context) {
58+
@@ -240,7 +254,14 @@ function* resolveMatches(candidate, context) {
6559
let ruleSet = plugin
6660
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache)
6761
for (let rule of rules) {
6862
- matches.push([{ ...sort, options: { ...sort.options, ...options } }, rule])
6963
+ matches.push([
70-
+ {
71-
+ ...sort,
72-
+ options: { ...sort.options, ...options },
73-
+ sort: hasLibVariant ? 0n : sort.sort,
74-
+ },
75-
+ rule,
76-
+ ])
64+
+ {
65+
+ ...sort,
66+
+ options: { ...sort.options, ...options },
67+
+ sort: hasLibVariant ? 0n : sort.sort,
68+
+ },
69+
+ rule,
70+
+ ])
7771
}
7872
}
7973
}
80-
@@ -213,7 +236,7 @@ function* resolveMatches(candidate, context) {
81-
matches = applyPrefix(matches, context)
74+
@@ -252,7 +273,7 @@ function* resolveMatches(candidate, context) {
75+
}
8276

8377
for (let variant of variants) {
8478
- matches = applyVariant(variant, matches, context)
@@ -87,10 +81,10 @@ index 7c98014..42a357f 100644
8781

8882
for (let match of matches) {
8983
diff --git a/node_modules/@tailwindcss/jit/src/lib/setupContext.js b/node_modules/@tailwindcss/jit/src/lib/setupContext.js
90-
index c2a4133..68b3c9f 100644
84+
index 65538d0..27c9c4b 100644
9185
--- a/node_modules/@tailwindcss/jit/src/lib/setupContext.js
9286
+++ b/node_modules/@tailwindcss/jit/src/lib/setupContext.js
93-
@@ -559,10 +559,11 @@ function collectLayerPlugins(root) {
87+
@@ -613,10 +613,11 @@ function collectLayerPlugins(root) {
9488
function registerPlugins(tailwindConfig, plugins, context) {
9589
let variantList = []
9690
let variantMap = new Map()
@@ -105,7 +99,7 @@ index c2a4133..68b3c9f 100644
10599
}
106100

107101
let pluginApi = buildPluginApi(tailwindConfig, context, {
108-
@@ -586,7 +587,7 @@ function registerPlugins(tailwindConfig, plugins, context) {
102+
@@ -640,7 +641,7 @@ function registerPlugins(tailwindConfig, plugins, context) {
109103
offsets.components,
110104
offsets.utilities,
111105
])
@@ -114,7 +108,7 @@ index c2a4133..68b3c9f 100644
114108

115109
context.layerOrder = {
116110
base: (1n << reservedBits) << 0n,
117-
@@ -595,10 +596,10 @@ function registerPlugins(tailwindConfig, plugins, context) {
111+
@@ -649,10 +650,10 @@ function registerPlugins(tailwindConfig, plugins, context) {
118112
}
119113

120114
reservedBits += 3n
@@ -123,9 +117,9 @@ index c2a4133..68b3c9f 100644
123117
- new Map()
124118
- )
125119
+ context.variantOrder = variantList.reduce((map, variant, i) => {
126-
+ if (variant.includes('lib')) return map.set(variant, 1n)
127-
+ return map.set(variant, (1n << BigInt(i)) << reservedBits)
128-
+ }, new Map())
120+
+ if (variant.includes('lib')) return map.set(variant, 1n)
121+
+ return map.set(variant, (1n << BigInt(i)) << reservedBits)
122+
+ }, new Map())
129123

130124
context.minimumScreen = [...context.variantOrder.values()].shift()
131125

yarn.lock

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,17 +2722,18 @@
27222722
dependencies:
27232723
defer-to-connect "^1.0.1"
27242724

2725-
"@tailwindcss/jit@^0.1.7":
2726-
version "0.1.7"
2727-
resolved "https://registry.yarnpkg.com/@tailwindcss/jit/-/jit-0.1.7.tgz#9916a53e13937346912285faaea05d151d12f1e2"
2728-
integrity sha512-v2TtFXvecPQ105ko2aaXp26VMtaBudpwB0039rxYy/yg6c34IX91HAmOEuotUwcwNvSW6I97YtzNg9ps3blr0A==
2725+
"@tailwindcss/jit@^0.1.17":
2726+
version "0.1.17"
2727+
resolved "https://registry.yarnpkg.com/@tailwindcss/jit/-/jit-0.1.17.tgz#0fe54a6bd9473c3c1a5cb622ba771d69117a3d49"
2728+
integrity sha512-Of3NbM2Peex6iPkOap5JBmAPq6oVjKEKMysy6iH/9Vl0TjuEuB094Uc7yzJz8q6j6AQEImlaOGxwF+sdBlG2pw==
27292729
dependencies:
27302730
chokidar "^3.5.1"
27312731
dlv "^1.1.3"
27322732
fast-glob "^3.2.5"
27332733
lodash.topath "^4.5.2"
27342734
normalize-path "^3.0.0"
27352735
object-hash "^2.1.1"
2736+
parse-glob "^3.0.4"
27362737
postcss-selector-parser "^6.0.4"
27372738
quick-lru "^5.1.1"
27382739

@@ -2750,10 +2751,10 @@
27502751
lz-string "^1.4.4"
27512752
pretty-format "^26.6.2"
27522753

2753-
"@testing-library/dom@^7.30.2":
2754-
version "7.30.2"
2755-
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.30.2.tgz#a63ae7078235ec6248a8a522b04e696ab49896cc"
2756-
integrity sha512-NJzHILb5De0J0varzT0W00qDTLcbF86etfAyx5ty7iJhpR6eCs+JR99Ls7AMSUG2bWRYIG0u4KTPH6PMcZhlWQ==
2754+
"@testing-library/dom@^7.30.3":
2755+
version "7.30.3"
2756+
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.30.3.tgz#779ea9bbb92d63302461800a388a5a890ac22519"
2757+
integrity sha512-7JhIg2MW6WPwyikH2iL3o7z+FTVgSOd2jqCwTAHqK7Qal2gRRYiUQyURAxtbK9VXm/UTyG9bRihv8C5Tznr2zw==
27572758
dependencies:
27582759
"@babel/code-frame" "^7.10.4"
27592760
"@babel/runtime" "^7.12.5"
@@ -8464,6 +8465,11 @@ is-dom@^1.0.0:
84648465
is-object "^1.0.1"
84658466
is-window "^1.0.2"
84668467

8468+
is-dotfile@^1.0.0:
8469+
version "1.0.3"
8470+
resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1"
8471+
integrity sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=
8472+
84678473
is-extendable@^0.1.0, is-extendable@^0.1.1:
84688474
version "0.1.1"
84698475
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
@@ -10940,6 +10946,16 @@ parse-github-repo-url@^1.3.0:
1094010946
resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50"
1094110947
integrity sha1-nn2LslKmy2ukJZUGC3v23z28H1A=
1094210948

10949+
parse-glob@^3.0.4:
10950+
version "3.0.4"
10951+
resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
10952+
integrity sha1-ssN2z7EfNVE7rdFz7wu246OIORw=
10953+
dependencies:
10954+
glob-base "^0.3.0"
10955+
is-dotfile "^1.0.0"
10956+
is-extglob "^1.0.0"
10957+
is-glob "^2.0.0"
10958+
1094310959
parse-json@^2.2.0:
1094410960
version "2.2.0"
1094510961
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"

0 commit comments

Comments
 (0)