@modern-js/plugin-tailwindcss 2.2.0 → 2.4.0
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 +25 -0
- package/README.md +14 -18
- package/dist/js/modern/cli.js +41 -30
- package/dist/js/modern/utils.js +14 -2
- package/dist/js/node/cli.js +39 -29
- package/dist/js/node/utils.js +15 -2
- package/dist/js/treeshaking/cli.js +29 -19
- package/dist/js/treeshaking/utils.js +17 -4
- package/dist/types/utils.d.ts +1 -0
- package/package.json +11 -11
- package/dist/js/modern/design-token/global.d.js +0 -0
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/node/design-token/global.d.js +0 -0
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/treeshaking/design-token/global.d.js +0 -1
- package/dist/js/treeshaking/modern-app.env.d.js +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
+
## 2.4.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 98a2733: fix(tailwind): fix webpack cache not work when using twin.macro
|
8
|
+
|
9
|
+
fix(tailwind): 修复使用 twin.macro 时 webpack 缓存不生效的问题
|
10
|
+
|
11
|
+
- Updated dependencies [98a2733]
|
12
|
+
- Updated dependencies [9e907ec]
|
13
|
+
- Updated dependencies [8c2db5f]
|
14
|
+
- @modern-js/utils@2.4.0
|
15
|
+
- @modern-js/runtime@2.4.0
|
16
|
+
|
17
|
+
## 2.3.0
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- Updated dependencies [fd5a3ed]
|
22
|
+
- Updated dependencies [6ca1c0b]
|
23
|
+
- Updated dependencies [89b6739]
|
24
|
+
- Updated dependencies [b4dd017]
|
25
|
+
- @modern-js/utils@2.3.0
|
26
|
+
- @modern-js/runtime@2.3.0
|
27
|
+
|
3
28
|
## 2.2.0
|
4
29
|
|
5
30
|
### Patch Changes
|
package/README.md
CHANGED
@@ -1,30 +1,26 @@
|
|
1
|
-
|
2
1
|
<p align="center">
|
3
2
|
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
4
3
|
</p>
|
4
|
+
|
5
|
+
<h1 align="center">Modern.js</h1>
|
6
|
+
|
5
7
|
<p align="center">
|
6
|
-
|
7
|
-
<br/>
|
8
|
-
<a href="https://modernjs.dev" target="blank">
|
9
|
-
modernjs.dev
|
10
|
-
</a>
|
11
|
-
</p>
|
12
|
-
<p align="center">
|
13
|
-
The meta-framework suite designed from scratch for frontend-focused modern web development
|
8
|
+
A Progressive React Framework for modern web development.
|
14
9
|
</p>
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
|
11
|
+
## Getting Started
|
19
12
|
|
20
|
-
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
|
21
14
|
|
22
|
-
##
|
15
|
+
## Documentation
|
23
16
|
|
24
|
-
- [
|
25
|
-
- [
|
26
|
-
- [API References](https://modernjs.dev/docs/apis)
|
17
|
+
- [English Documentation](https://modernjs.dev/en/)
|
18
|
+
- [中文文档](https://modernjs.dev)
|
27
19
|
|
28
20
|
## Contributing
|
29
21
|
|
30
|
-
|
22
|
+
Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
|
package/dist/js/modern/cli.js
CHANGED
@@ -33,7 +33,8 @@ import {
|
|
33
33
|
template,
|
34
34
|
checkTwinMacroExist,
|
35
35
|
getTailwindPath,
|
36
|
-
getTailwindVersion
|
36
|
+
getTailwindVersion,
|
37
|
+
getTwinMacroMajorVersion
|
37
38
|
} from "./utils";
|
38
39
|
const supportCssInJsLibrary = "styled-components";
|
39
40
|
const getRandomTwConfigFileName = (internalDirectory) => {
|
@@ -71,43 +72,52 @@ var cli_default = ({ pluginName } = {
|
|
71
72
|
];
|
72
73
|
return {
|
73
74
|
prepare() {
|
74
|
-
if (
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
75
|
+
if (haveTwinMacro) {
|
76
|
+
const twinMajorVersion = getTwinMacroMajorVersion(appDirectory);
|
77
|
+
const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
|
78
|
+
if (useConfigPath) {
|
79
|
+
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
80
|
+
const globPattern = slash(
|
81
|
+
path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs")
|
82
|
+
);
|
83
|
+
const files = globby.sync(globPattern, {
|
84
|
+
absolute: true
|
85
|
+
});
|
86
|
+
if (files.length > 0) {
|
87
|
+
fs.writeFileSync(
|
88
|
+
internalTwConfigPath,
|
89
|
+
template(files[files.length - 1]),
|
90
|
+
"utf-8"
|
91
|
+
);
|
92
|
+
}
|
93
|
+
}
|
90
94
|
}
|
91
95
|
},
|
92
96
|
validateSchema() {
|
93
97
|
return PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
|
94
98
|
},
|
95
99
|
config() {
|
100
|
+
let tailwindConfig;
|
101
|
+
const initTailwindConfig = () => {
|
102
|
+
var _a, _b;
|
103
|
+
if (!tailwindConfig) {
|
104
|
+
const modernConfig = api.useResolvedConfigContext();
|
105
|
+
tailwindConfig = getTailwindConfig(
|
106
|
+
tailwindVersion,
|
107
|
+
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
108
|
+
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
109
|
+
{
|
110
|
+
pureConfig: {
|
111
|
+
content: defaultContent
|
112
|
+
}
|
113
|
+
}
|
114
|
+
);
|
115
|
+
}
|
116
|
+
};
|
96
117
|
return {
|
97
118
|
tools: {
|
98
119
|
postcss: (config) => {
|
99
|
-
|
100
|
-
const modernConfig = api.useResolvedConfigContext();
|
101
|
-
const tailwindConfig = getTailwindConfig(
|
102
|
-
tailwindVersion,
|
103
|
-
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
104
|
-
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
105
|
-
{
|
106
|
-
pureConfig: {
|
107
|
-
content: defaultContent
|
108
|
-
}
|
109
|
-
}
|
110
|
-
);
|
120
|
+
initTailwindConfig();
|
111
121
|
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
112
122
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
113
123
|
config.postcssOptions.plugins.push(tailwindPlugin);
|
@@ -117,13 +127,14 @@ var cli_default = ({ pluginName } = {
|
|
117
127
|
},
|
118
128
|
babel(_, { addPlugins }) {
|
119
129
|
if (haveTwinMacro) {
|
130
|
+
initTailwindConfig();
|
120
131
|
addPlugins([
|
121
132
|
[
|
122
133
|
require.resolve("babel-plugin-macros"),
|
123
134
|
{
|
124
135
|
twin: {
|
125
136
|
preset: supportCssInJsLibrary,
|
126
|
-
config: internalTwConfigPath
|
137
|
+
config: internalTwConfigPath || tailwindConfig
|
127
138
|
}
|
128
139
|
}
|
129
140
|
]
|
package/dist/js/modern/utils.js
CHANGED
@@ -40,15 +40,26 @@ module.exports = {
|
|
40
40
|
...tailwindcss,
|
41
41
|
};
|
42
42
|
`;
|
43
|
+
const TWIN_MACRO_NAME = "twin.macro";
|
43
44
|
const checkTwinMacroExist = (appDirectory) => __async(void 0, null, function* () {
|
44
|
-
const depName = "twin.macro";
|
45
45
|
const packageJson = (yield fs.readJSON(path.join(appDirectory, "package.json"), {
|
46
46
|
throws: false
|
47
47
|
})) || {};
|
48
48
|
return Boolean(
|
49
|
-
typeof packageJson.dependencies === "object" && packageJson.dependencies[
|
49
|
+
typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
|
50
50
|
);
|
51
51
|
});
|
52
|
+
const getTwinMacroMajorVersion = (appDirectory) => {
|
53
|
+
try {
|
54
|
+
const pkgJsonPath = require.resolve(`${TWIN_MACRO_NAME}/package.json`, {
|
55
|
+
paths: [appDirectory]
|
56
|
+
});
|
57
|
+
const { version } = require(pkgJsonPath);
|
58
|
+
return Number(version.split(".")[0]);
|
59
|
+
} catch (err) {
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
};
|
52
63
|
function getTailwindPath(appDirectory) {
|
53
64
|
try {
|
54
65
|
return require.resolve("tailwindcss", { paths: [appDirectory, __dirname] });
|
@@ -70,5 +81,6 @@ export {
|
|
70
81
|
checkTwinMacroExist,
|
71
82
|
getTailwindPath,
|
72
83
|
getTailwindVersion,
|
84
|
+
getTwinMacroMajorVersion,
|
73
85
|
template
|
74
86
|
};
|
package/dist/js/node/cli.js
CHANGED
@@ -88,43 +88,52 @@ var cli_default = ({ pluginName } = {
|
|
88
88
|
];
|
89
89
|
return {
|
90
90
|
prepare() {
|
91
|
-
if (
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
91
|
+
if (haveTwinMacro) {
|
92
|
+
const twinMajorVersion = (0, import_utils2.getTwinMacroMajorVersion)(appDirectory);
|
93
|
+
const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
|
94
|
+
if (useConfigPath) {
|
95
|
+
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
96
|
+
const globPattern = (0, import_utils.slash)(
|
97
|
+
import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR, "*.cjs")
|
98
|
+
);
|
99
|
+
const files = import_utils.globby.sync(globPattern, {
|
100
|
+
absolute: true
|
101
|
+
});
|
102
|
+
if (files.length > 0) {
|
103
|
+
import_utils.fs.writeFileSync(
|
104
|
+
internalTwConfigPath,
|
105
|
+
(0, import_utils2.template)(files[files.length - 1]),
|
106
|
+
"utf-8"
|
107
|
+
);
|
108
|
+
}
|
109
|
+
}
|
107
110
|
}
|
108
111
|
},
|
109
112
|
validateSchema() {
|
110
113
|
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
|
111
114
|
},
|
112
115
|
config() {
|
116
|
+
let tailwindConfig;
|
117
|
+
const initTailwindConfig = () => {
|
118
|
+
var _a, _b;
|
119
|
+
if (!tailwindConfig) {
|
120
|
+
const modernConfig = api.useResolvedConfigContext();
|
121
|
+
tailwindConfig = (0, import_tailwind.getTailwindConfig)(
|
122
|
+
tailwindVersion,
|
123
|
+
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
124
|
+
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
125
|
+
{
|
126
|
+
pureConfig: {
|
127
|
+
content: defaultContent
|
128
|
+
}
|
129
|
+
}
|
130
|
+
);
|
131
|
+
}
|
132
|
+
};
|
113
133
|
return {
|
114
134
|
tools: {
|
115
135
|
postcss: (config) => {
|
116
|
-
|
117
|
-
const modernConfig = api.useResolvedConfigContext();
|
118
|
-
const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
|
119
|
-
tailwindVersion,
|
120
|
-
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
121
|
-
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
122
|
-
{
|
123
|
-
pureConfig: {
|
124
|
-
content: defaultContent
|
125
|
-
}
|
126
|
-
}
|
127
|
-
);
|
136
|
+
initTailwindConfig();
|
128
137
|
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
129
138
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
130
139
|
config.postcssOptions.plugins.push(tailwindPlugin);
|
@@ -134,13 +143,14 @@ var cli_default = ({ pluginName } = {
|
|
134
143
|
},
|
135
144
|
babel(_, { addPlugins }) {
|
136
145
|
if (haveTwinMacro) {
|
146
|
+
initTailwindConfig();
|
137
147
|
addPlugins([
|
138
148
|
[
|
139
149
|
require.resolve("babel-plugin-macros"),
|
140
150
|
{
|
141
151
|
twin: {
|
142
152
|
preset: supportCssInJsLibrary,
|
143
|
-
config: internalTwConfigPath
|
153
|
+
config: internalTwConfigPath || tailwindConfig
|
144
154
|
}
|
145
155
|
}
|
146
156
|
]
|
package/dist/js/node/utils.js
CHANGED
@@ -46,6 +46,7 @@ __export(utils_exports, {
|
|
46
46
|
checkTwinMacroExist: () => checkTwinMacroExist,
|
47
47
|
getTailwindPath: () => getTailwindPath,
|
48
48
|
getTailwindVersion: () => getTailwindVersion,
|
49
|
+
getTwinMacroMajorVersion: () => getTwinMacroMajorVersion,
|
49
50
|
template: () => template
|
50
51
|
});
|
51
52
|
module.exports = __toCommonJS(utils_exports);
|
@@ -71,15 +72,26 @@ module.exports = {
|
|
71
72
|
...tailwindcss,
|
72
73
|
};
|
73
74
|
`;
|
75
|
+
const TWIN_MACRO_NAME = "twin.macro";
|
74
76
|
const checkTwinMacroExist = (appDirectory) => __async(void 0, null, function* () {
|
75
|
-
const depName = "twin.macro";
|
76
77
|
const packageJson = (yield import_utils.fs.readJSON(import_path.default.join(appDirectory, "package.json"), {
|
77
78
|
throws: false
|
78
79
|
})) || {};
|
79
80
|
return Boolean(
|
80
|
-
typeof packageJson.dependencies === "object" && packageJson.dependencies[
|
81
|
+
typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
|
81
82
|
);
|
82
83
|
});
|
84
|
+
const getTwinMacroMajorVersion = (appDirectory) => {
|
85
|
+
try {
|
86
|
+
const pkgJsonPath = require.resolve(`${TWIN_MACRO_NAME}/package.json`, {
|
87
|
+
paths: [appDirectory]
|
88
|
+
});
|
89
|
+
const { version } = require(pkgJsonPath);
|
90
|
+
return Number(version.split(".")[0]);
|
91
|
+
} catch (err) {
|
92
|
+
return null;
|
93
|
+
}
|
94
|
+
};
|
83
95
|
function getTailwindPath(appDirectory) {
|
84
96
|
try {
|
85
97
|
return require.resolve("tailwindcss", { paths: [appDirectory, __dirname] });
|
@@ -102,5 +114,6 @@ function getTailwindVersion(appDirectory) {
|
|
102
114
|
checkTwinMacroExist,
|
103
115
|
getTailwindPath,
|
104
116
|
getTailwindVersion,
|
117
|
+
getTwinMacroMajorVersion,
|
105
118
|
template
|
106
119
|
});
|
@@ -126,7 +126,7 @@ import path from "path";
|
|
126
126
|
import { PLUGIN_SCHEMAS, fs, CONFIG_CACHE_DIR, globby, nanoid, slash } from "@modern-js/utils";
|
127
127
|
import designTokenPlugin from "./design-token/cli";
|
128
128
|
import { getTailwindConfig } from "./tailwind";
|
129
|
-
import { template, checkTwinMacroExist, getTailwindPath, getTailwindVersion } from "./utils";
|
129
|
+
import { template, checkTwinMacroExist, getTailwindPath, getTailwindVersion, getTwinMacroMajorVersion } from "./utils";
|
130
130
|
var supportCssInJsLibrary = "styled-components";
|
131
131
|
var getRandomTwConfigFileName = function(internalDirectory) {
|
132
132
|
return slash(path.join(internalDirectory, "tailwind.config.".concat(Date.now(), ".").concat(nanoid(), ".js")));
|
@@ -172,32 +172,41 @@ var cli_default = function() {
|
|
172
172
|
2,
|
173
173
|
{
|
174
174
|
prepare: function prepare() {
|
175
|
-
if (
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
175
|
+
if (haveTwinMacro) {
|
176
|
+
var twinMajorVersion = getTwinMacroMajorVersion(appDirectory);
|
177
|
+
var useConfigPath = twinMajorVersion && twinMajorVersion < 3;
|
178
|
+
if (useConfigPath) {
|
179
|
+
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
180
|
+
var globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs"));
|
181
|
+
var files = globby.sync(globPattern, {
|
182
|
+
absolute: true
|
183
|
+
});
|
184
|
+
if (files.length > 0) {
|
185
|
+
fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), "utf-8");
|
186
|
+
}
|
187
|
+
}
|
185
188
|
}
|
186
189
|
},
|
187
190
|
validateSchema: function validateSchema() {
|
188
191
|
return PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
|
189
192
|
},
|
190
193
|
config: function config() {
|
194
|
+
var tailwindConfig;
|
195
|
+
var initTailwindConfig = function() {
|
196
|
+
if (!tailwindConfig) {
|
197
|
+
var ref, ref1;
|
198
|
+
var modernConfig = api.useResolvedConfigContext();
|
199
|
+
tailwindConfig = getTailwindConfig(tailwindVersion, modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.tools) === null || ref === void 0 ? void 0 : ref.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (ref1 = modernConfig.source) === null || ref1 === void 0 ? void 0 : ref1.designSystem, {
|
200
|
+
pureConfig: {
|
201
|
+
content: defaultContent
|
202
|
+
}
|
203
|
+
});
|
204
|
+
}
|
205
|
+
};
|
191
206
|
return {
|
192
207
|
tools: {
|
193
208
|
postcss: function(config) {
|
194
|
-
|
195
|
-
var modernConfig = api.useResolvedConfigContext();
|
196
|
-
var tailwindConfig = getTailwindConfig(tailwindVersion, modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.tools) === null || ref === void 0 ? void 0 : ref.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (ref1 = modernConfig.source) === null || ref1 === void 0 ? void 0 : ref1.designSystem, {
|
197
|
-
pureConfig: {
|
198
|
-
content: defaultContent
|
199
|
-
}
|
200
|
-
});
|
209
|
+
initTailwindConfig();
|
201
210
|
var tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
202
211
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
203
212
|
config.postcssOptions.plugins.push(tailwindPlugin);
|
@@ -210,13 +219,14 @@ var cli_default = function() {
|
|
210
219
|
babel: function babel(_, param) {
|
211
220
|
var addPlugins = param.addPlugins;
|
212
221
|
if (haveTwinMacro) {
|
222
|
+
initTailwindConfig();
|
213
223
|
addPlugins([
|
214
224
|
[
|
215
225
|
require.resolve("babel-plugin-macros"),
|
216
226
|
{
|
217
227
|
twin: {
|
218
228
|
preset: supportCssInJsLibrary,
|
219
|
-
config: internalTwConfigPath
|
229
|
+
config: internalTwConfigPath || tailwindConfig
|
220
230
|
}
|
221
231
|
}
|
222
232
|
]
|
@@ -127,13 +127,13 @@ import { fs } from "@modern-js/utils";
|
|
127
127
|
var template = function(configPath) {
|
128
128
|
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");
|
129
129
|
};
|
130
|
+
var TWIN_MACRO_NAME = "twin.macro";
|
130
131
|
var checkTwinMacroExist = function() {
|
131
132
|
var _ref = _asyncToGenerator(function(appDirectory) {
|
132
|
-
var
|
133
|
+
var packageJson;
|
133
134
|
return __generator(this, function(_state) {
|
134
135
|
switch(_state.label){
|
135
136
|
case 0:
|
136
|
-
depName = "twin.macro";
|
137
137
|
return [
|
138
138
|
4,
|
139
139
|
fs.readJSON(path.join(appDirectory, "package.json"), {
|
@@ -144,7 +144,7 @@ var checkTwinMacroExist = function() {
|
|
144
144
|
packageJson = _state.sent() || {};
|
145
145
|
return [
|
146
146
|
2,
|
147
|
-
Boolean(typeof packageJson.dependencies === "object" && packageJson.dependencies[
|
147
|
+
Boolean(typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME])
|
148
148
|
];
|
149
149
|
}
|
150
150
|
});
|
@@ -153,6 +153,19 @@ var checkTwinMacroExist = function() {
|
|
153
153
|
return _ref.apply(this, arguments);
|
154
154
|
};
|
155
155
|
}();
|
156
|
+
var getTwinMacroMajorVersion = function(appDirectory) {
|
157
|
+
try {
|
158
|
+
var pkgJsonPath = require.resolve("".concat(TWIN_MACRO_NAME, "/package.json"), {
|
159
|
+
paths: [
|
160
|
+
appDirectory
|
161
|
+
]
|
162
|
+
});
|
163
|
+
var version = require(pkgJsonPath).version;
|
164
|
+
return Number(version.split(".")[0]);
|
165
|
+
} catch (err) {
|
166
|
+
return null;
|
167
|
+
}
|
168
|
+
};
|
156
169
|
function getTailwindPath(appDirectory) {
|
157
170
|
try {
|
158
171
|
return require.resolve("tailwindcss", {
|
@@ -178,4 +191,4 @@ function getTailwindVersion(appDirectory) {
|
|
178
191
|
return "3";
|
179
192
|
}
|
180
193
|
}
|
181
|
-
export { checkTwinMacroExist, getTailwindPath, getTailwindVersion, template };
|
194
|
+
export { checkTwinMacroExist, getTailwindPath, getTailwindVersion, getTwinMacroMajorVersion, template };
|
package/dist/types/utils.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export declare const template: (configPath: string) => string;
|
2
2
|
export declare const checkTwinMacroExist: (appDirectory: string) => Promise<boolean>;
|
3
|
+
export declare const getTwinMacroMajorVersion: (appDirectory: string) => number | null;
|
3
4
|
export declare function getTailwindPath(appDirectory: string): string;
|
4
5
|
export declare function getTailwindVersion(appDirectory: string): '2' | '3';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modern-js/plugin-tailwindcss",
|
3
|
-
"description": "
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
4
4
|
"homepage": "https://modernjs.dev",
|
5
5
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|
6
6
|
"repository": "modern-js-dev/modern.js",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.4.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"@babel/runtime": "^7.18.0",
|
47
47
|
"babel-plugin-macros": "3.1.0",
|
48
48
|
"hoist-non-react-statics": "^3.3.2",
|
49
|
-
"@modern-js/utils": "2.
|
49
|
+
"@modern-js/utils": "2.4.0"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@types/jest": "^27",
|
@@ -56,17 +56,17 @@
|
|
56
56
|
"jest": "^27",
|
57
57
|
"react": "^18",
|
58
58
|
"postcss": "8.4.21",
|
59
|
-
"@modern-js/core": "2.
|
60
|
-
"@modern-js/module-tools": "2.
|
61
|
-
"@modern-js/runtime": "2.
|
62
|
-
"@modern-js/types": "2.
|
63
|
-
"@scripts/build": "2.
|
64
|
-
"@modern-js/app-tools": "2.
|
65
|
-
"@scripts/jest-config": "2.
|
59
|
+
"@modern-js/core": "2.4.0",
|
60
|
+
"@modern-js/module-tools": "2.4.0",
|
61
|
+
"@modern-js/runtime": "2.4.0",
|
62
|
+
"@modern-js/types": "2.4.0",
|
63
|
+
"@scripts/build": "2.4.0",
|
64
|
+
"@modern-js/app-tools": "2.4.0",
|
65
|
+
"@scripts/jest-config": "2.4.0"
|
66
66
|
},
|
67
67
|
"peerDependencies": {
|
68
68
|
"tailwindcss": ">= 2.0.0 || >= 3.0.0",
|
69
|
-
"@modern-js/runtime": "^2.
|
69
|
+
"@modern-js/runtime": "^2.4.0"
|
70
70
|
},
|
71
71
|
"peerDependenciesMeta": {
|
72
72
|
"@modern-js/runtime": {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|