@modern-js/plugin-tailwindcss 1.21.5 → 2.0.0-beta.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 +94 -18
- package/dist/js/modern/cli.js +33 -37
- package/dist/js/modern/design-token/cli/index.js +13 -38
- package/dist/js/modern/design-token/postcss-plugin/index.js +0 -3
- package/dist/js/modern/design-token/runtime/plugin.js +0 -8
- package/dist/js/modern/tailwind.js +6 -10
- package/dist/js/modern/types.js +0 -0
- package/dist/js/modern/utils.js +0 -2
- package/dist/js/node/cli.js +33 -49
- package/dist/js/node/design-token/cli/index.js +13 -41
- package/dist/js/node/design-token/index.js +0 -4
- package/dist/js/node/design-token/postcss-plugin/index.js +0 -5
- package/dist/js/node/design-token/runtime/index.js +0 -5
- package/dist/js/node/design-token/runtime/plugin.js +0 -20
- package/dist/js/node/index.js +0 -2
- package/dist/js/node/tailwind.js +6 -13
- package/dist/js/node/types.js +0 -0
- package/dist/js/node/utils.js +0 -9
- package/dist/js/treeshaking/cli.js +34 -36
- package/dist/js/treeshaking/design-token/cli/index.js +22 -30
- package/dist/js/treeshaking/design-token/postcss-plugin/index.js +2 -6
- package/dist/js/treeshaking/design-token/runtime/plugin.js +7 -12
- package/dist/js/treeshaking/tailwind.js +9 -14
- package/dist/js/treeshaking/types.js +0 -0
- package/dist/js/treeshaking/utils.js +0 -9
- package/dist/types/cli.d.ts +0 -2
- package/dist/types/design-token/cli/index.d.ts +0 -2
- package/dist/types/design-token/postcss-plugin/index.d.ts +0 -2
- package/dist/types/design-token/runtime/plugin.d.ts +0 -2
- package/dist/types/types.d.ts +10 -0
- package/package.json +11 -34
package/CHANGELOG.md
CHANGED
@@ -1,27 +1,103 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.0.0-beta.1
|
4
4
|
|
5
|
-
###
|
6
|
-
|
7
|
-
- Updated dependencies [a150632]
|
8
|
-
- Updated dependencies [29576fc]
|
9
|
-
- @modern-js/runtime@1.21.5
|
10
|
-
- @modern-js/utils@1.21.5
|
11
|
-
|
12
|
-
## 1.21.4
|
13
|
-
|
14
|
-
### Patch Changes
|
15
|
-
|
16
|
-
- @modern-js/runtime@1.21.4
|
17
|
-
- @modern-js/utils@1.21.4
|
5
|
+
### Major Changes
|
18
6
|
|
19
|
-
|
7
|
+
- dda38c9: chore: v2
|
20
8
|
|
21
|
-
###
|
9
|
+
### Minor Changes
|
22
10
|
|
23
|
-
-
|
24
|
-
|
11
|
+
- 92f0ead: feat:
|
12
|
+
|
13
|
+
1. add style config and add new hook
|
14
|
+
2. add dts alias logic
|
15
|
+
3. add copy logic
|
16
|
+
4. add log logic
|
17
|
+
5. add skipDeps config
|
18
|
+
|
19
|
+
feat:
|
20
|
+
|
21
|
+
1. 添加样式配置以及新的 hook
|
22
|
+
2. 添加 dts 别名处理
|
23
|
+
3. 添加 copy 逻辑
|
24
|
+
4. 添加日志逻辑
|
25
|
+
5. 添加 skipDeps 配置
|
26
|
+
|
27
|
+
- 92f0ead: feat:
|
28
|
+
|
29
|
+
1. core: 增加 test 函数
|
30
|
+
2. module plugins: 增加 `babel`, `mainField`, `target` 插件
|
31
|
+
3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
|
32
|
+
4. 增加 designSystem 配置
|
33
|
+
|
34
|
+
feat:
|
35
|
+
|
36
|
+
1. core: add test method
|
37
|
+
2. module plugins: add `babel`, `mainField`, `target` plugin
|
38
|
+
3. storybook: change some logic and add tspath webpack plugin
|
39
|
+
4. add `designSystem` config
|
40
|
+
|
41
|
+
### Patch Changes
|
42
|
+
|
43
|
+
- Updated dependencies [2344eb2]
|
44
|
+
- Updated dependencies [a11fcf8]
|
45
|
+
- Updated dependencies [b18fa8f]
|
46
|
+
- Updated dependencies [c9e800d39a]
|
47
|
+
- Updated dependencies [3e57f2b]
|
48
|
+
- Updated dependencies [fbf5eed]
|
49
|
+
- Updated dependencies [a2509bfbdb]
|
50
|
+
- Updated dependencies [4369648ae2]
|
51
|
+
- Updated dependencies [92f0ead]
|
52
|
+
- Updated dependencies [92c0994]
|
53
|
+
- Updated dependencies [edd1cfb1af]
|
54
|
+
- Updated dependencies [cc971eabfc]
|
55
|
+
- Updated dependencies [5b9049f]
|
56
|
+
- Updated dependencies [6bda14ed71]
|
57
|
+
- Updated dependencies [92004d1]
|
58
|
+
- Updated dependencies [b8bbe036c7]
|
59
|
+
- Updated dependencies [40ed587]
|
60
|
+
- Updated dependencies [60d5378632]
|
61
|
+
- Updated dependencies [d5a31df781]
|
62
|
+
- Updated dependencies [dda38c9]
|
63
|
+
- Updated dependencies [8b8e1bb571]
|
64
|
+
- Updated dependencies [3bbea92b2a]
|
65
|
+
- Updated dependencies [18aaf42]
|
66
|
+
- Updated dependencies [fcace5b5b9]
|
67
|
+
- Updated dependencies [abf3421]
|
68
|
+
- Updated dependencies [543be9558e]
|
69
|
+
- Updated dependencies [14b712d]
|
70
|
+
- @modern-js/runtime@2.0.0-beta.1
|
71
|
+
- @modern-js/utils@2.0.0-beta.1
|
72
|
+
|
73
|
+
## 2.0.0-beta.0
|
74
|
+
|
75
|
+
### Major Changes
|
76
|
+
|
77
|
+
- dda38c9: chore: v2
|
78
|
+
|
79
|
+
### Patch Changes
|
80
|
+
|
81
|
+
- Updated dependencies [b18fa8f]
|
82
|
+
- Updated dependencies [c9e800d39]
|
83
|
+
- Updated dependencies [a2509bf]
|
84
|
+
- Updated dependencies [4369648ae]
|
85
|
+
- Updated dependencies [edd1cfb1a]
|
86
|
+
- Updated dependencies [cc971eabf]
|
87
|
+
- Updated dependencies [5b9049f]
|
88
|
+
- Updated dependencies [6bda14ed7]
|
89
|
+
- Updated dependencies [b8bbe036c]
|
90
|
+
- Updated dependencies [60d5378]
|
91
|
+
- Updated dependencies [d5a31df78]
|
92
|
+
- Updated dependencies [dda38c9]
|
93
|
+
- Updated dependencies [8b8e1bb57]
|
94
|
+
- Updated dependencies [3bbea92b2]
|
95
|
+
- Updated dependencies [fcace5b5b]
|
96
|
+
- Updated dependencies [abf3421]
|
97
|
+
- Updated dependencies [543be95]
|
98
|
+
- Updated dependencies [14b712d]
|
99
|
+
- @modern-js/runtime@2.0.0-beta.0
|
100
|
+
- @modern-js/utils@2.0.0-beta.0
|
25
101
|
|
26
102
|
## 1.21.2
|
27
103
|
|
package/dist/js/modern/cli.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
2
|
-
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
|
-
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
-
|
7
4
|
import path from 'path';
|
8
5
|
import { PLUGIN_SCHEMAS, fs, CONFIG_CACHE_DIR, globby, nanoid, slash } from '@modern-js/utils';
|
9
6
|
import DesignTokenPlugin from "./design-token/cli";
|
@@ -28,30 +25,26 @@ export default (({
|
|
28
25
|
appDirectory,
|
29
26
|
internalDirectory
|
30
27
|
} = api.useAppContext();
|
31
|
-
let internalTwConfigPath = '';
|
32
|
-
|
28
|
+
let internalTwConfigPath = '';
|
29
|
+
// When reinstalling dependencies, most of the time the project will be restarted
|
33
30
|
const notHaveTwinMacro = await checkTwinMacroNotExist(appDirectory);
|
34
31
|
return {
|
35
32
|
prepare() {
|
36
33
|
if (notHaveTwinMacro) {
|
37
34
|
return;
|
38
35
|
}
|
39
|
-
|
40
36
|
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
41
37
|
const globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, '*.cjs'));
|
42
38
|
const files = globby.sync(globPattern, {
|
43
39
|
absolute: true
|
44
40
|
});
|
45
|
-
|
46
41
|
if (files.length > 0) {
|
47
42
|
fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), 'utf-8');
|
48
43
|
}
|
49
44
|
},
|
50
|
-
|
51
45
|
validateSchema() {
|
52
46
|
return PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
|
53
47
|
},
|
54
|
-
|
55
48
|
config() {
|
56
49
|
return {
|
57
50
|
tools: {
|
@@ -59,27 +52,44 @@ export default (({
|
|
59
52
|
// TODO: In module project, also is called, but should not be called.
|
60
53
|
postcss: config => {
|
61
54
|
const modernConfig = api.useResolvedConfigContext();
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
if (!config.postcssOptions
|
56
|
+
// config.$$tools === 'module-tools'
|
57
|
+
) {
|
58
|
+
if (Array.isArray(config.plugins)) {
|
59
|
+
const tailwindConfig = getTailwindConfig(modernConfig, {
|
60
|
+
pureConfig: {
|
61
|
+
content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
62
|
+
}
|
63
|
+
});
|
64
|
+
config.plugins.push(require('tailwindcss')(tailwindConfig));
|
65
|
+
} else {
|
66
|
+
const tailwindConfig = getTailwindConfig(modernConfig, {
|
67
|
+
pureConfig: {
|
68
|
+
content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
69
|
+
}
|
70
|
+
});
|
71
|
+
config.plugins = [require('tailwindcss')(tailwindConfig)];
|
66
72
|
}
|
67
|
-
});
|
68
|
-
|
69
|
-
if (Array.isArray(config.postcssOptions.plugins)) {
|
70
|
-
config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
|
71
73
|
} else {
|
72
|
-
|
74
|
+
const tailwindConfig = getTailwindConfig(modernConfig, {
|
75
|
+
pureConfig: {
|
76
|
+
content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
|
77
|
+
// about storybook
|
78
|
+
'./storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
79
|
+
}
|
80
|
+
});
|
81
|
+
if (Array.isArray(config.postcssOptions.plugins)) {
|
82
|
+
config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
|
83
|
+
} else {
|
84
|
+
config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
|
85
|
+
}
|
73
86
|
}
|
74
87
|
},
|
75
|
-
|
76
88
|
babel(config) {
|
77
89
|
var _config$plugins;
|
78
|
-
|
79
90
|
if (notHaveTwinMacro) {
|
80
91
|
return;
|
81
92
|
}
|
82
|
-
|
83
93
|
const twinConfig = {
|
84
94
|
twin: {
|
85
95
|
preset: supportCssInJsLibrary,
|
@@ -90,37 +100,23 @@ export default (({
|
|
90
100
|
if (Array.isArray(plugin) && plugin[0]) {
|
91
101
|
const pluginTarget = plugin[0];
|
92
102
|
let pluginOptions = plugin[1];
|
93
|
-
|
94
|
-
|
103
|
+
if (typeof pluginTarget === 'string' &&
|
104
|
+
// TODO: use babel chain
|
95
105
|
slash(pluginTarget).includes('compiled/babel-plugin-macros')) {
|
96
106
|
if (pluginOptions) {
|
97
107
|
pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
|
98
108
|
} else {
|
99
109
|
plugin.push(twinConfig);
|
100
110
|
}
|
101
|
-
|
102
111
|
return true;
|
103
112
|
}
|
104
113
|
}
|
105
|
-
|
106
114
|
return false;
|
107
115
|
});
|
108
116
|
}
|
109
|
-
|
110
117
|
}
|
111
118
|
};
|
112
|
-
},
|
113
|
-
|
114
|
-
moduleTailwindConfig() {
|
115
|
-
const modernConfig = api.useResolvedConfigContext();
|
116
|
-
const tailwindConfig = getTailwindConfig(modernConfig, {
|
117
|
-
pureConfig: {
|
118
|
-
content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
119
|
-
}
|
120
|
-
});
|
121
|
-
return require('tailwindcss')(tailwindConfig);
|
122
119
|
}
|
123
|
-
|
124
120
|
};
|
125
121
|
}
|
126
122
|
}));
|
@@ -1,9 +1,6 @@
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
2
|
-
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
|
-
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
-
|
7
4
|
import { lazyImport, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
|
8
5
|
export default (({
|
9
6
|
pluginName
|
@@ -11,34 +8,27 @@ export default (({
|
|
11
8
|
pluginName: '@modern-js/plugin-tailwindcss'
|
12
9
|
}) => ({
|
13
10
|
name: '@modern-js/plugin-design-token',
|
14
|
-
|
15
11
|
setup(api) {
|
16
12
|
let pluginsExportsUtils;
|
17
13
|
const resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
|
18
14
|
const PLUGIN_IDENTIFIER = 'designToken';
|
19
|
-
|
20
15
|
const getDesignTokens = userConfig => {
|
21
|
-
|
22
|
-
|
23
|
-
designSystem
|
24
|
-
}
|
25
|
-
} = userConfig; // TODO: Type to be filled
|
26
|
-
|
16
|
+
var _userConfig$source;
|
17
|
+
const designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
|
27
18
|
const tailwindcssConfig = {};
|
28
|
-
tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
|
19
|
+
tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
|
29
20
|
|
21
|
+
// not use default design token when designToken.defaultTheme is false or theme is false
|
30
22
|
if (!designSystem) {
|
31
23
|
tailwindcssConfig.presets = [];
|
32
|
-
}
|
33
|
-
|
24
|
+
}
|
34
25
|
|
26
|
+
// when only designSystem exist, need remove supportStyledComponents
|
35
27
|
if (designSystem) {
|
36
28
|
delete tailwindcssConfig.theme.supportStyledComponents;
|
37
29
|
}
|
38
|
-
|
39
30
|
return resolveConfig(tailwindcssConfig).theme || {};
|
40
31
|
};
|
41
|
-
|
42
32
|
return {
|
43
33
|
config() {
|
44
34
|
const appContext = api.useAppContext();
|
@@ -49,25 +39,21 @@ export default (({
|
|
49
39
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
50
40
|
}
|
51
41
|
},
|
52
|
-
tools: {
|
42
|
+
tools: {
|
43
|
+
// TODO: support less、scss、css vars
|
53
44
|
// less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
|
54
45
|
// sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
|
55
46
|
// postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
|
56
47
|
}
|
57
48
|
};
|
58
49
|
},
|
59
|
-
|
60
50
|
modifyEntryImports({
|
61
51
|
entrypoint,
|
62
52
|
imports
|
63
53
|
}) {
|
54
|
+
var _userConfig$source$de, _userConfig$source2;
|
64
55
|
const userConfig = api.useResolvedConfigContext();
|
65
|
-
const {
|
66
|
-
source: {
|
67
|
-
designSystem
|
68
|
-
}
|
69
|
-
} = userConfig;
|
70
|
-
|
56
|
+
const designSystem = (_userConfig$source$de = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
|
71
57
|
if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
|
72
58
|
const designTokens = getDesignTokens(userConfig);
|
73
59
|
imports.push({
|
@@ -80,52 +66,41 @@ export default (({
|
|
80
66
|
`
|
81
67
|
});
|
82
68
|
}
|
83
|
-
|
84
69
|
return {
|
85
70
|
entrypoint,
|
86
71
|
imports
|
87
72
|
};
|
88
73
|
},
|
89
|
-
|
90
74
|
modifyEntryRuntimePlugins({
|
91
75
|
entrypoint,
|
92
76
|
plugins
|
93
77
|
}) {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
} = api.useResolvedConfigContext();
|
78
|
+
var _userConfig$source$de2, _userConfig$source3;
|
79
|
+
const userConfig = api.useResolvedConfigContext();
|
80
|
+
const designSystem = (_userConfig$source$de2 = (_userConfig$source3 = userConfig.source) === null || _userConfig$source3 === void 0 ? void 0 : _userConfig$source3.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
|
99
81
|
let useSCThemeProvider = true;
|
100
|
-
|
101
82
|
if (designSystem) {
|
102
83
|
// when designSystem exist, designToken.styledComponents`s default value is false.
|
103
84
|
useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
|
104
85
|
}
|
105
|
-
|
106
86
|
if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
|
107
87
|
plugins.push({
|
108
88
|
name: PLUGIN_IDENTIFIER,
|
109
89
|
options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
|
110
90
|
});
|
111
91
|
}
|
112
|
-
|
113
92
|
return {
|
114
93
|
entrypoint,
|
115
94
|
plugins
|
116
95
|
};
|
117
96
|
},
|
118
|
-
|
119
97
|
validateSchema() {
|
120
98
|
// add source.designSystem.supportStyledComponents config
|
121
99
|
return PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
|
122
100
|
},
|
123
|
-
|
124
101
|
addRuntimeExports() {
|
125
102
|
pluginsExportsUtils.addExport(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
|
126
103
|
}
|
127
|
-
|
128
104
|
};
|
129
105
|
}
|
130
|
-
|
131
106
|
}));
|
@@ -2,17 +2,14 @@ export default (({
|
|
2
2
|
cssVarsHash: _cssVarsHash = {}
|
3
3
|
} = {}) => ({
|
4
4
|
postcssPlugin: 'postcss-replace-css-vars',
|
5
|
-
|
6
5
|
Declaration(decl) {
|
7
6
|
if (decl.value && typeof decl.value === 'string') {
|
8
7
|
decl.value = decl.value.replace(/--\S*/g, match => {
|
9
8
|
if (_cssVarsHash[match]) {
|
10
9
|
return _cssVarsHash[match];
|
11
10
|
}
|
12
|
-
|
13
11
|
return match;
|
14
12
|
});
|
15
13
|
}
|
16
14
|
}
|
17
|
-
|
18
15
|
}));
|
@@ -1,9 +1,6 @@
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
2
|
-
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
|
-
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
-
|
7
4
|
import hoistNonReactStatics from 'hoist-non-react-statics';
|
8
5
|
import React, { useContext } from 'react';
|
9
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -21,12 +18,10 @@ export default ((options = {}) => ({
|
|
21
18
|
useStyledComponentsThemeProvider = false,
|
22
19
|
useDesignTokenContext = false
|
23
20
|
} = options;
|
24
|
-
|
25
21
|
if (useStyledComponentsThemeProvider && useDesignTokenContext) {
|
26
22
|
const {
|
27
23
|
ThemeProvider
|
28
24
|
} = require('@modern-js/runtime/styled');
|
29
|
-
|
30
25
|
return /*#__PURE__*/_jsx(ThemeProvider, {
|
31
26
|
theme: token,
|
32
27
|
children: /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
|
@@ -38,7 +33,6 @@ export default ((options = {}) => ({
|
|
38
33
|
const {
|
39
34
|
ThemeProvider
|
40
35
|
} = require('@modern-js/runtime/styled');
|
41
|
-
|
42
36
|
return /*#__PURE__*/_jsx(ThemeProvider, {
|
43
37
|
theme: token,
|
44
38
|
children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
|
@@ -52,11 +46,9 @@ export default ((options = {}) => ({
|
|
52
46
|
return /*#__PURE__*/_jsx(App, _objectSpread({}, props));
|
53
47
|
}
|
54
48
|
};
|
55
|
-
|
56
49
|
return next({
|
57
50
|
App: hoistNonReactStatics(DesignTokenAppWrapper, App)
|
58
51
|
});
|
59
52
|
}
|
60
|
-
|
61
53
|
})
|
62
54
|
}));
|
@@ -1,20 +1,18 @@
|
|
1
1
|
import { applyOptionsChain, logger } from '@modern-js/utils';
|
2
2
|
import { merge, cloneDeep } from '@modern-js/utils/lodash';
|
3
|
-
|
4
3
|
const checkIfExistNotAllowKeys = tailwindConfig => {
|
5
4
|
const notAllowExistKeys = ['theme'];
|
6
5
|
let notAllowKey = '';
|
7
6
|
const ret = Object.keys(tailwindConfig).some(key => notAllowExistKeys.includes(key) && (notAllowKey = key));
|
8
7
|
return [ret, notAllowKey];
|
9
8
|
};
|
10
|
-
|
11
9
|
const getPureDesignSystemConfig = designSystemConfig => {
|
12
10
|
const pureDesignSystemConfig = cloneDeep(designSystemConfig);
|
13
11
|
delete pureDesignSystemConfig.supportStyledComponents;
|
14
12
|
return pureDesignSystemConfig;
|
15
13
|
};
|
16
|
-
|
17
14
|
const getTailwindConfig = (config, option = {}) => {
|
15
|
+
var _ref, _designSystem;
|
18
16
|
const purgeConfig = merge({
|
19
17
|
// TODO: how the operating environment is determined
|
20
18
|
enabled: process.env.NODE_ENV === 'production',
|
@@ -26,18 +24,16 @@ const getTailwindConfig = (config, option = {}) => {
|
|
26
24
|
purge: purgeConfig
|
27
25
|
};
|
28
26
|
const tailwindConfig = applyOptionsChain(defaultTailwindConfig, config.tools.tailwindcss || {});
|
29
|
-
const designSystem = getPureDesignSystemConfig(config.source.designSystem
|
27
|
+
const designSystem = getPureDesignSystemConfig((_ref = (_designSystem = config.designSystem) !== null && _designSystem !== void 0 ? _designSystem : config.source.designSystem) !== null && _ref !== void 0 ? _ref : {});
|
30
28
|
const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
|
31
|
-
|
32
29
|
if (exist) {
|
33
|
-
logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
|
34
|
-
|
30
|
+
logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
|
31
|
+
// eslint-disable-next-line no-process-exit
|
35
32
|
process.exit(0);
|
36
|
-
}
|
37
|
-
|
33
|
+
}
|
38
34
|
|
35
|
+
// Because there is no default theme configuration
|
39
36
|
tailwindConfig.theme = designSystem || {};
|
40
37
|
return tailwindConfig;
|
41
38
|
};
|
42
|
-
|
43
39
|
export { getTailwindConfig };
|
File without changes
|
package/dist/js/modern/utils.js
CHANGED
@@ -25,10 +25,8 @@ export const checkTwinMacroNotExist = async appDirectory => {
|
|
25
25
|
const packageJson = (await fs.readJSON(path.join(appDirectory, 'package.json'), {
|
26
26
|
throws: false
|
27
27
|
})) || {};
|
28
|
-
|
29
28
|
if (typeof packageJson.dependencies === 'object' && packageJson.dependencies[depName] || typeof packageJson.devDependencies === 'object' && packageJson.devDependencies[depName]) {
|
30
29
|
return false;
|
31
30
|
}
|
32
|
-
|
33
31
|
return true;
|
34
32
|
};
|