tailwindcss 0.0.0-insiders.ea80db2 → 0.0.0-insiders.eae2b7a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +13 -9
  2. package/defaultTheme.d.ts +2 -1
  3. package/index.css +5 -0
  4. package/lib/cli/build/index.js +57 -0
  5. package/lib/cli/build/plugin.js +427 -0
  6. package/lib/cli/build/utils.js +88 -0
  7. package/lib/cli/build/watching.js +182 -0
  8. package/lib/cli/help/index.js +73 -0
  9. package/lib/cli/index.js +231 -0
  10. package/lib/cli/init/index.js +63 -0
  11. package/lib/cli.js +1 -759
  12. package/lib/corePluginList.js +12 -3
  13. package/lib/corePlugins.js +2308 -1739
  14. package/lib/css/preflight.css +13 -5
  15. package/lib/featureFlags.js +50 -25
  16. package/lib/index.js +1 -40
  17. package/lib/lib/cacheInvalidation.js +48 -25
  18. package/lib/lib/collapseAdjacentRules.js +17 -10
  19. package/lib/lib/collapseDuplicateDeclarations.js +13 -8
  20. package/lib/lib/content.js +207 -0
  21. package/lib/lib/defaultExtractor.js +232 -33
  22. package/lib/lib/detectNesting.js +21 -10
  23. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  24. package/lib/lib/expandApplyAtRules.js +316 -215
  25. package/lib/lib/expandTailwindAtRules.js +167 -115
  26. package/lib/lib/findAtConfigPath.js +46 -0
  27. package/lib/lib/generateRules.js +444 -211
  28. package/lib/lib/getModuleDependencies.js +88 -37
  29. package/lib/lib/handleImportAtRules.js +50 -0
  30. package/lib/lib/load-config.js +42 -0
  31. package/lib/lib/normalizeTailwindDirectives.js +29 -39
  32. package/lib/lib/offsets.js +306 -0
  33. package/lib/lib/partitionApplyAtRules.js +13 -8
  34. package/lib/lib/regex.js +74 -0
  35. package/lib/lib/remap-bitfield.js +89 -0
  36. package/lib/lib/resolveDefaultsAtRules.js +96 -74
  37. package/lib/lib/setupContextUtils.js +672 -300
  38. package/lib/lib/setupTrackingContext.js +63 -68
  39. package/lib/lib/sharedState.js +44 -17
  40. package/lib/lib/substituteScreenAtRules.js +14 -10
  41. package/lib/plugin.js +160 -0
  42. package/lib/postcss-plugins/nesting/README.md +2 -2
  43. package/lib/postcss-plugins/nesting/index.js +10 -6
  44. package/lib/postcss-plugins/nesting/plugin.js +24 -20
  45. package/lib/processTailwindFeatures.js +34 -29
  46. package/lib/public/colors.js +272 -246
  47. package/lib/public/create-plugin.js +9 -5
  48. package/lib/public/default-config.js +10 -6
  49. package/lib/public/default-theme.js +10 -6
  50. package/lib/public/load-config.js +12 -0
  51. package/lib/public/resolve-config.js +11 -6
  52. package/lib/util/applyImportantSelector.js +36 -0
  53. package/lib/util/bigSign.js +6 -1
  54. package/lib/util/buildMediaQuery.js +13 -6
  55. package/lib/util/cloneDeep.js +9 -6
  56. package/lib/util/cloneNodes.js +12 -3
  57. package/lib/util/color.js +66 -50
  58. package/lib/util/colorNames.js +752 -0
  59. package/lib/util/configurePlugins.js +7 -2
  60. package/lib/util/createPlugin.js +8 -5
  61. package/lib/util/createUtilityPlugin.js +13 -9
  62. package/lib/util/dataTypes.js +182 -111
  63. package/lib/util/defaults.js +12 -7
  64. package/lib/util/escapeClassName.js +13 -8
  65. package/lib/util/escapeCommas.js +7 -2
  66. package/lib/util/flattenColorPalette.js +11 -10
  67. package/lib/util/formatVariantSelector.js +228 -151
  68. package/lib/util/getAllConfigs.js +33 -12
  69. package/lib/util/hashConfig.js +9 -4
  70. package/lib/util/isKeyframeRule.js +7 -2
  71. package/lib/util/isPlainObject.js +7 -2
  72. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  73. package/lib/util/log.js +40 -13
  74. package/lib/util/nameClass.js +27 -10
  75. package/lib/util/negateValue.js +25 -8
  76. package/lib/util/normalizeConfig.js +155 -87
  77. package/lib/util/normalizeScreens.js +127 -8
  78. package/lib/util/parseAnimationValue.js +44 -40
  79. package/lib/util/parseBoxShadowValue.js +33 -62
  80. package/lib/util/parseDependency.js +39 -55
  81. package/lib/util/parseGlob.js +36 -0
  82. package/lib/util/parseObjectStyles.js +15 -10
  83. package/lib/util/pluginUtils.js +154 -59
  84. package/lib/util/prefixSelector.js +29 -10
  85. package/lib/util/pseudoElements.js +209 -0
  86. package/lib/util/removeAlphaVariables.js +31 -0
  87. package/lib/util/resolveConfig.js +96 -95
  88. package/lib/util/resolveConfigPath.js +29 -10
  89. package/lib/util/responsive.js +11 -6
  90. package/lib/util/splitAtTopLevelOnly.js +51 -0
  91. package/lib/util/tap.js +6 -1
  92. package/lib/util/toColorValue.js +7 -2
  93. package/lib/util/toPath.js +22 -4
  94. package/lib/util/transformThemeValue.js +40 -26
  95. package/lib/util/validateConfig.js +48 -0
  96. package/lib/util/validateFormalSyntax.js +26 -0
  97. package/lib/util/withAlphaVariable.js +27 -15
  98. package/lib/value-parser/LICENSE +22 -0
  99. package/lib/value-parser/README.md +3 -0
  100. package/lib/value-parser/index.d.js +2 -0
  101. package/lib/value-parser/index.js +22 -0
  102. package/lib/value-parser/parse.js +259 -0
  103. package/lib/value-parser/stringify.js +38 -0
  104. package/lib/value-parser/unit.js +86 -0
  105. package/lib/value-parser/walk.js +16 -0
  106. package/loadConfig.d.ts +4 -0
  107. package/loadConfig.js +2 -0
  108. package/package.json +54 -52
  109. package/plugin.d.ts +10 -5
  110. package/resolveConfig.d.ts +12 -0
  111. package/scripts/generate-types.js +53 -0
  112. package/scripts/release-channel.js +18 -0
  113. package/scripts/release-notes.js +21 -0
  114. package/scripts/type-utils.js +27 -0
  115. package/src/cli/build/index.js +53 -0
  116. package/src/cli/build/plugin.js +465 -0
  117. package/src/cli/build/utils.js +76 -0
  118. package/src/cli/build/watching.js +229 -0
  119. package/src/cli/help/index.js +70 -0
  120. package/src/cli/index.js +217 -0
  121. package/src/cli/init/index.js +79 -0
  122. package/src/cli.js +1 -836
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +576 -106
  125. package/src/css/preflight.css +13 -5
  126. package/src/featureFlags.js +17 -3
  127. package/src/index.js +1 -42
  128. package/src/lib/collapseAdjacentRules.js +5 -1
  129. package/src/lib/content.js +240 -0
  130. package/src/lib/defaultExtractor.js +202 -35
  131. package/src/lib/detectNesting.js +9 -1
  132. package/src/lib/evaluateTailwindFunctions.js +82 -8
  133. package/src/lib/expandApplyAtRules.js +322 -189
  134. package/src/lib/expandTailwindAtRules.js +82 -59
  135. package/src/lib/findAtConfigPath.js +48 -0
  136. package/src/lib/generateRules.js +413 -132
  137. package/src/lib/getModuleDependencies.js +70 -30
  138. package/src/lib/handleImportAtRules.js +34 -0
  139. package/src/lib/load-config.ts +31 -0
  140. package/src/lib/normalizeTailwindDirectives.js +0 -27
  141. package/src/lib/offsets.js +373 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/remap-bitfield.js +82 -0
  144. package/src/lib/resolveDefaultsAtRules.js +53 -36
  145. package/src/lib/setupContextUtils.js +570 -151
  146. package/src/lib/setupTrackingContext.js +44 -58
  147. package/src/lib/sharedState.js +13 -4
  148. package/src/plugin.js +128 -0
  149. package/src/postcss-plugins/nesting/README.md +2 -2
  150. package/src/public/colors.js +22 -0
  151. package/src/public/default-config.js +1 -1
  152. package/src/public/default-theme.js +2 -2
  153. package/src/public/load-config.js +2 -0
  154. package/src/util/applyImportantSelector.js +27 -0
  155. package/src/util/buildMediaQuery.js +5 -3
  156. package/src/util/cloneNodes.js +5 -1
  157. package/src/util/color.js +34 -17
  158. package/src/util/colorNames.js +150 -0
  159. package/src/util/dataTypes.js +67 -23
  160. package/src/util/formatVariantSelector.js +264 -144
  161. package/src/util/getAllConfigs.js +21 -2
  162. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  163. package/src/util/log.js +25 -1
  164. package/src/util/nameClass.js +4 -0
  165. package/src/util/negateValue.js +11 -3
  166. package/src/util/normalizeConfig.js +78 -20
  167. package/src/util/normalizeScreens.js +99 -4
  168. package/src/util/parseBoxShadowValue.js +3 -50
  169. package/src/util/parseDependency.js +37 -42
  170. package/src/util/parseGlob.js +24 -0
  171. package/src/util/pluginUtils.js +118 -23
  172. package/src/util/prefixSelector.js +28 -10
  173. package/src/util/pseudoElements.js +167 -0
  174. package/src/util/removeAlphaVariables.js +24 -0
  175. package/src/util/resolveConfig.js +70 -62
  176. package/src/util/resolveConfigPath.js +12 -1
  177. package/src/util/splitAtTopLevelOnly.js +52 -0
  178. package/src/util/toPath.js +1 -1
  179. package/src/util/transformThemeValue.js +13 -3
  180. package/src/util/validateConfig.js +36 -0
  181. package/src/util/validateFormalSyntax.js +34 -0
  182. package/src/util/withAlphaVariable.js +1 -1
  183. package/src/value-parser/LICENSE +22 -0
  184. package/src/value-parser/README.md +3 -0
  185. package/src/value-parser/index.d.ts +177 -0
  186. package/src/value-parser/index.js +28 -0
  187. package/src/value-parser/parse.js +303 -0
  188. package/src/value-parser/stringify.js +41 -0
  189. package/src/value-parser/unit.js +118 -0
  190. package/src/value-parser/walk.js +18 -0
  191. package/stubs/.gitignore +1 -0
  192. package/stubs/.prettierrc.json +6 -0
  193. package/stubs/{defaultConfig.stub.js → config.full.js} +215 -165
  194. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -1
  195. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  196. package/stubs/postcss.config.js +5 -0
  197. package/stubs/tailwind.config.cjs +2 -0
  198. package/stubs/tailwind.config.js +2 -0
  199. package/stubs/tailwind.config.ts +3 -0
  200. package/types/config.d.ts +102 -56
  201. package/types/generated/colors.d.ts +22 -0
  202. package/types/generated/corePluginList.d.ts +1 -1
  203. package/types/generated/default-theme.d.ts +372 -0
  204. package/types/index.d.ts +7 -1
  205. package/CHANGELOG.md +0 -2099
  206. package/lib/cli-peer-dependencies.js +0 -15
  207. package/lib/constants.js +0 -37
  208. package/peers/index.js +0 -75156
  209. package/scripts/install-integrations.js +0 -27
  210. package/scripts/rebuildFixtures.js +0 -68
  211. package/src/cli-peer-dependencies.js +0 -9
  212. package/src/constants.js +0 -17
  213. package/types.d.ts +0 -1
@@ -1,26 +1,35 @@
1
+ // @ts-check
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
- exports.default = setupTrackingContext;
6
- var _fs = _interopRequireDefault(require("fs"));
7
- var _path = _interopRequireDefault(require("path"));
8
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
9
- var _quickLru = _interopRequireDefault(require("quick-lru"));
10
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
11
- var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
12
- var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
13
- var _resolveConfig = _interopRequireDefault(require("../public/resolve-config"));
14
- var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
15
- var _sharedState = require("./sharedState");
16
- var _setupContextUtils = require("./setupContextUtils");
17
- var _parseDependency = _interopRequireDefault(require("../util/parseDependency"));
18
- function _interopRequireDefault(obj) {
6
+ Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
7
+ // Retrieve an existing context from cache if possible (since contexts are unique per
8
+ // source path), or set up a new one (including setting up watchers and registering
9
+ // plugins) then return it
10
+ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return setupTrackingContext;
14
+ }
15
+ });
16
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
+ const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
18
+ const _hashConfig = /*#__PURE__*/ _interop_require_default(require("../util/hashConfig"));
19
+ const _resolveconfig = /*#__PURE__*/ _interop_require_default(require("../public/resolve-config"));
20
+ const _resolveConfigPath = /*#__PURE__*/ _interop_require_default(require("../util/resolveConfigPath"));
21
+ const _setupContextUtils = require("./setupContextUtils");
22
+ const _parseDependency = /*#__PURE__*/ _interop_require_default(require("../util/parseDependency"));
23
+ const _validateConfig = require("../util/validateConfig.js");
24
+ const _content = require("./content.js");
25
+ const _loadconfig = require("../lib/load-config");
26
+ const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("./getModuleDependencies"));
27
+ function _interop_require_default(obj) {
19
28
  return obj && obj.__esModule ? obj : {
20
29
  default: obj
21
30
  };
22
31
  }
23
- let configPathCache = new _quickLru.default({
32
+ let configPathCache = new _quicklru.default({
24
33
  maxSize: 100
25
34
  });
26
35
  let candidateFilesCache = new WeakMap();
@@ -28,18 +37,15 @@ function getCandidateFiles(context, tailwindConfig) {
28
37
  if (candidateFilesCache.has(context)) {
29
38
  return candidateFilesCache.get(context);
30
39
  }
31
- let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
32
- ).map((contentPath)=>(0, _normalizePath).default(contentPath)
33
- );
40
+ let candidateFiles = (0, _content.parseCandidateFiles)(context, tailwindConfig);
34
41
  return candidateFilesCache.set(context, candidateFiles).get(context);
35
42
  }
36
43
  // Get the config object based on a path
37
44
  function getTailwindConfig(configOrPath) {
38
- let userConfigPath = (0, _resolveConfigPath).default(configOrPath);
45
+ let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
39
46
  if (userConfigPath !== null) {
40
47
  let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
41
- let newDeps = (0, _getModuleDependencies).default(userConfigPath).map((dep)=>dep.file
42
- );
48
+ let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
43
49
  let modified = false;
44
50
  let newModified = new Map();
45
51
  for (let file of newDeps){
@@ -59,11 +65,11 @@ function getTailwindConfig(configOrPath) {
59
65
  ];
60
66
  }
61
67
  // It has changed (based on timestamps), or first run
62
- for (let file1 of newDeps){
63
- delete require.cache[file1];
68
+ for (let file of newDeps){
69
+ delete require.cache[file];
64
70
  }
65
- let newConfig = (0, _resolveConfig).default(require(userConfigPath));
66
- let newHash = (0, _hashConfig).default(newConfig);
71
+ let newConfig = (0, _validateConfig.validateConfig)((0, _resolveconfig.default)((0, _loadconfig.loadConfig)(userConfigPath)));
72
+ let newHash = (0, _hashConfig.default)(newConfig);
67
73
  configPathCache.set(userConfigPath, [
68
74
  newConfig,
69
75
  newHash,
@@ -77,47 +83,17 @@ function getTailwindConfig(configOrPath) {
77
83
  newDeps
78
84
  ];
79
85
  }
86
+ var _configOrPath_config, _ref;
80
87
  // It's a plain object, not a path
81
- let newConfig = (0, _resolveConfig).default(configOrPath.config === undefined ? configOrPath : configOrPath.config);
88
+ let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config = configOrPath === null || configOrPath === void 0 ? void 0 : configOrPath.config) !== null && _configOrPath_config !== void 0 ? _configOrPath_config : configOrPath) !== null && _ref !== void 0 ? _ref : {});
89
+ newConfig = (0, _validateConfig.validateConfig)(newConfig);
82
90
  return [
83
91
  newConfig,
84
92
  null,
85
- (0, _hashConfig).default(newConfig),
93
+ (0, _hashConfig.default)(newConfig),
86
94
  []
87
95
  ];
88
96
  }
89
- function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
90
- let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
91
- ).map(({ raw , extension ='html' })=>({
92
- content: raw,
93
- extension
94
- })
95
- );
96
- for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
97
- let content = _fs.default.readFileSync(changedFile, 'utf8');
98
- let extension = _path.default.extname(changedFile).slice(1);
99
- changedContent.push({
100
- content,
101
- extension
102
- });
103
- }
104
- return changedContent;
105
- }
106
- function resolveChangedFiles(candidateFiles, fileModifiedMap) {
107
- let changedFiles = new Set();
108
- _sharedState.env.DEBUG && console.time('Finding changed files');
109
- let files = _fastGlob.default.sync(candidateFiles);
110
- for (let file of files){
111
- let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
112
- let modified = _fs.default.statSync(file).mtimeMs;
113
- if (modified > prevModified) {
114
- changedFiles.add(file);
115
- fileModifiedMap.set(file, modified);
116
- }
117
- }
118
- _sharedState.env.DEBUG && console.timeEnd('Finding changed files');
119
- return changedFiles;
120
- }
121
97
  function setupTrackingContext(configOrPath) {
122
98
  return ({ tailwindDirectives , registerDependency })=>{
123
99
  return (root, result)=>{
@@ -134,12 +110,13 @@ function setupTrackingContext(configOrPath) {
134
110
  contextDependencies.add(result.opts.from);
135
111
  // Add all css @import dependencies as context dependencies.
136
112
  for (let message of result.messages){
137
- if (message.type === 'dependency') {
113
+ if (message.type === "dependency") {
138
114
  contextDependencies.add(message.file);
139
115
  }
140
116
  }
141
117
  }
142
- let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
118
+ let [context, , mTimesToCommit] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
119
+ let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
143
120
  let candidateFiles = getCandidateFiles(context, tailwindConfig);
144
121
  // If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
145
122
  // dependencies to be dependencies of the context. Can reuse the context even if they change.
@@ -147,24 +124,42 @@ function setupTrackingContext(configOrPath) {
147
124
  // because it's impossible for a layer in one file to end up in the actual @tailwind rule
148
125
  // in another file since independent sources are effectively isolated.
149
126
  if (tailwindDirectives.size > 0) {
150
- let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
151
127
  // Add template paths as postcss dependencies.
152
- for (let fileOrGlob of candidateFiles){
153
- let dependency = (0, _parseDependency).default(fileOrGlob);
154
- if (dependency) {
128
+ for (let contentPath of candidateFiles){
129
+ for (let dependency of (0, _parseDependency.default)(contentPath)){
155
130
  registerDependency(dependency);
156
131
  }
157
132
  }
158
- for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)){
159
- context.changedContent.push(changedContent);
133
+ let [changedContent, contentMTimesToCommit] = (0, _content.resolvedChangedContent)(context, candidateFiles, fileModifiedMap);
134
+ for (let content of changedContent){
135
+ context.changedContent.push(content);
136
+ }
137
+ // Add the mtimes of the content files to the commit list
138
+ // We can overwrite the existing values because unconditionally
139
+ // This is because:
140
+ // 1. Most of the files here won't be in the map yet
141
+ // 2. If they are that means it's a context dependency
142
+ // and we're reading this after the context. This means
143
+ // that the mtime we just read is strictly >= the context
144
+ // mtime. Unless the user / os is doing something weird
145
+ // in which the mtime would be going backwards. If that
146
+ // happens there's already going to be problems.
147
+ for (let [path, mtime] of contentMTimesToCommit.entries()){
148
+ mTimesToCommit.set(path, mtime);
160
149
  }
161
150
  }
162
151
  for (let file of configDependencies){
163
152
  registerDependency({
164
- type: 'dependency',
153
+ type: "dependency",
165
154
  file
166
155
  });
167
156
  }
157
+ // "commit" the new modified time for all context deps
158
+ // We do this here because we want content tracking to
159
+ // read the "old" mtime even when it's a context dependency.
160
+ for (let [path, mtime] of mTimesToCommit.entries()){
161
+ fileModifiedMap.set(path, mtime);
162
+ }
168
163
  return context;
169
164
  };
170
165
  };
@@ -2,32 +2,60 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.resolveDebug = resolveDebug;
6
- exports.NOT_ON_DEMAND = exports.sourceHashMap = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
7
- const env = {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ env: function() {
13
+ return env;
14
+ },
15
+ contextMap: function() {
16
+ return contextMap;
17
+ },
18
+ configContextMap: function() {
19
+ return configContextMap;
20
+ },
21
+ contextSourcesMap: function() {
22
+ return contextSourcesMap;
23
+ },
24
+ sourceHashMap: function() {
25
+ return sourceHashMap;
26
+ },
27
+ NOT_ON_DEMAND: function() {
28
+ return NOT_ON_DEMAND;
29
+ },
30
+ NONE: function() {
31
+ return NONE;
32
+ },
33
+ resolveDebug: function() {
34
+ return resolveDebug;
35
+ }
36
+ });
37
+ const env = typeof process !== "undefined" ? {
8
38
  NODE_ENV: process.env.NODE_ENV,
9
39
  DEBUG: resolveDebug(process.env.DEBUG)
40
+ } : {
41
+ NODE_ENV: "production",
42
+ DEBUG: false
10
43
  };
11
- exports.env = env;
12
44
  const contextMap = new Map();
13
- exports.contextMap = contextMap;
14
45
  const configContextMap = new Map();
15
- exports.configContextMap = configContextMap;
16
46
  const contextSourcesMap = new Map();
17
- exports.contextSourcesMap = contextSourcesMap;
18
47
  const sourceHashMap = new Map();
19
- exports.sourceHashMap = sourceHashMap;
20
- const NOT_ON_DEMAND = new String('*');
21
- exports.NOT_ON_DEMAND = NOT_ON_DEMAND;
48
+ const NOT_ON_DEMAND = new String("*");
49
+ const NONE = Symbol("__NONE__");
22
50
  function resolveDebug(debug) {
23
51
  if (debug === undefined) {
24
52
  return false;
25
53
  }
26
54
  // Environment variables are strings, so convert to boolean
27
- if (debug === 'true' || debug === '1') {
55
+ if (debug === "true" || debug === "1") {
28
56
  return true;
29
57
  }
30
- if (debug === 'false' || debug === '0') {
58
+ if (debug === "false" || debug === "0") {
31
59
  return false;
32
60
  }
33
61
  // Keep the debug convention into account:
@@ -35,17 +63,16 @@ function resolveDebug(debug) {
35
63
  // DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
36
64
  // DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
37
65
  // DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
38
- if (debug === '*') {
66
+ if (debug === "*") {
39
67
  return true;
40
68
  }
41
- let debuggers = debug.split(',').map((d)=>d.split(':')[0]
42
- );
69
+ let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
43
70
  // Ignoring tailwindcss
44
- if (debuggers.includes('-tailwindcss')) {
71
+ if (debuggers.includes("-tailwindcss")) {
45
72
  return false;
46
73
  }
47
74
  // Including tailwindcss
48
- if (debuggers.includes('tailwindcss')) {
75
+ if (debuggers.includes("tailwindcss")) {
49
76
  return true;
50
77
  }
51
78
  return false;
@@ -2,26 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _normalizeScreens = require("../util/normalizeScreens");
7
- var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _normalizeScreens = require("../util/normalizeScreens");
12
+ const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
18
  function _default({ tailwindConfig: { theme } }) {
14
19
  return function(css) {
15
- css.walkAtRules('screen', (atRule)=>{
20
+ css.walkAtRules("screen", (atRule)=>{
16
21
  let screen = atRule.params;
17
- let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
18
- let screenDefinition = screens.find(({ name })=>name === screen
19
- );
22
+ let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
23
+ let screenDefinition = screens.find(({ name })=>name === screen);
20
24
  if (!screenDefinition) {
21
25
  throw atRule.error(`No \`${screen}\` screen found.`);
22
26
  }
23
- atRule.name = 'media';
24
- atRule.params = (0, _buildMediaQuery).default(screenDefinition);
27
+ atRule.name = "media";
28
+ atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
25
29
  });
26
30
  };
27
31
  }
package/lib/plugin.js ADDED
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
6
+ const _lightningcss = /*#__PURE__*/ _interop_require_wildcard(require("lightningcss"));
7
+ const _browserslist = /*#__PURE__*/ _interop_require_default(require("browserslist"));
8
+ const _setupTrackingContext = /*#__PURE__*/ _interop_require_default(require("./lib/setupTrackingContext"));
9
+ const _processTailwindFeatures = /*#__PURE__*/ _interop_require_default(require("./processTailwindFeatures"));
10
+ const _sharedState = require("./lib/sharedState");
11
+ const _findAtConfigPath = require("./lib/findAtConfigPath");
12
+ const _handleImportAtRules = require("./lib/handleImportAtRules");
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ function _getRequireWildcardCache(nodeInterop) {
19
+ if (typeof WeakMap !== "function") return null;
20
+ var cacheBabelInterop = new WeakMap();
21
+ var cacheNodeInterop = new WeakMap();
22
+ return (_getRequireWildcardCache = function(nodeInterop) {
23
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
24
+ })(nodeInterop);
25
+ }
26
+ function _interop_require_wildcard(obj, nodeInterop) {
27
+ if (!nodeInterop && obj && obj.__esModule) {
28
+ return obj;
29
+ }
30
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
31
+ return {
32
+ default: obj
33
+ };
34
+ }
35
+ var cache = _getRequireWildcardCache(nodeInterop);
36
+ if (cache && cache.has(obj)) {
37
+ return cache.get(obj);
38
+ }
39
+ var newObj = {};
40
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
41
+ for(var key in obj){
42
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
43
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
44
+ if (desc && (desc.get || desc.set)) {
45
+ Object.defineProperty(newObj, key, desc);
46
+ } else {
47
+ newObj[key] = obj[key];
48
+ }
49
+ }
50
+ }
51
+ newObj.default = obj;
52
+ if (cache) {
53
+ cache.set(obj, newObj);
54
+ }
55
+ return newObj;
56
+ }
57
+ module.exports = function tailwindcss(configOrPath) {
58
+ return {
59
+ postcssPlugin: "tailwindcss",
60
+ plugins: [
61
+ _sharedState.env.DEBUG && function(root) {
62
+ console.log("\n");
63
+ console.time("JIT TOTAL");
64
+ return root;
65
+ },
66
+ ...(0, _handleImportAtRules.handleImportAtRules)(),
67
+ function(root, result) {
68
+ var _findAtConfigPath1;
69
+ // Use the path for the `@config` directive if it exists, otherwise use the
70
+ // path for the file being processed
71
+ configOrPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : configOrPath;
72
+ let context = (0, _setupTrackingContext.default)(configOrPath);
73
+ if (root.type === "document") {
74
+ let roots = root.nodes.filter((node)=>node.type === "root");
75
+ for (const root of roots){
76
+ if (root.type === "root") {
77
+ (0, _processTailwindFeatures.default)(context)(root, result);
78
+ }
79
+ }
80
+ return;
81
+ }
82
+ (0, _processTailwindFeatures.default)(context)(root, result);
83
+ },
84
+ function lightningCssPlugin(_root, result) {
85
+ var _intermediateResult_map, _intermediateResult_map_toJSON;
86
+ var _result_map;
87
+ let map = (_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : result.opts.map;
88
+ let intermediateResult = result.root.toResult({
89
+ map: map ? {
90
+ inline: true
91
+ } : false
92
+ });
93
+ var _intermediateResult_map_toJSON1;
94
+ let intermediateMap = (_intermediateResult_map_toJSON1 = (_intermediateResult_map = intermediateResult.map) === null || _intermediateResult_map === void 0 ? void 0 : (_intermediateResult_map_toJSON = _intermediateResult_map.toJSON) === null || _intermediateResult_map_toJSON === void 0 ? void 0 : _intermediateResult_map_toJSON.call(_intermediateResult_map)) !== null && _intermediateResult_map_toJSON1 !== void 0 ? _intermediateResult_map_toJSON1 : map;
95
+ try {
96
+ var _browserslist_findConfig;
97
+ var _result_opts_from;
98
+ let resolvedBrowsersListConfig = (_browserslist_findConfig = _browserslist.default.findConfig((_result_opts_from = result.opts.from) !== null && _result_opts_from !== void 0 ? _result_opts_from : process.cwd())) === null || _browserslist_findConfig === void 0 ? void 0 : _browserslist_findConfig.defaults;
99
+ let defaultBrowsersListConfig = require("../package.json").browserslist;
100
+ let browsersListConfig = resolvedBrowsersListConfig !== null && resolvedBrowsersListConfig !== void 0 ? resolvedBrowsersListConfig : defaultBrowsersListConfig;
101
+ let transformed = _lightningcss.default.transform({
102
+ filename: result.opts.from,
103
+ code: Buffer.from(intermediateResult.css),
104
+ minify: false,
105
+ sourceMap: !!intermediateMap,
106
+ targets: _lightningcss.default.browserslistToTargets((0, _browserslist.default)(browsersListConfig)),
107
+ drafts: {
108
+ nesting: true,
109
+ customMedia: true
110
+ },
111
+ nonStandard: {
112
+ deepSelectorCombinator: true
113
+ },
114
+ include: _lightningcss.Features.Nesting,
115
+ exclude: _lightningcss.Features.LogicalProperties
116
+ });
117
+ let code = transformed.code.toString();
118
+ // https://postcss.org/api/#sourcemapoptions
119
+ if (intermediateMap && transformed.map != null) {
120
+ let prev = transformed.map.toString();
121
+ if (typeof intermediateMap === "object") {
122
+ intermediateMap.prev = prev;
123
+ } else {
124
+ code = `${code}\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(prev).toString("base64")} */`;
125
+ }
126
+ }
127
+ result.root = _postcss.default.parse(code, {
128
+ ...result.opts,
129
+ map: intermediateMap
130
+ });
131
+ } catch (err) {
132
+ if (err.source && typeof process !== "undefined" && process.env.JEST_WORKER_ID) {
133
+ let lines = err.source.split("\n");
134
+ err = new Error([
135
+ "Error formatting using Lightning CSS:",
136
+ "",
137
+ ...[
138
+ "```css",
139
+ ...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
140
+ " ".repeat(err.loc.column - 1) + "^-- " + err.toString(),
141
+ ...lines.slice(err.loc.line, err.loc.line + 2),
142
+ "```"
143
+ ]
144
+ ].join("\n"));
145
+ }
146
+ if (Error.captureStackTrace) {
147
+ Error.captureStackTrace(err, lightningCssPlugin);
148
+ }
149
+ throw err;
150
+ }
151
+ },
152
+ _sharedState.env.DEBUG && function(root) {
153
+ console.timeEnd("JIT TOTAL");
154
+ console.log("\n");
155
+ return root;
156
+ }
157
+ ].filter(Boolean)
158
+ };
159
+ };
160
+ module.exports.postcss = true;
@@ -1,6 +1,6 @@
1
1
  # tailwindcss/nesting
2
2
 
3
- This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
3
+ This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
4
4
 
5
5
  Add it to your PostCSS configuration, somewhere before Tailwind itself:
6
6
 
@@ -18,7 +18,7 @@ module.exports = {
18
18
 
19
19
  By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
20
20
 
21
- If you'd rather use [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
21
+ If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
22
22
 
23
23
  ```shell
24
24
  npm install postcss-nesting
@@ -2,16 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = void 0;
6
- var _plugin = require("./plugin");
7
- var _default = Object.assign(function(opts) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _plugin = require("./plugin");
12
+ const _default = Object.assign(function(opts) {
8
13
  return {
9
- postcssPlugin: 'tailwindcss/nesting',
14
+ postcssPlugin: "tailwindcss/nesting",
10
15
  Once (root, { result }) {
11
- return (0, _plugin).nesting(opts)(root, result);
16
+ return (0, _plugin.nesting)(opts)(root, result);
12
17
  }
13
18
  };
14
19
  }, {
15
20
  postcss: true
16
21
  });
17
- exports.default = _default;
@@ -2,47 +2,52 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.nesting = nesting;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _postcssNested = _interopRequireDefault(require("postcss-nested"));
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "nesting", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return nesting;
9
+ }
10
+ });
11
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12
+ const _postcssnested = /*#__PURE__*/ _interop_require_default(require("postcss-nested"));
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
- function nesting(opts = _postcssNested.default) {
18
+ function nesting(opts = _postcssnested.default) {
14
19
  return (root, result)=>{
15
- root.walkAtRules('screen', (rule)=>{
16
- rule.name = 'media';
20
+ root.walkAtRules("screen", (rule)=>{
21
+ rule.name = "media";
17
22
  rule.params = `screen(${rule.params})`;
18
23
  });
19
- root.walkAtRules('apply', (rule)=>{
24
+ root.walkAtRules("apply", (rule)=>{
20
25
  rule.before(_postcss.default.decl({
21
- prop: '__apply',
26
+ prop: "__apply",
22
27
  value: rule.params,
23
28
  source: rule.source
24
29
  }));
25
30
  rule.remove();
26
31
  });
27
32
  let plugin = (()=>{
28
- var ref;
29
- if (typeof opts === 'function' || typeof opts === 'object' && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, 'postcssPlugin'))) {
33
+ var _opts_hasOwnProperty;
34
+ if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
30
35
  return opts;
31
36
  }
32
- if (typeof opts === 'string') {
37
+ if (typeof opts === "string") {
33
38
  return require(opts);
34
39
  }
35
40
  if (Object.keys(opts).length <= 0) {
36
- return _postcssNested.default;
41
+ return _postcssnested.default;
37
42
  }
38
- throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.');
43
+ throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
39
44
  })();
40
- (0, _postcss).default([
45
+ (0, _postcss.default)([
41
46
  plugin
42
47
  ]).process(root, result.opts).sync();
43
- root.walkDecls('__apply', (decl)=>{
48
+ root.walkDecls("__apply", (decl)=>{
44
49
  decl.before(_postcss.default.atRule({
45
- name: 'apply',
50
+ name: "apply",
46
51
  params: decl.value,
47
52
  source: decl.source
48
53
  }));
@@ -62,13 +67,12 @@ function nesting(opts = _postcssNested.default) {
62
67
  *
63
68
  * @param {import('postcss').Node} node
64
69
  */ function markDirty(node) {
65
- if (!('markDirty' in node)) {
70
+ if (!("markDirty" in node)) {
66
71
  return;
67
72
  }
68
73
  // Traverse the tree down to the leaf nodes
69
74
  if (node.nodes) {
70
- node.nodes.forEach((n)=>markDirty(n)
71
- );
75
+ node.nodes.forEach((n)=>markDirty(n));
72
76
  }
73
77
  // If it's a leaf node mark it as dirty
74
78
  // We do this here because marking a node as dirty