@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.6
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 +197 -0
- package/dist/js/modern/cli.js +132 -79
- package/dist/js/modern/design-token/cli/index.js +57 -51
- package/dist/js/modern/design-token/global.d.js +0 -0
- package/dist/js/modern/design-token/index.js +5 -2
- package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
- package/dist/js/modern/design-token/runtime/index.js +4 -1
- package/dist/js/modern/design-token/runtime/plugin.js +41 -29
- package/dist/js/modern/index.js +4 -1
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/tailwind.js +28 -21
- package/dist/js/modern/utils.js +32 -8
- package/dist/js/node/cli.js +156 -90
- package/dist/js/node/design-token/cli/index.js +70 -56
- package/dist/js/node/design-token/global.d.js +0 -0
- package/dist/js/node/design-token/index.js +31 -24
- package/dist/js/node/design-token/postcss-plugin/index.js +30 -13
- package/dist/js/node/design-token/runtime/index.js +33 -22
- package/dist/js/node/design-token/runtime/plugin.js +68 -40
- package/dist/js/node/index.js +29 -11
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/tailwind.js +51 -27
- package/dist/js/node/types.js +15 -0
- package/dist/js/node/utils.js +61 -16
- package/dist/js/treeshaking/cli.js +265 -132
- package/dist/js/treeshaking/design-token/cli/index.js +116 -99
- package/dist/js/treeshaking/design-token/global.d.js +1 -0
- package/dist/js/treeshaking/design-token/index.js +3 -2
- package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
- package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
- package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
- package/dist/js/treeshaking/index.js +2 -1
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/tailwind.js +86 -42
- package/dist/js/treeshaking/types.js +1 -0
- package/dist/js/treeshaking/utils.js +159 -44
- package/dist/types/cli.d.ts +3 -1
- package/dist/types/design-token/cli/index.d.ts +2 -0
- package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
- package/dist/types/design-token/runtime/plugin.d.ts +2 -0
- package/package.json +11 -10
@@ -1,101 +1,118 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
var
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}
|
16
|
-
|
17
|
-
|
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,57 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
};
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
1
|
+
import { default as default2 } from "./cli";
|
2
|
+
export { default2 as default };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
@@ -1,45 +1,89 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
13
|
-
|
14
|
-
|
15
|
-
|
62
|
+
var getPureDesignSystemConfig = function(designSystemConfig) {
|
63
|
+
var pureDesignSystemConfig = cloneDeep(designSystemConfig);
|
64
|
+
delete pureDesignSystemConfig.supportStyledComponents;
|
65
|
+
return pureDesignSystemConfig;
|
16
66
|
};
|
17
|
-
var getTailwindConfig = function
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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";
|