@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.4

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 (40) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/dist/js/modern/cli.js +132 -79
  3. package/dist/js/modern/design-token/cli/index.js +57 -51
  4. package/dist/js/modern/design-token/global.d.js +0 -0
  5. package/dist/js/modern/design-token/index.js +5 -2
  6. package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
  7. package/dist/js/modern/design-token/runtime/index.js +4 -1
  8. package/dist/js/modern/design-token/runtime/plugin.js +41 -29
  9. package/dist/js/modern/index.js +4 -1
  10. package/dist/js/modern/modern-app.env.d.js +0 -0
  11. package/dist/js/modern/tailwind.js +28 -21
  12. package/dist/js/modern/utils.js +32 -8
  13. package/dist/js/node/cli.js +152 -90
  14. package/dist/js/node/design-token/cli/index.js +70 -56
  15. package/dist/js/node/design-token/global.d.js +0 -0
  16. package/dist/js/node/design-token/index.js +29 -24
  17. package/dist/js/node/design-token/postcss-plugin/index.js +28 -13
  18. package/dist/js/node/design-token/runtime/index.js +31 -22
  19. package/dist/js/node/design-token/runtime/plugin.js +65 -40
  20. package/dist/js/node/index.js +27 -11
  21. package/dist/js/node/modern-app.env.d.js +0 -0
  22. package/dist/js/node/tailwind.js +47 -27
  23. package/dist/js/node/utils.js +56 -16
  24. package/dist/js/treeshaking/cli.js +265 -132
  25. package/dist/js/treeshaking/design-token/cli/index.js +116 -99
  26. package/dist/js/treeshaking/design-token/global.d.js +1 -0
  27. package/dist/js/treeshaking/design-token/index.js +3 -2
  28. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
  29. package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
  30. package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
  31. package/dist/js/treeshaking/index.js +2 -1
  32. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  33. package/dist/js/treeshaking/tailwind.js +86 -42
  34. package/dist/js/treeshaking/types.js +1 -0
  35. package/dist/js/treeshaking/utils.js +159 -44
  36. package/dist/types/cli.d.ts +3 -1
  37. package/dist/types/design-token/cli/index.d.ts +2 -0
  38. package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
  39. package/dist/types/design-token/runtime/plugin.d.ts +2 -0
  40. package/package.json +11 -10
@@ -1,101 +1,118 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import { lazyImport, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
4
- export default (function () {
5
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
6
- pluginName: '@modern-js/plugin-tailwindcss'
7
- },
8
- pluginName = _ref.pluginName;
9
- return {
10
- name: '@modern-js/plugin-design-token',
11
- setup: function setup(api) {
12
- var pluginsExportsUtils;
13
- var resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
14
- var PLUGIN_IDENTIFIER = 'designToken';
15
- var getDesignTokens = function getDesignTokens(designSystem) {
16
- var tailwindcssConfig = {};
17
- tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
18
-
19
- // not use default design token when designToken.defaultTheme is false or theme is false
20
- if (!designSystem) {
21
- tailwindcssConfig.presets = [];
22
- }
23
-
24
- // when only designSystem exist, need remove supportStyledComponents
25
- if (designSystem) {
26
- delete tailwindcssConfig.theme.supportStyledComponents;
27
- }
28
- return resolveConfig(tailwindcssConfig).theme || {};
29
- };
30
- return {
31
- config: function config() {
32
- var appContext = api.useAppContext();
33
- pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'plugins');
34
- return {
35
- source: {
36
- alias: {
37
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
38
- }
39
- },
40
- tools: {
41
- // TODO: support less、scss、css vars
42
- // less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
43
- // sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
44
- // postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
45
- }
46
- };
47
- },
48
- modifyEntryImports: function modifyEntryImports(_ref2) {
49
- var _userConfig$source$de, _userConfig$source;
50
- var entrypoint = _ref2.entrypoint,
51
- imports = _ref2.imports;
52
- var userConfig = api.useResolvedConfigContext();
53
- var designSystem = (_userConfig$source$de = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
54
- if (_typeof(designSystem) === 'object' && designSystem.supportStyledComponents) {
55
- var designTokens = getDesignTokens(userConfig.source.designSystem);
56
- imports.push({
57
- value: '@modern-js/runtime/plugins',
58
- specifiers: [{
59
- imported: PLUGIN_IDENTIFIER
60
- }],
61
- initialize: "\n const designTokens = ".concat(JSON.stringify(designTokens), ";\n ")
62
- });
63
- }
64
- return {
65
- entrypoint: entrypoint,
66
- imports: imports
67
- };
68
- },
69
- modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref3) {
70
- var _userConfig$source$de2, _userConfig$source2;
71
- var entrypoint = _ref3.entrypoint,
72
- plugins = _ref3.plugins;
73
- var userConfig = api.useResolvedConfigContext();
74
- var designSystem = (_userConfig$source$de2 = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
75
- var useSCThemeProvider = true;
76
- if (designSystem) {
77
- // when designSystem exist, designToken.styledComponents`s default value is false.
78
- useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
79
- }
80
- if (_typeof(designSystem) === 'object' && designSystem.supportStyledComponents) {
81
- plugins.push({
82
- name: PLUGIN_IDENTIFIER,
83
- options: "{token: designTokens, useStyledComponentsThemeProvider: ".concat(useSCThemeProvider ? 'true' : 'false', ", useDesignTokenContext: false}")
84
- });
85
- }
86
- return {
87
- entrypoint: entrypoint,
88
- plugins: plugins
89
- };
90
- },
91
- validateSchema: function validateSchema() {
92
- // add source.designSystem.supportStyledComponents config
93
- return PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
94
- },
95
- addRuntimeExports: function addRuntimeExports() {
96
- pluginsExportsUtils.addExport("export { default as designToken } from '".concat(pluginName, "/runtime-design-token'"));
1
+ function _defineProperty(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _objectSpread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
97
22
  }
98
- };
23
+ ownKeys.forEach(function(key) {
24
+ _defineProperty(target, key, source[key]);
25
+ });
99
26
  }
100
- };
101
- });
27
+ return target;
28
+ }
29
+ import { lazyImport, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from "@modern-js/utils";
30
+ var cli_default = function() {
31
+ var pluginName = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
32
+ pluginName: "@modern-js/plugin-tailwindcss"
33
+ }).pluginName;
34
+ return {
35
+ name: "@modern-js/plugin-design-token",
36
+ setup: function setup(api) {
37
+ var pluginsExportsUtils;
38
+ var resolveConfig = lazyImport("tailwindcss/resolveConfig", require);
39
+ var PLUGIN_IDENTIFIER = "designToken";
40
+ var getDesignTokens = function(designSystem) {
41
+ var tailwindcssConfig = {};
42
+ tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
43
+ if (!designSystem) {
44
+ tailwindcssConfig.presets = [];
45
+ }
46
+ if (designSystem) {
47
+ delete tailwindcssConfig.theme.supportStyledComponents;
48
+ }
49
+ return resolveConfig(tailwindcssConfig).theme || {};
50
+ };
51
+ return {
52
+ config: function config() {
53
+ var appContext = api.useAppContext();
54
+ pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
55
+ return {
56
+ source: {
57
+ alias: {
58
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
59
+ }
60
+ },
61
+ tools: {}
62
+ };
63
+ },
64
+ modifyEntryImports: function modifyEntryImports(param) {
65
+ var entrypoint = param.entrypoint, imports = param.imports;
66
+ var ref;
67
+ var userConfig = api.useResolvedConfigContext();
68
+ var ref1;
69
+ var designSystem = (ref1 = (ref = userConfig.source) === null || ref === void 0 ? void 0 : ref.designSystem) !== null && ref1 !== void 0 ? ref1 : {};
70
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
71
+ var designTokens = getDesignTokens(userConfig.source.designSystem);
72
+ imports.push({
73
+ value: "@modern-js/runtime/plugins",
74
+ specifiers: [
75
+ {
76
+ imported: PLUGIN_IDENTIFIER
77
+ }
78
+ ],
79
+ initialize: "\n const designTokens = ".concat(JSON.stringify(designTokens), ";\n ")
80
+ });
81
+ }
82
+ return {
83
+ entrypoint: entrypoint,
84
+ imports: imports
85
+ };
86
+ },
87
+ modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
88
+ var entrypoint = param.entrypoint, plugins = param.plugins;
89
+ var ref;
90
+ var userConfig = api.useResolvedConfigContext();
91
+ var ref1;
92
+ var designSystem = (ref1 = (ref = userConfig.source) === null || ref === void 0 ? void 0 : ref.designSystem) !== null && ref1 !== void 0 ? ref1 : {};
93
+ var useSCThemeProvider = true;
94
+ if (designSystem) {
95
+ useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
96
+ }
97
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
98
+ plugins.push({
99
+ name: PLUGIN_IDENTIFIER,
100
+ options: "{token: designTokens, useStyledComponentsThemeProvider: ".concat(useSCThemeProvider ? "true" : "false", ", useDesignTokenContext: false}")
101
+ });
102
+ }
103
+ return {
104
+ entrypoint: entrypoint,
105
+ plugins: plugins
106
+ };
107
+ },
108
+ validateSchema: function validateSchema() {
109
+ return PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
110
+ },
111
+ addRuntimeExports: function addRuntimeExports() {
112
+ pluginsExportsUtils.addExport("export { default as designToken } from '".concat(pluginName, "/runtime-design-token'"));
113
+ }
114
+ };
115
+ }
116
+ };
117
+ };
118
+ export { cli_default as default };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,2 +1,3 @@
1
- export { default } from "./runtime";
2
- export * from "./runtime";
1
+ import { default as default2 } from "./runtime";
2
+ export * from "./runtime";
3
+ export { default2 as default };
@@ -1,26 +1,17 @@
1
- export default (function () {
2
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3
- _ref$cssVarsHash = _ref.cssVarsHash,
4
- cssVarsHash = _ref$cssVarsHash === void 0 ? {} : _ref$cssVarsHash;
5
- return {
6
- postcssPlugin: 'postcss-replace-css-vars',
7
- Declaration: function (_Declaration) {
8
- function Declaration(_x) {
9
- return _Declaration.apply(this, arguments);
10
- }
11
- Declaration.toString = function () {
12
- return _Declaration.toString();
13
- };
14
- return Declaration;
15
- }(function (decl) {
16
- if (decl.value && typeof decl.value === 'string') {
17
- decl.value = decl.value.replace(/--\S*/g, function (match) {
18
- if (cssVarsHash[match]) {
19
- return cssVarsHash[match];
20
- }
21
- return match;
22
- });
23
- }
24
- })
25
- };
26
- });
1
+ var postcss_plugin_default = function() {
2
+ var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _cssVarsHash = ref.cssVarsHash, cssVarsHash = _cssVarsHash === void 0 ? {} : _cssVarsHash;
3
+ return {
4
+ postcssPlugin: "postcss-replace-css-vars",
5
+ Declaration: function Declaration(decl) {
6
+ if (decl.value && typeof decl.value === "string") {
7
+ decl.value = decl.value.replace(/--\S*/g, function(match) {
8
+ if (cssVarsHash[match]) {
9
+ return cssVarsHash[match];
10
+ }
11
+ return match;
12
+ });
13
+ }
14
+ }
15
+ };
16
+ };
17
+ export { postcss_plugin_default as default };
@@ -1,3 +1,4 @@
1
1
  import designTokenPlugin from "./plugin";
2
2
  export * from "./plugin";
3
- export default designTokenPlugin;
3
+ var runtime_default = designTokenPlugin;
4
+ export { runtime_default as default };
@@ -1,57 +1,78 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import hoistNonReactStatics from 'hoist-non-react-statics';
3
- import React, { useContext } from 'react';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- export var DesignTokenContext = /*#__PURE__*/React.createContext({});
6
- export var useDesignTokens = function useDesignTokens() {
7
- return useContext(DesignTokenContext);
8
- };
9
- export default (function () {
10
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
- return {
12
- name: '@modern-js/plugin-design-token',
13
- setup: function setup() {
14
- return {
15
- hoc: function hoc(_ref, next) {
16
- var App = _ref.App;
17
- var DesignTokenAppWrapper = function DesignTokenAppWrapper(props) {
18
- var _options$token = options.token,
19
- token = _options$token === void 0 ? {} : _options$token,
20
- _options$useStyledCom = options.useStyledComponentsThemeProvider,
21
- useStyledComponentsThemeProvider = _options$useStyledCom === void 0 ? false : _options$useStyledCom,
22
- _options$useDesignTok = options.useDesignTokenContext,
23
- useDesignTokenContext = _options$useDesignTok === void 0 ? false : _options$useDesignTok;
24
- if (useStyledComponentsThemeProvider && useDesignTokenContext) {
25
- var _require = require('@modern-js/runtime/styled'),
26
- ThemeProvider = _require.ThemeProvider;
27
- return /*#__PURE__*/_jsx(ThemeProvider, {
28
- theme: token,
29
- children: /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
30
- value: token,
31
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
32
- })
33
- });
34
- } else if (useStyledComponentsThemeProvider) {
35
- var _require2 = require('@modern-js/runtime/styled'),
36
- _ThemeProvider = _require2.ThemeProvider;
37
- return /*#__PURE__*/_jsx(_ThemeProvider, {
38
- theme: token,
39
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
40
- });
41
- } else if (useDesignTokenContext) {
42
- return /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
43
- value: token,
44
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
45
- });
46
- } else {
47
- return /*#__PURE__*/_jsx(App, _objectSpread({}, props));
48
- }
49
- };
50
- return next({
51
- App: hoistNonReactStatics(DesignTokenAppWrapper, App)
52
- });
1
+ function _defineProperty(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _objectSpread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
53
22
  }
54
- };
23
+ ownKeys.forEach(function(key) {
24
+ _defineProperty(target, key, source[key]);
25
+ });
55
26
  }
56
- };
57
- });
27
+ return target;
28
+ }
29
+ import { jsx } from "react/jsx-runtime";
30
+ import hoistNonReactStatics from "hoist-non-react-statics";
31
+ import React, { useContext } from "react";
32
+ var DesignTokenContext = React.createContext({});
33
+ var useDesignTokens = function() {
34
+ return useContext(DesignTokenContext);
35
+ };
36
+ var plugin_default = function() {
37
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
38
+ return {
39
+ name: "@modern-js/plugin-design-token",
40
+ setup: function() {
41
+ return {
42
+ hoc: function hoc(param, next) {
43
+ var App = param.App;
44
+ var DesignTokenAppWrapper = function(props) {
45
+ var _token = options.token, token = _token === void 0 ? {} : _token, _useStyledComponentsThemeProvider = options.useStyledComponentsThemeProvider, useStyledComponentsThemeProvider = _useStyledComponentsThemeProvider === void 0 ? false : _useStyledComponentsThemeProvider, _useDesignTokenContext = options.useDesignTokenContext, useDesignTokenContext = _useDesignTokenContext === void 0 ? false : _useDesignTokenContext;
46
+ if (useStyledComponentsThemeProvider && useDesignTokenContext) {
47
+ var ThemeProvider = require("@modern-js/runtime/styled").ThemeProvider;
48
+ return /* @__PURE__ */ jsx(ThemeProvider, {
49
+ theme: token,
50
+ children: /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
51
+ value: token,
52
+ children: /* @__PURE__ */ jsx(App, _objectSpread({}, props))
53
+ })
54
+ });
55
+ } else if (useStyledComponentsThemeProvider) {
56
+ var ThemeProvider1 = require("@modern-js/runtime/styled").ThemeProvider;
57
+ return /* @__PURE__ */ jsx(ThemeProvider1, {
58
+ theme: token,
59
+ children: /* @__PURE__ */ jsx(App, _objectSpread({}, props))
60
+ });
61
+ } else if (useDesignTokenContext) {
62
+ return /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
63
+ value: token,
64
+ children: /* @__PURE__ */ jsx(App, _objectSpread({}, props))
65
+ });
66
+ } else {
67
+ return /* @__PURE__ */ jsx(App, _objectSpread({}, props));
68
+ }
69
+ };
70
+ return next({
71
+ App: hoistNonReactStatics(DesignTokenAppWrapper, App)
72
+ });
73
+ }
74
+ };
75
+ }
76
+ };
77
+ };
78
+ export { DesignTokenContext, plugin_default as default, useDesignTokens };
@@ -1 +1,2 @@
1
- export { default } from "./cli";
1
+ import { default as default2 } from "./cli";
2
+ export { default2 as default };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,45 +1,89 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { applyOptionsChain, logger } from '@modern-js/utils';
3
- import { merge, cloneDeep } from '@modern-js/utils/lodash';
4
- var checkIfExistNotAllowKeys = function checkIfExistNotAllowKeys(tailwindConfig) {
5
- var notAllowExistKeys = ['theme'];
6
- var notAllowKey = '';
7
- var ret = Object.keys(tailwindConfig).some(function (key) {
8
- return notAllowExistKeys.includes(key) && (notAllowKey = key);
9
- });
10
- return [ret, notAllowKey];
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithHoles(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _iterableToArrayLimit(arr, i) {
10
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11
+ if (_i == null) return;
12
+ var _arr = [];
13
+ var _n = true;
14
+ var _d = false;
15
+ var _s, _e;
16
+ try {
17
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
18
+ _arr.push(_s.value);
19
+ if (i && _arr.length === i) break;
20
+ }
21
+ } catch (err) {
22
+ _d = true;
23
+ _e = err;
24
+ } finally{
25
+ try {
26
+ if (!_n && _i["return"] != null) _i["return"]();
27
+ } finally{
28
+ if (_d) throw _e;
29
+ }
30
+ }
31
+ return _arr;
32
+ }
33
+ function _nonIterableRest() {
34
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _slicedToArray(arr, i) {
37
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
38
+ }
39
+ function _unsupportedIterableToArray(o, minLen) {
40
+ if (!o) return;
41
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor) n = o.constructor.name;
44
+ if (n === "Map" || n === "Set") return Array.from(n);
45
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
46
+ }
47
+ import { applyOptionsChain, logger } from "@modern-js/utils";
48
+ import { merge, cloneDeep } from "@modern-js/utils/lodash";
49
+ var checkIfExistNotAllowKeys = function(tailwindConfig) {
50
+ var notAllowExistKeys = [
51
+ "theme"
52
+ ];
53
+ var notAllowKey = "";
54
+ var ret = Object.keys(tailwindConfig).some(function(key) {
55
+ return notAllowExistKeys.includes(key) && (notAllowKey = key);
56
+ });
57
+ return [
58
+ ret,
59
+ notAllowKey
60
+ ];
11
61
  };
12
- var getPureDesignSystemConfig = function getPureDesignSystemConfig(designSystemConfig) {
13
- var pureDesignSystemConfig = cloneDeep(designSystemConfig);
14
- delete pureDesignSystemConfig.supportStyledComponents;
15
- return pureDesignSystemConfig;
62
+ var getPureDesignSystemConfig = function(designSystemConfig) {
63
+ var pureDesignSystemConfig = cloneDeep(designSystemConfig);
64
+ delete pureDesignSystemConfig.supportStyledComponents;
65
+ return pureDesignSystemConfig;
16
66
  };
17
- var getTailwindConfig = function getTailwindConfig(tailwindcss, designSystem) {
18
- var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
19
- var purgeConfig = merge({
20
- // TODO: how the operating environment is determined
21
- enabled: process.env.NODE_ENV === 'production',
22
- // TODO: Remove or not
23
- layers: ['utilities'],
24
- content: []
25
- }, option.pureConfig || {});
26
- var defaultTailwindConfig = {
27
- purge: purgeConfig
28
- };
29
- var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
30
- var designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
31
- var _checkIfExistNotAllow = checkIfExistNotAllowKeys(tailwindConfig),
32
- _checkIfExistNotAllow2 = _slicedToArray(_checkIfExistNotAllow, 2),
33
- exist = _checkIfExistNotAllow2[0],
34
- key = _checkIfExistNotAllow2[1];
35
- if (exist) {
36
- logger.error("should not exist '".concat(key, "' on tools.tailwindcss, please remove it"));
37
- // eslint-disable-next-line no-process-exit
38
- process.exit(0);
39
- }
40
-
41
- // Because there is no default theme configuration
42
- tailwindConfig.theme = designSystemConfig || {};
43
- return tailwindConfig;
67
+ var getTailwindConfig = function(tailwindcss, designSystem) {
68
+ var option = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
69
+ var purgeConfig = merge({
70
+ enabled: process.env.NODE_ENV === "production",
71
+ layers: [
72
+ "utilities"
73
+ ],
74
+ content: []
75
+ }, option.pureConfig || {});
76
+ var defaultTailwindConfig = {
77
+ purge: purgeConfig
78
+ };
79
+ var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
80
+ var designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
81
+ var ref = _slicedToArray(checkIfExistNotAllowKeys(tailwindConfig), 2), exist = ref[0], key = ref[1];
82
+ if (exist) {
83
+ logger.error("should not exist '".concat(key, "' on tools.tailwindcss, please remove it"));
84
+ process.exit(0);
85
+ }
86
+ tailwindConfig.theme = designSystemConfig || {};
87
+ return tailwindConfig;
44
88
  };
45
- export { getTailwindConfig };
89
+ export { getTailwindConfig };
@@ -0,0 +1 @@
1
+ "use strict";