@modern-js/plugin-tailwindcss 2.13.3 → 2.13.5-beta.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 +7 -0
- package/dist/cjs/cli.js +4 -0
- package/dist/esm/cli.js +4 -0
- package/dist/esm-node/cli.js +4 -0
- package/dist/js/modern/cli.js +174 -0
- package/dist/js/modern/design-token/cli/index.js +110 -0
- package/dist/js/modern/design-token/index.js +5 -0
- package/dist/js/modern/design-token/postcss-plugin/index.js +18 -0
- package/dist/js/modern/design-token/runtime/index.js +6 -0
- package/dist/js/modern/design-token/runtime/plugin.js +66 -0
- package/dist/js/modern/index.js +4 -0
- package/dist/js/modern/tailwind.js +45 -0
- package/dist/js/modern/types.js +0 -0
- package/dist/js/modern/utils.js +86 -0
- package/dist/js/node/cli.js +190 -0
- package/dist/js/node/design-token/cli/index.js +125 -0
- package/dist/js/node/design-token/index.js +33 -0
- package/dist/js/node/design-token/postcss-plugin/index.js +39 -0
- package/dist/js/node/design-token/runtime/index.js +34 -0
- package/dist/js/node/design-token/runtime/plugin.js +94 -0
- package/dist/js/node/index.js +31 -0
- package/dist/js/node/tailwind.js +68 -0
- package/dist/js/node/types.js +15 -0
- package/dist/js/node/utils.js +119 -0
- package/dist/js/treeshaking/cli.js +268 -0
- package/dist/js/treeshaking/design-token/cli/index.js +118 -0
- package/dist/js/treeshaking/design-token/index.js +3 -0
- package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -0
- package/dist/js/treeshaking/design-token/runtime/index.js +4 -0
- package/dist/js/treeshaking/design-token/runtime/plugin.js +78 -0
- package/dist/js/treeshaking/index.js +2 -0
- package/dist/js/treeshaking/tailwind.js +91 -0
- package/dist/js/treeshaking/types.js +1 -0
- package/dist/js/treeshaking/utils.js +194 -0
- package/package.json +10 -10
@@ -0,0 +1,91 @@
|
|
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
|
+
];
|
61
|
+
};
|
62
|
+
var getPureDesignSystemConfig = function(designSystemConfig) {
|
63
|
+
var pureDesignSystemConfig = cloneDeep(designSystemConfig);
|
64
|
+
delete pureDesignSystemConfig.supportStyledComponents;
|
65
|
+
return pureDesignSystemConfig;
|
66
|
+
};
|
67
|
+
var getTailwindConfig = function(tailwindVersion, tailwindcss, designSystem) {
|
68
|
+
var option = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
69
|
+
var purgeConfig = merge({
|
70
|
+
enabled: process.env.NODE_ENV === "production",
|
71
|
+
layers: [
|
72
|
+
"utilities"
|
73
|
+
],
|
74
|
+
content: []
|
75
|
+
}, option.pureConfig || {});
|
76
|
+
var defaultTailwindConfig = tailwindVersion === "3" ? {
|
77
|
+
content: purgeConfig.content
|
78
|
+
} : {
|
79
|
+
purge: purgeConfig
|
80
|
+
};
|
81
|
+
var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
|
82
|
+
var designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
|
83
|
+
var _checkIfExistNotAllowKeys = _slicedToArray(checkIfExistNotAllowKeys(tailwindConfig), 2), exist = _checkIfExistNotAllowKeys[0], key = _checkIfExistNotAllowKeys[1];
|
84
|
+
if (exist) {
|
85
|
+
logger.error("should not exist '".concat(key, "' on tools.tailwindcss, please remove it"));
|
86
|
+
process.exit(0);
|
87
|
+
}
|
88
|
+
tailwindConfig.theme = designSystemConfig || {};
|
89
|
+
return tailwindConfig;
|
90
|
+
};
|
91
|
+
export { getTailwindConfig };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
@@ -0,0 +1,194 @@
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
2
|
+
try {
|
3
|
+
var info = gen[key](arg);
|
4
|
+
var value = info.value;
|
5
|
+
} catch (error) {
|
6
|
+
reject(error);
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
if (info.done) {
|
10
|
+
resolve(value);
|
11
|
+
} else {
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
function _asyncToGenerator(fn) {
|
16
|
+
return function() {
|
17
|
+
var self = this, args = arguments;
|
18
|
+
return new Promise(function(resolve, reject) {
|
19
|
+
var gen = fn.apply(self, args);
|
20
|
+
function _next(value) {
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
22
|
+
}
|
23
|
+
function _throw(err) {
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
25
|
+
}
|
26
|
+
_next(undefined);
|
27
|
+
});
|
28
|
+
};
|
29
|
+
}
|
30
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
31
|
+
var f, y, t, g, _ = {
|
32
|
+
label: 0,
|
33
|
+
sent: function() {
|
34
|
+
if (t[0] & 1) throw t[1];
|
35
|
+
return t[1];
|
36
|
+
},
|
37
|
+
trys: [],
|
38
|
+
ops: []
|
39
|
+
};
|
40
|
+
return(g = {
|
41
|
+
next: verb(0),
|
42
|
+
"throw": verb(1),
|
43
|
+
"return": verb(2)
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
45
|
+
return this;
|
46
|
+
}), g);
|
47
|
+
function verb(n) {
|
48
|
+
return function(v) {
|
49
|
+
return step([
|
50
|
+
n,
|
51
|
+
v
|
52
|
+
]);
|
53
|
+
};
|
54
|
+
}
|
55
|
+
function step(op) {
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
57
|
+
while(_)try {
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
59
|
+
if (y = 0, t) op = [
|
60
|
+
op[0] & 2,
|
61
|
+
t.value
|
62
|
+
];
|
63
|
+
switch(op[0]){
|
64
|
+
case 0:
|
65
|
+
case 1:
|
66
|
+
t = op;
|
67
|
+
break;
|
68
|
+
case 4:
|
69
|
+
_.label++;
|
70
|
+
return {
|
71
|
+
value: op[1],
|
72
|
+
done: false
|
73
|
+
};
|
74
|
+
case 5:
|
75
|
+
_.label++;
|
76
|
+
y = op[1];
|
77
|
+
op = [
|
78
|
+
0
|
79
|
+
];
|
80
|
+
continue;
|
81
|
+
case 7:
|
82
|
+
op = _.ops.pop();
|
83
|
+
_.trys.pop();
|
84
|
+
continue;
|
85
|
+
default:
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
87
|
+
_ = 0;
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
91
|
+
_.label = op[1];
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
95
|
+
_.label = t[1];
|
96
|
+
t = op;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
if (t && _.label < t[2]) {
|
100
|
+
_.label = t[2];
|
101
|
+
_.ops.push(op);
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
if (t[2]) _.ops.pop();
|
105
|
+
_.trys.pop();
|
106
|
+
continue;
|
107
|
+
}
|
108
|
+
op = body.call(thisArg, _);
|
109
|
+
} catch (e) {
|
110
|
+
op = [
|
111
|
+
6,
|
112
|
+
e
|
113
|
+
];
|
114
|
+
y = 0;
|
115
|
+
} finally{
|
116
|
+
f = t = 0;
|
117
|
+
}
|
118
|
+
if (op[0] & 5) throw op[1];
|
119
|
+
return {
|
120
|
+
value: op[0] ? op[1] : void 0,
|
121
|
+
done: true
|
122
|
+
};
|
123
|
+
}
|
124
|
+
};
|
125
|
+
import path from "path";
|
126
|
+
import { fs } from "@modern-js/utils";
|
127
|
+
var template = function(configPath) {
|
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
|
+
};
|
130
|
+
var TWIN_MACRO_NAME = "twin.macro";
|
131
|
+
var checkTwinMacroExist = function() {
|
132
|
+
var _ref = _asyncToGenerator(function(appDirectory) {
|
133
|
+
var packageJson;
|
134
|
+
return __generator(this, function(_state) {
|
135
|
+
switch(_state.label){
|
136
|
+
case 0:
|
137
|
+
return [
|
138
|
+
4,
|
139
|
+
fs.readJSON(path.join(appDirectory, "package.json"), {
|
140
|
+
throws: false
|
141
|
+
})
|
142
|
+
];
|
143
|
+
case 1:
|
144
|
+
packageJson = _state.sent() || {};
|
145
|
+
return [
|
146
|
+
2,
|
147
|
+
Boolean(typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME])
|
148
|
+
];
|
149
|
+
}
|
150
|
+
});
|
151
|
+
});
|
152
|
+
return function checkTwinMacroExist(appDirectory) {
|
153
|
+
return _ref.apply(this, arguments);
|
154
|
+
};
|
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
|
+
};
|
169
|
+
function getTailwindPath(appDirectory) {
|
170
|
+
try {
|
171
|
+
return require.resolve("tailwindcss", {
|
172
|
+
paths: [
|
173
|
+
appDirectory,
|
174
|
+
__dirname
|
175
|
+
]
|
176
|
+
});
|
177
|
+
} catch (err) {
|
178
|
+
return "tailwindcss";
|
179
|
+
}
|
180
|
+
}
|
181
|
+
function getTailwindVersion(appDirectory) {
|
182
|
+
try {
|
183
|
+
var packageJsonPath = require.resolve("tailwindcss/package.json", {
|
184
|
+
paths: [
|
185
|
+
appDirectory,
|
186
|
+
__dirname
|
187
|
+
]
|
188
|
+
});
|
189
|
+
return require(packageJsonPath).version.split(".")[0];
|
190
|
+
} catch (err) {
|
191
|
+
return "3";
|
192
|
+
}
|
193
|
+
}
|
194
|
+
export { checkTwinMacroExist, getTailwindPath, getTailwindVersion, getTwinMacroMajorVersion, template };
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.13.
|
14
|
+
"version": "2.13.5-beta.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/cjs/index.js",
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"@babel/runtime": "^7.18.0",
|
46
46
|
"babel-plugin-macros": "3.1.0",
|
47
47
|
"hoist-non-react-statics": "^3.3.2",
|
48
|
-
"@modern-js/utils": "2.13.
|
48
|
+
"@modern-js/utils": "2.13.4"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
51
|
"@types/jest": "^29",
|
@@ -55,17 +55,17 @@
|
|
55
55
|
"jest": "^29",
|
56
56
|
"react": "^18",
|
57
57
|
"postcss": "8.4.21",
|
58
|
-
"@modern-js/core": "2.13.
|
59
|
-
"@modern-js/module-tools": "2.13.
|
60
|
-
"@modern-js/
|
61
|
-
"@modern-js/
|
62
|
-
"@scripts/build": "2.13.
|
63
|
-
"@
|
64
|
-
"@
|
58
|
+
"@modern-js/core": "2.13.4",
|
59
|
+
"@modern-js/module-tools": "2.13.4",
|
60
|
+
"@modern-js/types": "2.13.4",
|
61
|
+
"@modern-js/runtime": "2.13.4",
|
62
|
+
"@scripts/build": "2.13.4",
|
63
|
+
"@scripts/jest-config": "2.13.4",
|
64
|
+
"@modern-js/app-tools": "2.13.4"
|
65
65
|
},
|
66
66
|
"peerDependencies": {
|
67
67
|
"tailwindcss": ">= 2.0.0 || >= 3.0.0",
|
68
|
-
"@modern-js/runtime": "^2.13.
|
68
|
+
"@modern-js/runtime": "^2.13.4"
|
69
69
|
},
|
70
70
|
"peerDependenciesMeta": {
|
71
71
|
"@modern-js/runtime": {
|