@modern-js/plugin-tailwindcss 2.15.0 → 2.17.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/dist/cjs/cli.js +130 -158
- package/dist/cjs/design-token/cli/index.js +93 -111
- package/dist/cjs/design-token/index.js +26 -36
- package/dist/cjs/design-token/postcss-plugin/index.js +8 -26
- package/dist/cjs/design-token/runtime/index.js +27 -37
- package/dist/cjs/design-token/runtime/plugin.js +90 -52
- package/dist/cjs/index.js +13 -34
- package/dist/cjs/tailwind.js +33 -52
- package/dist/cjs/types.js +4 -15
- package/dist/cjs/utils.js +36 -49
- package/dist/esm/cli.js +264 -253
- package/dist/esm/design-token/cli/index.js +112 -113
- package/dist/esm/design-token/index.js +1 -2
- package/dist/esm/design-token/postcss-plugin/index.js +17 -17
- package/dist/esm/design-token/runtime/index.js +1 -2
- package/dist/esm/design-token/runtime/plugin.js +71 -71
- package/dist/esm/index.js +1 -2
- package/dist/esm/tailwind.js +88 -76
- package/dist/esm/types.js +1 -1
- package/dist/esm/utils.js +183 -177
- package/dist/esm-node/cli.js +109 -137
- package/dist/esm-node/design-token/cli/index.js +85 -94
- package/dist/esm-node/design-token/index.js +1 -4
- package/dist/esm-node/design-token/postcss-plugin/index.js +1 -6
- package/dist/esm-node/design-token/runtime/index.js +1 -4
- package/dist/esm-node/design-token/runtime/plugin.js +29 -18
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/tailwind.js +24 -27
- package/dist/esm-node/types.js +1 -0
- package/dist/esm-node/utils.js +19 -18
- package/package.json +15 -11
@@ -1,38 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all)
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
-
};
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
-
for (let key of __getOwnPropNames(from))
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var runtime_exports = {};
|
30
|
-
__export(runtime_exports, {
|
31
|
-
default: () => runtime_default
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
32
4
|
});
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
5
|
+
Object.defineProperty(exports, "default", {
|
6
|
+
enumerable: true,
|
7
|
+
get: () => _default
|
8
|
+
});
|
9
|
+
const _plugin = /* @__PURE__ */ _interop_require_default(_export_star(require("./plugin"), exports));
|
10
|
+
function _export_star(from, to) {
|
11
|
+
Object.keys(from).forEach(function(k) {
|
12
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
13
|
+
Object.defineProperty(to, k, {
|
14
|
+
enumerable: true,
|
15
|
+
get: function() {
|
16
|
+
return from[k];
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}
|
20
|
+
});
|
21
|
+
return from;
|
22
|
+
}
|
23
|
+
function _interop_require_default(obj) {
|
24
|
+
return obj && obj.__esModule ? obj : {
|
25
|
+
default: obj
|
26
|
+
};
|
27
|
+
}
|
28
|
+
const _default = _plugin.default;
|
@@ -1,72 +1,110 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
8
6
|
for (var name in all)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var plugin_exports = {};
|
29
|
-
__export(plugin_exports, {
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
30
13
|
DesignTokenContext: () => DesignTokenContext,
|
31
|
-
|
32
|
-
|
14
|
+
useDesignTokens: () => useDesignTokens,
|
15
|
+
default: () => _default
|
33
16
|
});
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
17
|
+
const _jsxruntime = require("react/jsx-runtime");
|
18
|
+
const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default(require("hoist-non-react-statics"));
|
19
|
+
const _react = /* @__PURE__ */ _interop_require_wildcard(require("react"));
|
20
|
+
function _interop_require_default(obj) {
|
21
|
+
return obj && obj.__esModule ? obj : {
|
22
|
+
default: obj
|
23
|
+
};
|
24
|
+
}
|
25
|
+
function _getRequireWildcardCache(nodeInterop) {
|
26
|
+
if (typeof WeakMap !== "function")
|
27
|
+
return null;
|
28
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
29
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
30
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
31
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
32
|
+
})(nodeInterop);
|
33
|
+
}
|
34
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
35
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
36
|
+
return obj;
|
37
|
+
}
|
38
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
39
|
+
return {
|
40
|
+
default: obj
|
41
|
+
};
|
42
|
+
}
|
43
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
44
|
+
if (cache && cache.has(obj)) {
|
45
|
+
return cache.get(obj);
|
46
|
+
}
|
47
|
+
var newObj = {};
|
48
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
49
|
+
for (var key in obj) {
|
50
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
51
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
52
|
+
if (desc && (desc.get || desc.set)) {
|
53
|
+
Object.defineProperty(newObj, key, desc);
|
54
|
+
} else {
|
55
|
+
newObj[key] = obj[key];
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
newObj.default = obj;
|
60
|
+
if (cache) {
|
61
|
+
cache.set(obj, newObj);
|
62
|
+
}
|
63
|
+
return newObj;
|
64
|
+
}
|
65
|
+
const DesignTokenContext = /* @__PURE__ */ _react.default.createContext({});
|
66
|
+
const useDesignTokens = () => (0, _react.useContext)(DesignTokenContext);
|
67
|
+
const _default = (options = {}) => ({
|
41
68
|
name: "@modern-js/plugin-design-token",
|
42
69
|
setup: () => ({
|
43
70
|
hoc({ App }, next) {
|
44
71
|
const DesignTokenAppWrapper = (props) => {
|
45
|
-
const {
|
46
|
-
token = {},
|
47
|
-
useStyledComponentsThemeProvider = false,
|
48
|
-
useDesignTokenContext = false
|
49
|
-
} = options;
|
72
|
+
const { token = {}, useStyledComponentsThemeProvider = false, useDesignTokenContext = false } = options;
|
50
73
|
if (useStyledComponentsThemeProvider && useDesignTokenContext) {
|
51
74
|
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
52
|
-
return /* @__PURE__ */ (0,
|
75
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)(ThemeProvider, {
|
76
|
+
theme: token,
|
77
|
+
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(DesignTokenContext.Provider, {
|
78
|
+
value: token,
|
79
|
+
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
|
80
|
+
...props
|
81
|
+
})
|
82
|
+
})
|
83
|
+
});
|
53
84
|
} else if (useStyledComponentsThemeProvider) {
|
54
85
|
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
55
|
-
return /* @__PURE__ */ (0,
|
86
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)(ThemeProvider, {
|
87
|
+
theme: token,
|
88
|
+
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
|
89
|
+
...props
|
90
|
+
})
|
91
|
+
});
|
56
92
|
} else if (useDesignTokenContext) {
|
57
|
-
return /* @__PURE__ */ (0,
|
93
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)(DesignTokenContext.Provider, {
|
94
|
+
value: token,
|
95
|
+
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
|
96
|
+
...props
|
97
|
+
})
|
98
|
+
});
|
58
99
|
} else {
|
59
|
-
return /* @__PURE__ */ (0,
|
100
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
|
101
|
+
...props
|
102
|
+
});
|
60
103
|
}
|
61
104
|
};
|
62
105
|
return next({
|
63
|
-
App: (0,
|
106
|
+
App: (0, _hoistnonreactstatics.default)(DesignTokenAppWrapper, App)
|
64
107
|
});
|
65
108
|
}
|
66
109
|
})
|
67
110
|
});
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
69
|
-
0 && (module.exports = {
|
70
|
-
DesignTokenContext,
|
71
|
-
useDesignTokens
|
72
|
-
});
|
package/dist/cjs/index.js
CHANGED
@@ -1,35 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all)
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
-
};
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
-
for (let key of __getOwnPropNames(from))
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var src_exports = {};
|
29
|
-
__export(src_exports, {
|
30
|
-
default: () => import_cli.default
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
31
4
|
});
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
5
|
+
Object.defineProperty(exports, "default", {
|
6
|
+
enumerable: true,
|
7
|
+
get: () => _cli.default
|
8
|
+
});
|
9
|
+
const _cli = /* @__PURE__ */ _interop_require_default(require("./cli"));
|
10
|
+
function _interop_require_default(obj) {
|
11
|
+
return obj && obj.__esModule ? obj : {
|
12
|
+
default: obj
|
13
|
+
};
|
14
|
+
}
|
package/dist/cjs/tailwind.js
CHANGED
@@ -1,70 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
-
var __export = (target, all) => {
|
6
|
-
for (var name in all)
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
-
};
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var tailwind_exports = {};
|
19
|
-
__export(tailwind_exports, {
|
20
|
-
getTailwindConfig: () => getTailwindConfig
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
21
4
|
});
|
22
|
-
|
23
|
-
|
24
|
-
|
5
|
+
Object.defineProperty(exports, "getTailwindConfig", {
|
6
|
+
enumerable: true,
|
7
|
+
get: () => getTailwindConfig
|
8
|
+
});
|
9
|
+
const _utils = require("@modern-js/utils");
|
10
|
+
const _lodash = require("@modern-js/utils/lodash");
|
25
11
|
const checkIfExistNotAllowKeys = (tailwindConfig) => {
|
26
|
-
const notAllowExistKeys = [
|
12
|
+
const notAllowExistKeys = [
|
13
|
+
"theme"
|
14
|
+
];
|
27
15
|
let notAllowKey = "";
|
28
|
-
const ret = Object.keys(tailwindConfig).some(
|
29
|
-
|
30
|
-
|
31
|
-
|
16
|
+
const ret = Object.keys(tailwindConfig).some((key) => notAllowExistKeys.includes(key) && (notAllowKey = key));
|
17
|
+
return [
|
18
|
+
ret,
|
19
|
+
notAllowKey
|
20
|
+
];
|
32
21
|
};
|
33
22
|
const getPureDesignSystemConfig = (designSystemConfig) => {
|
34
|
-
const pureDesignSystemConfig = (0,
|
23
|
+
const pureDesignSystemConfig = (0, _lodash.cloneDeep)(designSystemConfig);
|
35
24
|
delete pureDesignSystemConfig.supportStyledComponents;
|
36
25
|
return pureDesignSystemConfig;
|
37
26
|
};
|
38
27
|
const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
|
39
|
-
const purgeConfig = (0,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
28
|
+
const purgeConfig = (0, _lodash.merge)({
|
29
|
+
// TODO: how the operating environment is determined
|
30
|
+
enabled: process.env.NODE_ENV === "production",
|
31
|
+
// TODO: Remove or not
|
32
|
+
layers: [
|
33
|
+
"utilities"
|
34
|
+
],
|
35
|
+
content: []
|
36
|
+
}, option.pureConfig || {});
|
37
|
+
const defaultTailwindConfig = tailwindVersion === "3" ? {
|
38
|
+
content: purgeConfig.content
|
39
|
+
} : {
|
50
40
|
purge: purgeConfig
|
51
41
|
};
|
52
|
-
const tailwindConfig = (0,
|
53
|
-
|
54
|
-
tailwindcss || {}
|
55
|
-
);
|
56
|
-
const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
|
42
|
+
const tailwindConfig = (0, _utils.applyOptionsChain)(defaultTailwindConfig, tailwindcss || {});
|
43
|
+
const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
|
57
44
|
const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
|
58
45
|
if (exist) {
|
59
|
-
|
60
|
-
`should not exist '${key}' on tools.tailwindcss, please remove it`
|
61
|
-
);
|
46
|
+
_utils.logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
|
62
47
|
process.exit(0);
|
63
48
|
}
|
64
49
|
tailwindConfig.theme = designSystemConfig || {};
|
65
50
|
return tailwindConfig;
|
66
51
|
};
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
68
|
-
0 && (module.exports = {
|
69
|
-
getTailwindConfig
|
70
|
-
});
|
package/dist/cjs/types.js
CHANGED
@@ -1,15 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
-
for (let key of __getOwnPropNames(from))
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
-
}
|
11
|
-
return to;
|
12
|
-
};
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
-
var types_exports = {};
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
package/dist/cjs/utils.js
CHANGED
@@ -1,41 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
8
6
|
for (var name in all)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var utils_exports = {};
|
29
|
-
__export(utils_exports, {
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
13
|
+
template: () => template,
|
30
14
|
checkTwinMacroExist: () => checkTwinMacroExist,
|
31
|
-
getTailwindPath: () => getTailwindPath,
|
32
|
-
getTailwindVersion: () => getTailwindVersion,
|
33
15
|
getTwinMacroMajorVersion: () => getTwinMacroMajorVersion,
|
34
|
-
|
16
|
+
getTailwindPath: () => getTailwindPath,
|
17
|
+
getTailwindVersion: () => getTailwindVersion
|
35
18
|
});
|
36
|
-
|
37
|
-
|
38
|
-
|
19
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
20
|
+
const _utils = require("@modern-js/utils");
|
21
|
+
function _interop_require_default(obj) {
|
22
|
+
return obj && obj.__esModule ? obj : {
|
23
|
+
default: obj
|
24
|
+
};
|
25
|
+
}
|
39
26
|
const template = (configPath) => `
|
40
27
|
function _interopRequireDefault(obj) {
|
41
28
|
return obj && obj.__esModule ? obj : { default: obj };
|
@@ -58,17 +45,17 @@ module.exports = {
|
|
58
45
|
`;
|
59
46
|
const TWIN_MACRO_NAME = "twin.macro";
|
60
47
|
const checkTwinMacroExist = async (appDirectory) => {
|
61
|
-
const packageJson = await
|
48
|
+
const packageJson = await _utils.fs.readJSON(_path.default.join(appDirectory, "package.json"), {
|
62
49
|
throws: false
|
63
50
|
}) || {};
|
64
|
-
return Boolean(
|
65
|
-
typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
|
66
|
-
);
|
51
|
+
return Boolean(typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]);
|
67
52
|
};
|
68
53
|
const getTwinMacroMajorVersion = (appDirectory) => {
|
69
54
|
try {
|
70
55
|
const pkgJsonPath = require.resolve(`${TWIN_MACRO_NAME}/package.json`, {
|
71
|
-
paths: [
|
56
|
+
paths: [
|
57
|
+
appDirectory
|
58
|
+
]
|
72
59
|
});
|
73
60
|
const { version } = require(pkgJsonPath);
|
74
61
|
return Number(version.split(".")[0]);
|
@@ -78,7 +65,12 @@ const getTwinMacroMajorVersion = (appDirectory) => {
|
|
78
65
|
};
|
79
66
|
function getTailwindPath(appDirectory) {
|
80
67
|
try {
|
81
|
-
return require.resolve("tailwindcss", {
|
68
|
+
return require.resolve("tailwindcss", {
|
69
|
+
paths: [
|
70
|
+
appDirectory,
|
71
|
+
__dirname
|
72
|
+
]
|
73
|
+
});
|
82
74
|
} catch (err) {
|
83
75
|
return "tailwindcss";
|
84
76
|
}
|
@@ -86,18 +78,13 @@ function getTailwindPath(appDirectory) {
|
|
86
78
|
function getTailwindVersion(appDirectory) {
|
87
79
|
try {
|
88
80
|
const packageJsonPath = require.resolve("tailwindcss/package.json", {
|
89
|
-
paths: [
|
81
|
+
paths: [
|
82
|
+
appDirectory,
|
83
|
+
__dirname
|
84
|
+
]
|
90
85
|
});
|
91
86
|
return require(packageJsonPath).version.split(".")[0];
|
92
87
|
} catch (err) {
|
93
88
|
return "3";
|
94
89
|
}
|
95
90
|
}
|
96
|
-
// Annotate the CommonJS export names for ESM import in node:
|
97
|
-
0 && (module.exports = {
|
98
|
-
checkTwinMacroExist,
|
99
|
-
getTailwindPath,
|
100
|
-
getTailwindVersion,
|
101
|
-
getTwinMacroMajorVersion,
|
102
|
-
template
|
103
|
-
});
|