@modern-js/plugin-tailwindcss 2.64.0 → 2.64.2

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.
package/dist/cjs/cli.js CHANGED
@@ -32,12 +32,10 @@ __export(cli_exports, {
32
32
  tailwindcssPlugin: () => tailwindcssPlugin
33
33
  });
34
34
  module.exports = __toCommonJS(cli_exports);
35
- var import_path = __toESM(require("path"));
36
- var import_utils = require("@modern-js/utils");
37
35
  var import_config = require("./config");
38
36
  var import_cli = require("./design-token/cli");
39
37
  var import_macro = require("./macro");
40
- var import_utils2 = require("./utils");
38
+ var import_utils = require("./utils");
41
39
  const tailwindcssPlugin = ({ pluginName } = {
42
40
  pluginName: "@modern-js/plugin-tailwindcss"
43
41
  }) => ({
@@ -50,25 +48,16 @@ const tailwindcssPlugin = ({ pluginName } = {
50
48
  ],
51
49
  setup: async (api) => {
52
50
  const { appDirectory, internalDirectory } = api.useAppContext();
53
- let internalTwConfigPath = "";
54
51
  const haveTwinMacro = await (0, import_macro.checkTwinMacroExist)(appDirectory);
55
- const tailwindPath = (0, import_utils2.getTailwindPath)(appDirectory);
56
- const tailwindVersion = (0, import_utils2.getTailwindVersion)(appDirectory);
52
+ const tailwindPath = (0, import_utils.getTailwindPath)(appDirectory);
53
+ const tailwindVersion = (0, import_utils.getTailwindVersion)(appDirectory);
57
54
  const { content: userTailwindConfig, path: userTailwindConfigPath } = await (0, import_config.loadConfigFile)(appDirectory);
58
55
  return {
59
56
  prepare() {
60
57
  if (haveTwinMacro) {
61
58
  const twinMajorVersion = (0, import_macro.getTwinMacroMajorVersion)(appDirectory);
62
- const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
63
- if (useConfigPath) {
64
- internalTwConfigPath = (0, import_macro.getRandomTwConfigFileName)(internalDirectory);
65
- const globPattern = (0, import_utils.slash)(import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR, "*.cjs"));
66
- const files = import_utils.globby.sync(globPattern, {
67
- absolute: true
68
- });
69
- if (files.length > 0) {
70
- import_utils.fs.writeFileSync(internalTwConfigPath, (0, import_macro.template)(files[files.length - 1]), "utf-8");
71
- }
59
+ if (twinMajorVersion && twinMajorVersion < 3) {
60
+ console.warn("Your twin.macro version is below 3.0.0. Please upgrade to the latest version to avoid potential issues.");
72
61
  }
73
62
  }
74
63
  },
@@ -118,7 +107,7 @@ const tailwindcssPlugin = ({ pluginName } = {
118
107
  {
119
108
  twin: {
120
109
  preset: supportCssInJsLibrary,
121
- config: internalTwConfigPath || tailwindConfig
110
+ config: tailwindConfig
122
111
  }
123
112
  }
124
113
  ]
package/dist/cjs/macro.js CHANGED
@@ -29,33 +29,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var macro_exports = {};
30
30
  __export(macro_exports, {
31
31
  checkTwinMacroExist: () => checkTwinMacroExist,
32
- getRandomTwConfigFileName: () => getRandomTwConfigFileName,
33
- getTwinMacroMajorVersion: () => getTwinMacroMajorVersion,
34
- template: () => template
32
+ getTwinMacroMajorVersion: () => getTwinMacroMajorVersion
35
33
  });
36
34
  module.exports = __toCommonJS(macro_exports);
37
35
  var import_path = __toESM(require("path"));
38
36
  var import_utils = require("@modern-js/utils");
39
- const template = (configPath) => `
40
- function _interopRequireDefault(obj) {
41
- return obj && obj.__esModule ? obj : { default: obj };
42
- }
43
- const modernConfig = _interopRequireDefault(require('${configPath}')).default;
44
-
45
- const theme =
46
- modernConfig && modernConfig.source && modernConfig.source.designSystem
47
- ? modernConfig.source.designSystem
48
- : {};
49
- const tailwindcss =
50
- modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss
51
- ? modernConfig.tools.tailwindcss
52
- : {};
53
-
54
- module.exports = {
55
- theme,
56
- ...tailwindcss,
57
- };
58
- `;
59
37
  const TWIN_MACRO_NAME = "twin.macro";
60
38
  const checkTwinMacroExist = async (appDirectory) => {
61
39
  const packageJson = await import_utils.fs.readJSON(import_path.default.join(appDirectory, "package.json"), {
@@ -76,13 +54,8 @@ const getTwinMacroMajorVersion = (appDirectory) => {
76
54
  return null;
77
55
  }
78
56
  };
79
- const getRandomTwConfigFileName = (internalDirectory) => {
80
- return (0, import_utils.slash)(import_path.default.join(internalDirectory, `tailwind.config.${Date.now()}.${(0, import_utils.nanoid)()}.js`));
81
- };
82
57
  // Annotate the CommonJS export names for ESM import in node:
83
58
  0 && (module.exports = {
84
59
  checkTwinMacroExist,
85
- getRandomTwConfigFileName,
86
- getTwinMacroMajorVersion,
87
- template
60
+ getTwinMacroMajorVersion
88
61
  });
package/dist/esm/cli.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import path from "path";
4
- import { fs, CONFIG_CACHE_DIR, globby, slash } from "@modern-js/utils";
5
3
  import { getTailwindConfig, loadConfigFile } from "./config";
6
4
  import { designTokenPlugin } from "./design-token/cli";
7
- import { checkTwinMacroExist, getRandomTwConfigFileName, getTwinMacroMajorVersion, template } from "./macro";
5
+ import { checkTwinMacroExist, getTwinMacroMajorVersion } from "./macro";
8
6
  import { getTailwindPath, getTailwindVersion } from "./utils";
9
7
  var tailwindcssPlugin = function() {
10
8
  var pluginName = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
@@ -20,12 +18,11 @@ var tailwindcssPlugin = function() {
20
18
  ],
21
19
  setup: function() {
22
20
  var _ref = _async_to_generator(function(api) {
23
- var _api_useAppContext, appDirectory, internalDirectory, internalTwConfigPath, haveTwinMacro, tailwindPath, tailwindVersion, _ref2, userTailwindConfig, userTailwindConfigPath;
21
+ var _api_useAppContext, appDirectory, internalDirectory, haveTwinMacro, tailwindPath, tailwindVersion, _ref2, userTailwindConfig, userTailwindConfigPath;
24
22
  return _ts_generator(this, function(_state) {
25
23
  switch (_state.label) {
26
24
  case 0:
27
25
  _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, internalDirectory = _api_useAppContext.internalDirectory;
28
- internalTwConfigPath = "";
29
26
  return [
30
27
  4,
31
28
  checkTwinMacroExist(appDirectory)
@@ -46,16 +43,8 @@ var tailwindcssPlugin = function() {
46
43
  prepare: function prepare() {
47
44
  if (haveTwinMacro) {
48
45
  var twinMajorVersion = getTwinMacroMajorVersion(appDirectory);
49
- var useConfigPath = twinMajorVersion && twinMajorVersion < 3;
50
- if (useConfigPath) {
51
- internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
52
- var globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs"));
53
- var files = globby.sync(globPattern, {
54
- absolute: true
55
- });
56
- if (files.length > 0) {
57
- fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), "utf-8");
58
- }
46
+ if (twinMajorVersion && twinMajorVersion < 3) {
47
+ console.warn("Your twin.macro version is below 3.0.0. Please upgrade to the latest version to avoid potential issues.");
59
48
  }
60
49
  }
61
50
  },
@@ -106,7 +95,7 @@ var tailwindcssPlugin = function() {
106
95
  {
107
96
  twin: {
108
97
  preset: supportCssInJsLibrary,
109
- config: internalTwConfigPath || tailwindConfig
98
+ config: tailwindConfig
110
99
  }
111
100
  }
112
101
  ]
package/dist/esm/macro.js CHANGED
@@ -2,10 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _type_of } from "@swc/helpers/_/_type_of";
3
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
4
  import path from "path";
5
- import { fs, nanoid, slash } from "@modern-js/utils";
6
- var template = function(configPath) {
7
- return "\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nconst modernConfig = _interopRequireDefault(require('".concat(configPath, "')).default;\n\nconst theme =\n modernConfig && modernConfig.source && modernConfig.source.designSystem\n ? modernConfig.source.designSystem\n : {};\nconst tailwindcss =\n modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss\n ? modernConfig.tools.tailwindcss\n : {};\n\nmodule.exports = {\n theme,\n ...tailwindcss,\n};\n");
8
- };
5
+ import { fs } from "@modern-js/utils";
9
6
  var TWIN_MACRO_NAME = "twin.macro";
10
7
  var checkTwinMacroExist = function() {
11
8
  var _ref = _async_to_generator(function(appDirectory) {
@@ -45,12 +42,7 @@ var getTwinMacroMajorVersion = function(appDirectory) {
45
42
  return null;
46
43
  }
47
44
  };
48
- var getRandomTwConfigFileName = function(internalDirectory) {
49
- return slash(path.join(internalDirectory, "tailwind.config.".concat(Date.now(), ".").concat(nanoid(), ".js")));
50
- };
51
45
  export {
52
46
  checkTwinMacroExist,
53
- getRandomTwConfigFileName,
54
- getTwinMacroMajorVersion,
55
- template
47
+ getTwinMacroMajorVersion
56
48
  };
@@ -1,8 +1,6 @@
1
- import path from "path";
2
- import { fs, CONFIG_CACHE_DIR, globby, slash } from "@modern-js/utils";
3
1
  import { getTailwindConfig, loadConfigFile } from "./config";
4
2
  import { designTokenPlugin } from "./design-token/cli";
5
- import { checkTwinMacroExist, getRandomTwConfigFileName, getTwinMacroMajorVersion, template } from "./macro";
3
+ import { checkTwinMacroExist, getTwinMacroMajorVersion } from "./macro";
6
4
  import { getTailwindPath, getTailwindVersion } from "./utils";
7
5
  const tailwindcssPlugin = ({ pluginName } = {
8
6
  pluginName: "@modern-js/plugin-tailwindcss"
@@ -16,7 +14,6 @@ const tailwindcssPlugin = ({ pluginName } = {
16
14
  ],
17
15
  setup: async (api) => {
18
16
  const { appDirectory, internalDirectory } = api.useAppContext();
19
- let internalTwConfigPath = "";
20
17
  const haveTwinMacro = await checkTwinMacroExist(appDirectory);
21
18
  const tailwindPath = getTailwindPath(appDirectory);
22
19
  const tailwindVersion = getTailwindVersion(appDirectory);
@@ -25,16 +22,8 @@ const tailwindcssPlugin = ({ pluginName } = {
25
22
  prepare() {
26
23
  if (haveTwinMacro) {
27
24
  const twinMajorVersion = getTwinMacroMajorVersion(appDirectory);
28
- const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
29
- if (useConfigPath) {
30
- internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
31
- const globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs"));
32
- const files = globby.sync(globPattern, {
33
- absolute: true
34
- });
35
- if (files.length > 0) {
36
- fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), "utf-8");
37
- }
25
+ if (twinMajorVersion && twinMajorVersion < 3) {
26
+ console.warn("Your twin.macro version is below 3.0.0. Please upgrade to the latest version to avoid potential issues.");
38
27
  }
39
28
  }
40
29
  },
@@ -84,7 +73,7 @@ const tailwindcssPlugin = ({ pluginName } = {
84
73
  {
85
74
  twin: {
86
75
  preset: supportCssInJsLibrary,
87
- config: internalTwConfigPath || tailwindConfig
76
+ config: tailwindConfig
88
77
  }
89
78
  }
90
79
  ]
@@ -1,25 +1,5 @@
1
1
  import path from "path";
2
- import { fs, nanoid, slash } from "@modern-js/utils";
3
- const template = (configPath) => `
4
- function _interopRequireDefault(obj) {
5
- return obj && obj.__esModule ? obj : { default: obj };
6
- }
7
- const modernConfig = _interopRequireDefault(require('${configPath}')).default;
8
-
9
- const theme =
10
- modernConfig && modernConfig.source && modernConfig.source.designSystem
11
- ? modernConfig.source.designSystem
12
- : {};
13
- const tailwindcss =
14
- modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss
15
- ? modernConfig.tools.tailwindcss
16
- : {};
17
-
18
- module.exports = {
19
- theme,
20
- ...tailwindcss,
21
- };
22
- `;
2
+ import { fs } from "@modern-js/utils";
23
3
  const TWIN_MACRO_NAME = "twin.macro";
24
4
  const checkTwinMacroExist = async (appDirectory) => {
25
5
  const packageJson = await fs.readJSON(path.join(appDirectory, "package.json"), {
@@ -40,12 +20,7 @@ const getTwinMacroMajorVersion = (appDirectory) => {
40
20
  return null;
41
21
  }
42
22
  };
43
- const getRandomTwConfigFileName = (internalDirectory) => {
44
- return slash(path.join(internalDirectory, `tailwind.config.${Date.now()}.${nanoid()}.js`));
45
- };
46
23
  export {
47
24
  checkTwinMacroExist,
48
- getRandomTwConfigFileName,
49
- getTwinMacroMajorVersion,
50
- template
25
+ getTwinMacroMajorVersion
51
26
  };
@@ -1,4 +1,2 @@
1
- export declare const template: (configPath: string) => string;
2
1
  export declare const checkTwinMacroExist: (appDirectory: string) => Promise<boolean>;
3
2
  export declare const getTwinMacroMajorVersion: (appDirectory: string) => number | null;
4
- export declare const getRandomTwConfigFileName: (internalDirectory: string) => string;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.64.0",
18
+ "version": "2.64.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "@swc/helpers": "0.5.13",
51
51
  "babel-plugin-macros": "3.1.0",
52
- "@modern-js/node-bundle-require": "2.64.0",
53
- "@modern-js/runtime-utils": "2.64.0",
54
- "@modern-js/utils": "2.64.0"
52
+ "@modern-js/runtime-utils": "2.64.2",
53
+ "@modern-js/node-bundle-require": "2.64.2",
54
+ "@modern-js/utils": "2.64.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/jest": "^29",
@@ -61,17 +61,17 @@
61
61
  "react": "^18.3.1",
62
62
  "tailwindcss": "^3.3.3",
63
63
  "typescript": "^5",
64
- "@modern-js/core": "2.64.0",
65
- "@modern-js/module-tools": "2.64.0",
66
- "@modern-js/app-tools": "2.64.0",
67
- "@modern-js/runtime": "2.64.0",
68
- "@modern-js/types": "2.64.0",
69
- "@scripts/build": "2.64.0",
70
- "@scripts/jest-config": "2.64.0"
64
+ "@modern-js/app-tools": "2.64.2",
65
+ "@modern-js/runtime": "2.64.2",
66
+ "@modern-js/core": "2.64.2",
67
+ "@modern-js/module-tools": "2.64.2",
68
+ "@modern-js/types": "2.64.2",
69
+ "@scripts/jest-config": "2.64.2",
70
+ "@scripts/build": "2.64.2"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "tailwindcss": ">= 2.0.0 || >= 3.0.0",
74
- "@modern-js/runtime": "^2.64.0"
74
+ "@modern-js/runtime": "^2.64.2"
75
75
  },
76
76
  "peerDependenciesMeta": {
77
77
  "@modern-js/runtime": {