@modern-js/plugin-tailwindcss 2.32.0 → 2.32.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
+ ## 2.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 5e04e3e: refactor(tailwindcss): allow to use tailwind theme config
8
+
9
+ refactor(tailwindcss): 支持使用 tailwind theme 配置
10
+
11
+ - Updated dependencies [90e053a]
12
+ - @modern-js/runtime@2.32.1
13
+ - @modern-js/utils@2.32.1
14
+
3
15
  ## 2.32.0
4
16
 
5
17
  ### Patch Changes
@@ -39,8 +39,7 @@ const _default = ({ pluginName } = {
39
39
  alias: {
40
40
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
41
41
  }
42
- },
43
- tools: {}
42
+ }
44
43
  };
45
44
  },
46
45
  modifyEntryImports({ entrypoint, imports }) {
@@ -10,21 +10,10 @@ Object.defineProperty(exports, "getTailwindConfig", {
10
10
  });
11
11
  const _utils = require("@modern-js/utils");
12
12
  const _lodash = require("@modern-js/utils/lodash");
13
- const checkIfExistNotAllowKeys = (tailwindConfig) => {
14
- const notAllowExistKeys = [
15
- "theme"
16
- ];
17
- let notAllowKey = "";
18
- const ret = Object.keys(tailwindConfig).some((key) => notAllowExistKeys.includes(key) && (notAllowKey = key));
19
- return [
20
- ret,
21
- notAllowKey
22
- ];
23
- };
24
- const getPureDesignSystemConfig = (designSystemConfig) => {
25
- const pureDesignSystemConfig = (0, _lodash.cloneDeep)(designSystemConfig);
26
- delete pureDesignSystemConfig.supportStyledComponents;
27
- return pureDesignSystemConfig;
13
+ const getPureDesignSystemConfig = (config) => {
14
+ const pureConfig = (0, _lodash.cloneDeep)(config);
15
+ delete pureConfig.supportStyledComponents;
16
+ return pureConfig;
28
17
  };
29
18
  const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
30
19
  const purgeConfig = (0, _lodash.merge)({
@@ -43,11 +32,8 @@ const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option =
43
32
  };
44
33
  const tailwindConfig = (0, _utils.applyOptionsChain)(defaultTailwindConfig, tailwindcss || {});
45
34
  const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
46
- const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
47
- if (exist) {
48
- _utils.logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
49
- process.exit(0);
35
+ if (designSystemConfig && Object.keys(designSystemConfig).length > 0) {
36
+ tailwindConfig.theme = designSystemConfig;
50
37
  }
51
- tailwindConfig.theme = designSystemConfig || {};
52
38
  return tailwindConfig;
53
39
  };
@@ -30,8 +30,7 @@ export default function() {
30
30
  alias: {
31
31
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
32
32
  }
33
- },
34
- tools: {}
33
+ }
35
34
  };
36
35
  },
37
36
  modifyEntryImports: function modifyEntryImports(param) {
@@ -1,23 +1,9 @@
1
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
2
- import { applyOptionsChain, logger } from "@modern-js/utils";
1
+ import { applyOptionsChain } from "@modern-js/utils";
3
2
  import { merge, cloneDeep } from "@modern-js/utils/lodash";
4
- var checkIfExistNotAllowKeys = function(tailwindConfig) {
5
- var notAllowExistKeys = [
6
- "theme"
7
- ];
8
- var notAllowKey = "";
9
- var ret = Object.keys(tailwindConfig).some(function(key) {
10
- return notAllowExistKeys.includes(key) && (notAllowKey = key);
11
- });
12
- return [
13
- ret,
14
- notAllowKey
15
- ];
16
- };
17
- var getPureDesignSystemConfig = function(designSystemConfig) {
18
- var pureDesignSystemConfig = cloneDeep(designSystemConfig);
19
- delete pureDesignSystemConfig.supportStyledComponents;
20
- return pureDesignSystemConfig;
3
+ var getPureDesignSystemConfig = function(config) {
4
+ var pureConfig = cloneDeep(config);
5
+ delete pureConfig.supportStyledComponents;
6
+ return pureConfig;
21
7
  };
22
8
  var getTailwindConfig = function(tailwindVersion, tailwindcss, designSystem) {
23
9
  var option = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
@@ -37,12 +23,9 @@ var getTailwindConfig = function(tailwindVersion, tailwindcss, designSystem) {
37
23
  };
38
24
  var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
39
25
  var designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
40
- var _checkIfExistNotAllowKeys = _sliced_to_array(checkIfExistNotAllowKeys(tailwindConfig), 2), exist = _checkIfExistNotAllowKeys[0], key = _checkIfExistNotAllowKeys[1];
41
- if (exist) {
42
- logger.error("should not exist '".concat(key, "' on tools.tailwindcss, please remove it"));
43
- process.exit(0);
26
+ if (designSystemConfig && Object.keys(designSystemConfig).length > 0) {
27
+ tailwindConfig.theme = designSystemConfig;
44
28
  }
45
- tailwindConfig.theme = designSystemConfig || {};
46
29
  return tailwindConfig;
47
30
  };
48
31
  export { getTailwindConfig };
@@ -29,8 +29,7 @@ export default ({ pluginName } = {
29
29
  alias: {
30
30
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
31
31
  }
32
- },
33
- tools: {}
32
+ }
34
33
  };
35
34
  },
36
35
  modifyEntryImports({ entrypoint, imports }) {
@@ -1,20 +1,9 @@
1
- import { applyOptionsChain, logger } from "@modern-js/utils";
1
+ import { applyOptionsChain } from "@modern-js/utils";
2
2
  import { merge, cloneDeep } from "@modern-js/utils/lodash";
3
- const checkIfExistNotAllowKeys = (tailwindConfig) => {
4
- const notAllowExistKeys = [
5
- "theme"
6
- ];
7
- let notAllowKey = "";
8
- const ret = Object.keys(tailwindConfig).some((key) => notAllowExistKeys.includes(key) && (notAllowKey = key));
9
- return [
10
- ret,
11
- notAllowKey
12
- ];
13
- };
14
- const getPureDesignSystemConfig = (designSystemConfig) => {
15
- const pureDesignSystemConfig = cloneDeep(designSystemConfig);
16
- delete pureDesignSystemConfig.supportStyledComponents;
17
- return pureDesignSystemConfig;
3
+ const getPureDesignSystemConfig = (config) => {
4
+ const pureConfig = cloneDeep(config);
5
+ delete pureConfig.supportStyledComponents;
6
+ return pureConfig;
18
7
  };
19
8
  const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
20
9
  const purgeConfig = merge({
@@ -33,12 +22,9 @@ const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option =
33
22
  };
34
23
  const tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
35
24
  const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
36
- const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
37
- if (exist) {
38
- logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
39
- process.exit(0);
25
+ if (designSystemConfig && Object.keys(designSystemConfig).length > 0) {
26
+ tailwindConfig.theme = designSystemConfig;
40
27
  }
41
- tailwindConfig.theme = designSystemConfig || {};
42
28
  return tailwindConfig;
43
29
  };
44
30
  export { getTailwindConfig };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.32.0",
18
+ "version": "2.32.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -49,7 +49,7 @@
49
49
  "babel-plugin-macros": "3.1.0",
50
50
  "hoist-non-react-statics": "^3.3.2",
51
51
  "@swc/helpers": "0.5.1",
52
- "@modern-js/utils": "2.32.0"
52
+ "@modern-js/utils": "2.32.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/jest": "^29",
@@ -59,17 +59,17 @@
59
59
  "jest": "^29",
60
60
  "react": "^18",
61
61
  "postcss": "8.4.27",
62
- "@modern-js/core": "2.32.0",
63
- "@modern-js/module-tools": "2.32.0",
64
- "@modern-js/runtime": "2.32.0",
65
- "@modern-js/types": "2.32.0",
66
- "@modern-js/app-tools": "2.32.0",
67
- "@scripts/jest-config": "2.32.0",
68
- "@scripts/build": "2.32.0"
62
+ "@modern-js/core": "2.32.1",
63
+ "@modern-js/module-tools": "2.32.1",
64
+ "@modern-js/runtime": "2.32.1",
65
+ "@modern-js/types": "2.32.1",
66
+ "@modern-js/app-tools": "2.32.1",
67
+ "@scripts/build": "2.32.1",
68
+ "@scripts/jest-config": "2.32.1"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "tailwindcss": ">= 2.0.0 || >= 3.0.0",
72
- "@modern-js/runtime": "^2.32.0"
72
+ "@modern-js/runtime": "^2.32.1"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@modern-js/runtime": {