tailwindcss 0.0.0-insiders.bfdf3a7 → 0.0.0-insiders.c02842d

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 (67) hide show
  1. package/lib/cli/build/index.js +3 -2
  2. package/lib/cli/build/plugin.js +23 -18
  3. package/lib/cli/build/watching.js +4 -2
  4. package/lib/cli/index.js +12 -21
  5. package/lib/cli/init/index.js +21 -6
  6. package/lib/corePluginList.js +2 -0
  7. package/lib/corePlugins.js +35 -19
  8. package/lib/lib/expandApplyAtRules.js +2 -1
  9. package/lib/lib/generateRules.js +2 -1
  10. package/lib/lib/getModuleDependencies.js +79 -33
  11. package/lib/lib/load-config.js +36 -0
  12. package/lib/lib/setupTrackingContext.js +4 -4
  13. package/lib/oxide/cli/build/index.js +3 -2
  14. package/lib/oxide/cli/build/plugin.js +22 -17
  15. package/lib/oxide/cli/build/watching.js +1 -1
  16. package/lib/oxide/cli/index.js +10 -16
  17. package/lib/oxide/cli/init/index.js +19 -4
  18. package/lib/public/colors.js +44 -22
  19. package/lib/public/default-config.js +2 -2
  20. package/lib/public/default-theme.js +2 -2
  21. package/lib/public/load-config.js +10 -0
  22. package/lib/util/applyImportantSelector.js +22 -0
  23. package/lib/util/getAllConfigs.js +2 -2
  24. package/lib/util/normalizeConfig.js +14 -0
  25. package/lib/util/resolveConfigPath.js +19 -7
  26. package/loadConfig.d.ts +4 -0
  27. package/loadConfig.js +2 -0
  28. package/package.json +5 -4
  29. package/src/cli/build/index.js +3 -6
  30. package/src/cli/build/plugin.js +23 -22
  31. package/src/cli/build/watching.js +4 -2
  32. package/src/cli/index.js +8 -26
  33. package/src/cli/init/index.js +37 -8
  34. package/src/corePluginList.js +1 -1
  35. package/src/corePlugins.js +29 -20
  36. package/src/lib/expandApplyAtRules.js +2 -1
  37. package/src/lib/generateRules.js +2 -1
  38. package/src/lib/getModuleDependencies.js +70 -30
  39. package/src/lib/load-config.ts +27 -0
  40. package/src/lib/setupTrackingContext.js +4 -4
  41. package/src/oxide/cli/build/index.ts +3 -6
  42. package/src/oxide/cli/build/plugin.ts +23 -21
  43. package/src/oxide/cli/build/watching.ts +1 -1
  44. package/src/oxide/cli/index.ts +7 -15
  45. package/src/oxide/cli/init/index.ts +34 -7
  46. package/src/public/colors.js +22 -0
  47. package/src/public/default-config.js +1 -1
  48. package/src/public/default-theme.js +2 -2
  49. package/src/public/load-config.js +2 -0
  50. package/src/util/applyImportantSelector.js +19 -0
  51. package/src/util/getAllConfigs.js +2 -2
  52. package/src/util/normalizeConfig.js +17 -0
  53. package/src/util/resolveConfigPath.js +12 -1
  54. package/stubs/.gitignore +1 -0
  55. package/stubs/.prettierrc.json +6 -0
  56. package/stubs/{defaultConfig.stub.js → config.full.js} +11 -1
  57. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  58. package/stubs/postcss.config.js +6 -0
  59. package/stubs/tailwind.config.cjs +2 -0
  60. package/stubs/tailwind.config.js +2 -0
  61. package/stubs/tailwind.config.ts +3 -0
  62. package/types/generated/colors.d.ts +22 -0
  63. package/types/generated/corePluginList.d.ts +1 -1
  64. package/types/generated/default-theme.d.ts +2 -0
  65. package/lib/constants.js +0 -44
  66. package/src/constants.js +0 -17
  67. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -9,13 +9,14 @@ Object.defineProperty(exports, "build", {
9
9
  });
10
10
  const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
11
  const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
12
+ const _resolveConfigPathJs = require("../../util/resolveConfigPath.js");
12
13
  const _pluginJs = require("./plugin.js");
13
14
  function _interopRequireDefault(obj) {
14
15
  return obj && obj.__esModule ? obj : {
15
16
  default: obj
16
17
  };
17
18
  }
18
- async function build(args, configs) {
19
+ async function build(args) {
19
20
  let input = args["--input"];
20
21
  let shouldWatch = args["--watch"];
21
22
  // TODO: Deprecate this in future versions
@@ -32,7 +33,7 @@ async function build(args, configs) {
32
33
  process.exit(9);
33
34
  }
34
35
  // TODO: Reference the @config path here if exists
35
- let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
36
+ let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)();
36
37
  let processor = await (0, _pluginJs.createProcessor)(args, configPath);
37
38
  if (shouldWatch) {
38
39
  // Abort the watcher if stdin is closed to avoid zombie processes
@@ -20,12 +20,13 @@ const _deps = require("./deps");
20
20
  const _utils = require("./utils");
21
21
  const _sharedState = require("../../lib/sharedState");
22
22
  const _resolveConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../../../resolveConfig.js"));
23
- const _getModuleDependenciesJs = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies.js"));
24
23
  const _contentJs = require("../../lib/content.js");
25
24
  const _watchingJs = require("./watching.js");
26
25
  const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
27
26
  const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
28
27
  const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
28
+ const _loadConfig = require("../../lib/load-config");
29
+ const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies"));
29
30
  function _interopRequireDefault(obj) {
30
31
  return obj && obj.__esModule ? obj : {
31
32
  default: obj
@@ -109,7 +110,7 @@ let state = {
109
110
  /** @type {any} */ context: null,
110
111
  /** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
111
112
  /** @type {{content: string, extension: string}[]} */ changedContent: [],
112
- configDependencies: new Set(),
113
+ /** @type {ReturnType<typeof load> | null} */ configBag: null,
113
114
  contextDependencies: new Set(),
114
115
  /** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
115
116
  refreshContentPaths () {
@@ -127,32 +128,35 @@ let state = {
127
128
  },
128
129
  loadConfig (configPath, content) {
129
130
  if (this.watcher && configPath) {
130
- this.refreshConfigDependencies(configPath);
131
+ this.refreshConfigDependencies();
131
132
  }
132
- let config = configPath ? require(configPath) : {};
133
+ let config = (0, _loadConfig.loadConfig)(configPath);
134
+ let dependencies = (0, _getModuleDependencies.default)(configPath);
135
+ this.configBag = {
136
+ config,
137
+ dependencies,
138
+ dispose () {
139
+ for (let file of dependencies){
140
+ delete require.cache[require.resolve(file)];
141
+ }
142
+ }
143
+ };
133
144
  // @ts-ignore
134
- config = (0, _resolveConfigJs.default)(config, {
145
+ this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
135
146
  content: {
136
147
  files: []
137
148
  }
138
149
  });
139
150
  // Override content files if `--content` has been passed explicitly
140
151
  if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
141
- config.content.files = content;
152
+ this.configBag.config.content.files = content;
142
153
  }
143
- return config;
154
+ return this.configBag.config;
144
155
  },
145
- refreshConfigDependencies (configPath) {
156
+ refreshConfigDependencies () {
157
+ var _this_configBag;
146
158
  _sharedState.env.DEBUG && console.time("Module dependencies");
147
- for (let file of this.configDependencies){
148
- delete require.cache[require.resolve(file)];
149
- }
150
- if (configPath) {
151
- let deps = (0, _getModuleDependenciesJs.default)(configPath).map(({ file })=>file);
152
- for (let dependency of deps){
153
- this.configDependencies.add(dependency);
154
- }
155
- }
159
+ (_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
156
160
  _sharedState.env.DEBUG && console.timeEnd("Module dependencies");
157
161
  },
158
162
  readContentPaths () {
@@ -353,7 +357,8 @@ async function createProcessor(args, cliConfigPath) {
353
357
  * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
354
358
  */ async rebuild (changes) {
355
359
  let needsNewContext = changes.some((change)=>{
356
- return state.configDependencies.has(change.file) || state.contextDependencies.has(change.file);
360
+ var _state_configBag;
361
+ return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
357
362
  });
358
363
  if (needsNewContext) {
359
364
  state.context = null;
@@ -64,7 +64,9 @@ function createWatcher(args, { state , rebuild }) {
64
64
  // Clear all pending rebuilds for the about-to-be-built files
65
65
  changes.forEach((change)=>pendingRebuilds.delete(change.file));
66
66
  // Resolve the promise even when the rebuild fails
67
- return rebuild(changes).then(()=>{}, ()=>{});
67
+ return rebuild(changes).then(()=>{}, (e)=>{
68
+ console.error(e.toString());
69
+ });
68
70
  }
69
71
  /**
70
72
  *
@@ -171,7 +173,7 @@ function createWatcher(args, { state , rebuild }) {
171
173
  fswatcher: watcher,
172
174
  refreshWatchedFiles () {
173
175
  watcher.add(Array.from(state.contextDependencies));
174
- watcher.add(Array.from(state.configDependencies));
176
+ watcher.add(Array.from(state.configBag.dependencies));
175
177
  watcher.add(state.contentPatterns.all);
176
178
  }
177
179
  };
package/lib/cli/index.js CHANGED
@@ -14,23 +14,6 @@ function _interopRequireDefault(obj) {
14
14
  default: obj
15
15
  };
16
16
  }
17
- function isESM() {
18
- const pkgPath = _path.default.resolve("./package.json");
19
- try {
20
- let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
21
- return pkg.type && pkg.type === "module";
22
- } catch (err) {
23
- return false;
24
- }
25
- }
26
- let configs = isESM() ? {
27
- tailwind: "tailwind.config.cjs",
28
- postcss: "postcss.config.cjs"
29
- } : {
30
- tailwind: "tailwind.config.js",
31
- postcss: "postcss.config.js"
32
- };
33
- // ---
34
17
  function oneOf(...options) {
35
18
  return Object.assign((value = true)=>{
36
19
  for (let option of options){
@@ -48,13 +31,21 @@ let commands = {
48
31
  init: {
49
32
  run: _init.init,
50
33
  args: {
51
- "--full": {
34
+ "--esm": {
52
35
  type: Boolean,
53
- description: `Initialize a full \`${configs.tailwind}\` file`
36
+ description: `Initialize configuration file as ESM`
37
+ },
38
+ "--ts": {
39
+ type: Boolean,
40
+ description: `Initialize configuration file as TypeScript`
54
41
  },
55
42
  "--postcss": {
56
43
  type: Boolean,
57
- description: `Initialize a \`${configs.postcss}\` file`
44
+ description: `Initialize a \`postcss.config.js\` file`
45
+ },
46
+ "--full": {
47
+ type: Boolean,
48
+ description: `Include the default values for all options in the generated configuration file`
58
49
  },
59
50
  "-f": "--full",
60
51
  "-p": "--postcss"
@@ -236,4 +227,4 @@ if (args["--help"]) {
236
227
  });
237
228
  process.exit(0);
238
229
  }
239
- run(args, configs);
230
+ run(args);
@@ -14,25 +14,40 @@ function _interopRequireDefault(obj) {
14
14
  default: obj
15
15
  };
16
16
  }
17
- function init(args, configs) {
17
+ function isESM() {
18
+ const pkgPath = _path.default.resolve("./package.json");
19
+ try {
20
+ let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
21
+ return pkg.type && pkg.type === "module";
22
+ } catch (err) {
23
+ return false;
24
+ }
25
+ }
26
+ function init(args) {
18
27
  let messages = [];
28
+ let isProjectESM = args["--ts"] || args["--esm"] || isESM();
29
+ let syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs";
30
+ let extension = args["--ts"] ? "ts" : "js";
19
31
  var _args___;
20
- let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./${configs.tailwind}`);
32
+ let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
21
33
  if (_fs.default.existsSync(tailwindConfigLocation)) {
22
34
  messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
23
35
  } else {
24
- let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../../../stubs/simpleConfig.stub.js"), "utf8");
36
+ let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../stubs/config.simple.js"), "utf8");
37
+ let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`), "utf8");
25
38
  // Change colors import
26
- stubFile = stubFile.replace("../colors", "tailwindcss/colors");
39
+ stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
40
+ // Replace contents of {ts,js,cjs} file with the stub {simple,full}.
41
+ stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n";
27
42
  _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
28
43
  messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
29
44
  }
30
45
  if (args["--postcss"]) {
31
- let postcssConfigLocation = _path.default.resolve(`./${configs.postcss}`);
46
+ let postcssConfigLocation = _path.default.resolve("./postcss.config.js");
32
47
  if (_fs.default.existsSync(postcssConfigLocation)) {
33
48
  messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
34
49
  } else {
35
- let stubFile1 = _fs.default.readFileSync(_path.default.resolve(__dirname, "../../../stubs/defaultPostCssConfig.stub.js"), "utf8");
50
+ let stubFile1 = _fs.default.readFileSync(isProjectESM ? _path.default.resolve(__dirname, "../../../stubs/postcss.config.js") : _path.default.resolve(__dirname, "../../../stubs/postcss.config.cjs"), "utf8");
36
51
  _fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8");
37
52
  messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
38
53
  }
@@ -27,6 +27,7 @@ const _default = [
27
27
  "clear",
28
28
  "margin",
29
29
  "boxSizing",
30
+ "lineClamp",
30
31
  "display",
31
32
  "aspectRatio",
32
33
  "height",
@@ -61,6 +62,7 @@ const _default = [
61
62
  "scrollPadding",
62
63
  "listStylePosition",
63
64
  "listStyleType",
65
+ "listStyleImage",
64
66
  "appearance",
65
67
  "columns",
66
68
  "breakBefore",
@@ -257,20 +257,8 @@ let variantPlugins = {
257
257
  }
258
258
  },
259
259
  directionVariants: ({ addVariant })=>{
260
- addVariant("ltr", ()=>{
261
- _log.default.warn("rtl-experimental", [
262
- "The RTL features in Tailwind CSS are currently in preview.",
263
- "Preview features are not covered by semver, and may be improved in breaking ways at any time."
264
- ]);
265
- return '[dir="ltr"] &';
266
- });
267
- addVariant("rtl", ()=>{
268
- _log.default.warn("rtl-experimental", [
269
- "The RTL features in Tailwind CSS are currently in preview.",
270
- "Preview features are not covered by semver, and may be improved in breaking ways at any time."
271
- ]);
272
- return '[dir="rtl"] &';
273
- });
260
+ addVariant("ltr", ':is([dir="ltr"] &)');
261
+ addVariant("rtl", ':is([dir="rtl"] &)');
274
262
  },
275
263
  reducedMotionVariants: ({ addVariant })=>{
276
264
  addVariant("motion-safe", "@media (prefers-reduced-motion: no-preference)");
@@ -287,7 +275,7 @@ let variantPlugins = {
287
275
  ]);
288
276
  }
289
277
  if (mode === "class") {
290
- addVariant("dark", `${className} &`);
278
+ addVariant("dark", `:is(${className} &)`);
291
279
  } else if (mode === "media") {
292
280
  addVariant("dark", "@media (prefers-color-scheme: dark)");
293
281
  }
@@ -646,10 +634,7 @@ let corePlugins = {
646
634
  [
647
635
  "inset",
648
636
  [
649
- "top",
650
- "right",
651
- "bottom",
652
- "left"
637
+ "inset"
653
638
  ]
654
639
  ],
655
640
  [
@@ -883,6 +868,26 @@ let corePlugins = {
883
868
  }
884
869
  });
885
870
  },
871
+ lineClamp: ({ matchUtilities , addUtilities , theme })=>{
872
+ matchUtilities({
873
+ "line-clamp": (value)=>({
874
+ overflow: "hidden",
875
+ display: "-webkit-box",
876
+ "-webkit-box-orient": "vertical",
877
+ "-webkit-line-clamp": `${value}`
878
+ })
879
+ }, {
880
+ values: theme("lineClamp")
881
+ });
882
+ addUtilities({
883
+ ".line-clamp-none": {
884
+ overflow: "visible",
885
+ display: "block",
886
+ "-webkit-box-orient": "horizontal",
887
+ "-webkit-line-clamp": "none"
888
+ }
889
+ });
890
+ },
886
891
  display: ({ addUtilities })=>{
887
892
  addUtilities({
888
893
  ".block": {
@@ -1589,6 +1594,14 @@ let corePlugins = {
1589
1594
  ]
1590
1595
  ]
1591
1596
  ]),
1597
+ listStyleImage: (0, _createUtilityPlugin.default)("listStyleImage", [
1598
+ [
1599
+ "list-image",
1600
+ [
1601
+ "listStyleImage"
1602
+ ]
1603
+ ]
1604
+ ]),
1592
1605
  appearance: ({ addUtilities })=>{
1593
1606
  addUtilities({
1594
1607
  ".appearance-none": {
@@ -2271,6 +2284,9 @@ let corePlugins = {
2271
2284
  },
2272
2285
  ".whitespace-pre-wrap": {
2273
2286
  "white-space": "pre-wrap"
2287
+ },
2288
+ ".whitespace-break-spaces": {
2289
+ "white-space": "break-spaces"
2274
2290
  }
2275
2291
  });
2276
2292
  },
@@ -10,6 +10,7 @@ const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
10
10
  const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
11
11
  const _generateRules = require("./generateRules");
12
12
  const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
13
+ const _applyImportantSelector = require("../util/applyImportantSelector");
13
14
  function _interopRequireDefault(obj) {
14
15
  return obj && obj.__esModule ? obj : {
15
16
  default: obj
@@ -481,7 +482,7 @@ function processApply(root, context, localCache) {
481
482
  rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate1);
482
483
  // And then re-add it if it was removed
483
484
  if (importantSelector && parentSelector !== parent.selector) {
484
- rule.selector = `${importantSelector} ${rule.selector}`;
485
+ rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
485
486
  }
486
487
  rule.walkDecls((d)=>{
487
488
  d.important = meta.important || important1;
@@ -28,6 +28,7 @@ const _setupContextUtils = require("./setupContextUtils");
28
28
  const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
29
29
  const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
30
30
  const _featureFlags = require("../featureFlags");
31
+ const _applyImportantSelector = require("../util/applyImportantSelector");
31
32
  function _interopRequireDefault(obj) {
32
33
  return obj && obj.__esModule ? obj : {
33
34
  default: obj
@@ -823,7 +824,7 @@ function getImportantStrategy(important) {
823
824
  return;
824
825
  }
825
826
  rule.selectors = rule.selectors.map((selector)=>{
826
- return `${important} ${selector}`;
827
+ return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
827
828
  });
828
829
  };
829
830
  }
@@ -8,44 +8,90 @@ Object.defineProperty(exports, "default", {
8
8
  });
9
9
  const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
10
  const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
- const _resolve = /*#__PURE__*/ _interopRequireDefault(require("resolve"));
12
- const _detective = /*#__PURE__*/ _interopRequireDefault(require("detective"));
13
11
  function _interopRequireDefault(obj) {
14
12
  return obj && obj.__esModule ? obj : {
15
13
  default: obj
16
14
  };
17
15
  }
18
- function createModule(file) {
19
- const source = _fs.default.readFileSync(file, "utf-8");
20
- const requires = (0, _detective.default)(source);
21
- return {
22
- file,
23
- requires
24
- };
16
+ let jsExtensions = [
17
+ ".js",
18
+ ".cjs",
19
+ ".mjs"
20
+ ];
21
+ // Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
22
+ // `b.ts` before `b.js`
23
+ //
24
+ // E.g.:
25
+ //
26
+ // a.ts
27
+ // b // .ts
28
+ // c // .ts
29
+ // a.js
30
+ // b // .js or .ts
31
+ let jsResolutionOrder = [
32
+ "",
33
+ ".js",
34
+ ".cjs",
35
+ ".mjs",
36
+ ".ts",
37
+ ".cts",
38
+ ".mts",
39
+ ".jsx",
40
+ ".tsx"
41
+ ];
42
+ let tsResolutionOrder = [
43
+ "",
44
+ ".ts",
45
+ ".cts",
46
+ ".mts",
47
+ ".tsx",
48
+ ".js",
49
+ ".cjs",
50
+ ".mjs",
51
+ ".jsx"
52
+ ];
53
+ function resolveWithExtension(file, extensions) {
54
+ // Try to find `./a.ts`, `./a.ts`, ... from `./a`
55
+ for (let ext of extensions){
56
+ let full = `${file}${ext}`;
57
+ if (_fs.default.existsSync(full) && _fs.default.statSync(full).isFile()) {
58
+ return full;
59
+ }
60
+ }
61
+ // Try to find `./a/index.js` from `./a`
62
+ for (let ext1 of extensions){
63
+ let full1 = `${file}/index${ext1}`;
64
+ if (_fs.default.existsSync(full1)) {
65
+ return full1;
66
+ }
67
+ }
68
+ return null;
25
69
  }
26
- function getModuleDependencies(entryFile) {
27
- const rootModule = createModule(entryFile);
28
- const modules = [
29
- rootModule
30
- ];
31
- // Iterate over the modules, even when new
32
- // ones are being added
33
- for (const mdl of modules){
34
- mdl.requires.filter((dep)=>{
35
- // Only track local modules, not node_modules
36
- return dep.startsWith("./") || dep.startsWith("../");
37
- }).forEach((dep)=>{
38
- try {
39
- const basedir = _path.default.dirname(mdl.file);
40
- const depPath = _resolve.default.sync(dep, {
41
- basedir
42
- });
43
- const depModule = createModule(depPath);
44
- modules.push(depModule);
45
- } catch (_err) {
46
- // eslint-disable-next-line no-empty
47
- }
48
- });
70
+ function* _getModuleDependencies(filename, base, seen, ext = _path.default.extname(filename)) {
71
+ // Try to find the file
72
+ let absoluteFile = resolveWithExtension(_path.default.resolve(base, filename), jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder);
73
+ if (absoluteFile === null) return; // File doesn't exist
74
+ // Prevent infinite loops when there are circular dependencies
75
+ if (seen.has(absoluteFile)) return; // Already seen
76
+ seen.add(absoluteFile);
77
+ // Mark the file as a dependency
78
+ yield absoluteFile;
79
+ // Resolve new base for new imports/requires
80
+ base = _path.default.dirname(absoluteFile);
81
+ ext = _path.default.extname(absoluteFile);
82
+ let contents = _fs.default.readFileSync(absoluteFile, "utf-8");
83
+ // Find imports/requires
84
+ for (let match of [
85
+ ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
86
+ ...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
87
+ ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
88
+ ]){
89
+ // Bail out if it's not a relative file
90
+ if (!match[1].startsWith(".")) continue;
91
+ yield* _getModuleDependencies(match[1], base, seen, ext);
49
92
  }
50
- return modules;
93
+ }
94
+ function getModuleDependencies(absoluteFilePath) {
95
+ if (absoluteFilePath === null) return new Set();
96
+ return new Set(_getModuleDependencies(absoluteFilePath, _path.default.dirname(absoluteFilePath), new Set()));
51
97
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "loadConfig", {
6
+ enumerable: true,
7
+ get: ()=>loadConfig
8
+ });
9
+ const _jiti = /*#__PURE__*/ _interopRequireDefault(require("jiti"));
10
+ const _sucrase = require("sucrase");
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ let jiti = null;
17
+ function lazyJiti() {
18
+ return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, {
19
+ interopDefault: true,
20
+ transform: (opts)=>{
21
+ return (0, _sucrase.transform)(opts.source, {
22
+ transforms: [
23
+ "typescript",
24
+ "imports"
25
+ ]
26
+ });
27
+ }
28
+ });
29
+ }
30
+ function loadConfig(path) {
31
+ try {
32
+ return path ? require(path) : {};
33
+ } catch {
34
+ return lazyJiti()(path);
35
+ }
36
+ }
@@ -14,13 +14,14 @@ Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
14
14
  const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
15
15
  const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
16
16
  const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
17
- const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
18
17
  const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
19
18
  const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
20
19
  const _setupContextUtils = require("./setupContextUtils");
21
20
  const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
22
21
  const _validateConfigJs = require("../util/validateConfig.js");
23
22
  const _contentJs = require("./content.js");
23
+ const _loadConfig = require("../lib/load-config");
24
+ const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("./getModuleDependencies"));
24
25
  function _interopRequireDefault(obj) {
25
26
  return obj && obj.__esModule ? obj : {
26
27
  default: obj
@@ -42,7 +43,7 @@ function getTailwindConfig(configOrPath) {
42
43
  let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
43
44
  if (userConfigPath !== null) {
44
45
  let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
45
- let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map((dep)=>dep.file);
46
+ let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
46
47
  let modified = false;
47
48
  let newModified = new Map();
48
49
  for (let file of newDeps){
@@ -65,8 +66,7 @@ function getTailwindConfig(configOrPath) {
65
66
  for (let file1 of newDeps){
66
67
  delete require.cache[file1];
67
68
  }
68
- let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
69
- newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
69
+ let newConfig = (0, _validateConfigJs.validateConfig)((0, _resolveConfig.default)((0, _loadConfig.loadConfig)(userConfigPath)));
70
70
  let newHash = (0, _hashConfig.default)(newConfig);
71
71
  configPathCache.set(userConfigPath, [
72
72
  newConfig,
@@ -8,13 +8,14 @@ Object.defineProperty(exports, "build", {
8
8
  });
9
9
  const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
10
  const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
+ const _resolveConfigPath = require("../../../util/resolveConfigPath");
11
12
  const _plugin = require("./plugin");
12
13
  function _interopRequireDefault(obj) {
13
14
  return obj && obj.__esModule ? obj : {
14
15
  default: obj
15
16
  };
16
17
  }
17
- async function build(args, configs) {
18
+ async function build(args) {
18
19
  let input = args["--input"];
19
20
  let shouldWatch = args["--watch"];
20
21
  // TODO: Deprecate this in future versions
@@ -31,7 +32,7 @@ async function build(args, configs) {
31
32
  process.exit(9);
32
33
  }
33
34
  // TODO: Reference the @config path here if exists
34
- let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
35
+ let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPath.resolveDefaultConfigPath)();
35
36
  let processor = await (0, _plugin.createProcessor)(args, configPath);
36
37
  if (shouldWatch) {
37
38
  // Abort the watcher if stdin is closed to avoid zombie processes