@modern-js/plugin-tailwindcss 2.13.5-beta.0 → 2.15.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/cjs/cli.js +0 -4
  3. package/dist/esm/cli.js +0 -4
  4. package/dist/esm-node/cli.js +0 -4
  5. package/package.json +10 -10
  6. package/dist/js/modern/cli.js +0 -174
  7. package/dist/js/modern/design-token/cli/index.js +0 -110
  8. package/dist/js/modern/design-token/index.js +0 -5
  9. package/dist/js/modern/design-token/postcss-plugin/index.js +0 -18
  10. package/dist/js/modern/design-token/runtime/index.js +0 -6
  11. package/dist/js/modern/design-token/runtime/plugin.js +0 -66
  12. package/dist/js/modern/index.js +0 -4
  13. package/dist/js/modern/tailwind.js +0 -45
  14. package/dist/js/modern/types.js +0 -0
  15. package/dist/js/modern/utils.js +0 -86
  16. package/dist/js/node/cli.js +0 -190
  17. package/dist/js/node/design-token/cli/index.js +0 -125
  18. package/dist/js/node/design-token/index.js +0 -33
  19. package/dist/js/node/design-token/postcss-plugin/index.js +0 -39
  20. package/dist/js/node/design-token/runtime/index.js +0 -34
  21. package/dist/js/node/design-token/runtime/plugin.js +0 -94
  22. package/dist/js/node/index.js +0 -31
  23. package/dist/js/node/tailwind.js +0 -68
  24. package/dist/js/node/types.js +0 -15
  25. package/dist/js/node/utils.js +0 -119
  26. package/dist/js/treeshaking/cli.js +0 -268
  27. package/dist/js/treeshaking/design-token/cli/index.js +0 -118
  28. package/dist/js/treeshaking/design-token/index.js +0 -3
  29. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +0 -17
  30. package/dist/js/treeshaking/design-token/runtime/index.js +0 -4
  31. package/dist/js/treeshaking/design-token/runtime/plugin.js +0 -78
  32. package/dist/js/treeshaking/index.js +0 -2
  33. package/dist/js/treeshaking/tailwind.js +0 -91
  34. package/dist/js/treeshaking/types.js +0 -1
  35. package/dist/js/treeshaking/utils.js +0 -194
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
+ ## 2.15.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [09a3e57]
8
+ - @modern-js/runtime@2.15.0
9
+ - @modern-js/utils@2.15.0
10
+
11
+ ## 2.14.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [4779152]
16
+ - Updated dependencies [9321bef]
17
+ - Updated dependencies [c921f30]
18
+ - Updated dependencies [ead58c8]
19
+ - Updated dependencies [afe5d35]
20
+ - Updated dependencies [4c74ea7]
21
+ - Updated dependencies [9b45c58]
22
+ - Updated dependencies [76ad173]
23
+ - Updated dependencies [394470c]
24
+ - Updated dependencies [8b634f9]
25
+ - Updated dependencies [1b3afa0]
26
+ - Updated dependencies [52d0cb1]
27
+ - Updated dependencies [28721cb]
28
+ - Updated dependencies [60a81d0]
29
+ - Updated dependencies [dacef96]
30
+ - Updated dependencies [16399fd]
31
+ - @modern-js/utils@2.14.0
32
+ - @modern-js/runtime@2.14.0
33
+
3
34
  ## 2.13.4
4
35
 
5
36
  ### Patch Changes
package/dist/cjs/cli.js CHANGED
@@ -168,10 +168,6 @@ var cli_default = ({ pluginName } = {
168
168
  config.style.postcss.plugins = [tailwindPlugin];
169
169
  }
170
170
  return config;
171
- },
172
- modifyLibuild(config, next) {
173
- config.transformCache = false;
174
- return next(config);
175
171
  }
176
172
  };
177
173
  }
package/dist/esm/cli.js CHANGED
@@ -257,10 +257,6 @@ var cli_default = function() {
257
257
  ];
258
258
  }
259
259
  return config;
260
- },
261
- modifyLibuild: function modifyLibuild(config, next) {
262
- config.transformCache = false;
263
- return next(config);
264
260
  }
265
261
  }
266
262
  ];
@@ -148,10 +148,6 @@ var cli_default = ({ pluginName } = {
148
148
  config.style.postcss.plugins = [tailwindPlugin];
149
149
  }
150
150
  return config;
151
- },
152
- modifyLibuild(config, next) {
153
- config.transformCache = false;
154
- return next(config);
155
151
  }
156
152
  };
157
153
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.13.5-beta.0",
14
+ "version": "2.15.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.4"
48
+ "@modern-js/utils": "2.15.0"
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.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"
58
+ "@modern-js/module-tools": "2.15.0",
59
+ "@modern-js/runtime": "2.15.0",
60
+ "@modern-js/core": "2.15.0",
61
+ "@modern-js/types": "2.15.0",
62
+ "@scripts/build": "2.15.0",
63
+ "@modern-js/app-tools": "2.15.0",
64
+ "@scripts/jest-config": "2.15.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "tailwindcss": ">= 2.0.0 || >= 3.0.0",
68
- "@modern-js/runtime": "^2.13.4"
68
+ "@modern-js/runtime": "^2.15.0"
69
69
  },
70
70
  "peerDependenciesMeta": {
71
71
  "@modern-js/runtime": {
@@ -1,174 +0,0 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
- import path from "path";
22
- import {
23
- PLUGIN_SCHEMAS,
24
- fs,
25
- CONFIG_CACHE_DIR,
26
- globby,
27
- nanoid,
28
- slash
29
- } from "@modern-js/utils";
30
- import designTokenPlugin from "./design-token/cli";
31
- import { getTailwindConfig } from "./tailwind";
32
- import {
33
- template,
34
- checkTwinMacroExist,
35
- getTailwindPath,
36
- getTailwindVersion,
37
- getTwinMacroMajorVersion
38
- } from "./utils";
39
- const supportCssInJsLibrary = "styled-components";
40
- const getRandomTwConfigFileName = (internalDirectory) => {
41
- return slash(
42
- path.join(
43
- internalDirectory,
44
- `tailwind.config.${Date.now()}.${nanoid()}.js`
45
- )
46
- );
47
- };
48
- var cli_default = ({ pluginName } = {
49
- pluginName: "@modern-js/plugin-tailwindcss"
50
- }) => ({
51
- name: "@modern-js/plugin-tailwindcss",
52
- usePlugins: [
53
- designTokenPlugin({
54
- pluginName
55
- })
56
- ],
57
- setup: (api) => __async(void 0, null, function* () {
58
- const { appDirectory, internalDirectory } = api.useAppContext();
59
- let internalTwConfigPath = "";
60
- const haveTwinMacro = yield checkTwinMacroExist(appDirectory);
61
- const tailwindPath = getTailwindPath(appDirectory);
62
- const tailwindVersion = getTailwindVersion(appDirectory);
63
- const defaultContent = [
64
- "./config/html/**/*.html",
65
- "./config/html/**/*.ejs",
66
- "./config/html/**/*.hbs",
67
- "./src/**/*.js",
68
- "./src/**/*.jsx",
69
- "./src/**/*.ts",
70
- "./src/**/*.tsx",
71
- "./storybook/**/*"
72
- ];
73
- return {
74
- prepare() {
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
- }
94
- }
95
- },
96
- validateSchema() {
97
- return PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
98
- },
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
- };
117
- return {
118
- tools: {
119
- postcss: (config) => {
120
- initTailwindConfig();
121
- const tailwindPlugin = require(tailwindPath)(tailwindConfig);
122
- if (Array.isArray(config.postcssOptions.plugins)) {
123
- config.postcssOptions.plugins.push(tailwindPlugin);
124
- } else {
125
- config.postcssOptions.plugins = [tailwindPlugin];
126
- }
127
- },
128
- babel(_, { addPlugins }) {
129
- if (haveTwinMacro) {
130
- initTailwindConfig();
131
- addPlugins([
132
- [
133
- require.resolve("babel-plugin-macros"),
134
- {
135
- twin: {
136
- preset: supportCssInJsLibrary,
137
- config: internalTwConfigPath || tailwindConfig
138
- }
139
- }
140
- ]
141
- ]);
142
- }
143
- }
144
- }
145
- };
146
- },
147
- beforeBuildTask(config) {
148
- const modernConfig = api.useResolvedConfigContext();
149
- const { designSystem } = modernConfig;
150
- const tailwindConfig = getTailwindConfig(
151
- tailwindVersion,
152
- config.style.tailwindCss,
153
- designSystem,
154
- {
155
- pureConfig: {
156
- content: defaultContent
157
- }
158
- }
159
- );
160
- const tailwindPlugin = require(tailwindPath)(tailwindConfig);
161
- if (Array.isArray(config.style.postcss.plugins)) {
162
- config.style.postcss.plugins.push(tailwindPlugin);
163
- } else {
164
- config.style.postcss.plugins = [tailwindPlugin];
165
- }
166
- return config;
167
- }
168
- };
169
- })
170
- });
171
- export {
172
- cli_default as default,
173
- getRandomTwConfigFileName
174
- };
@@ -1,110 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import {
18
- lazyImport,
19
- PLUGIN_SCHEMAS,
20
- createRuntimeExportsUtils
21
- } from "@modern-js/utils";
22
- var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
23
- name: "@modern-js/plugin-design-token",
24
- setup(api) {
25
- let pluginsExportsUtils;
26
- const resolveConfig = lazyImport("tailwindcss/resolveConfig", require);
27
- const PLUGIN_IDENTIFIER = "designToken";
28
- const getDesignTokens = (designSystem) => {
29
- const tailwindcssConfig = {};
30
- tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
31
- if (!designSystem) {
32
- tailwindcssConfig.presets = [];
33
- }
34
- if (designSystem) {
35
- delete tailwindcssConfig.theme.supportStyledComponents;
36
- }
37
- return resolveConfig(tailwindcssConfig).theme || {};
38
- };
39
- return {
40
- config() {
41
- const appContext = api.useAppContext();
42
- pluginsExportsUtils = createRuntimeExportsUtils(
43
- appContext.internalDirectory,
44
- "plugins"
45
- );
46
- return {
47
- source: {
48
- alias: {
49
- "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
50
- }
51
- },
52
- tools: {}
53
- };
54
- },
55
- modifyEntryImports({ entrypoint, imports }) {
56
- var _a, _b;
57
- const userConfig = api.useResolvedConfigContext();
58
- const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
59
- if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
60
- const designTokens = getDesignTokens(userConfig.source.designSystem);
61
- imports.push({
62
- value: "@modern-js/runtime/plugins",
63
- specifiers: [
64
- {
65
- imported: PLUGIN_IDENTIFIER
66
- }
67
- ],
68
- initialize: `
69
- const designTokens = ${JSON.stringify(designTokens)};
70
- `
71
- });
72
- }
73
- return {
74
- entrypoint,
75
- imports
76
- };
77
- },
78
- modifyEntryRuntimePlugins({ entrypoint, plugins }) {
79
- var _a, _b;
80
- const userConfig = api.useResolvedConfigContext();
81
- const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
82
- let useSCThemeProvider = true;
83
- if (designSystem) {
84
- useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
85
- }
86
- if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
87
- plugins.push({
88
- name: PLUGIN_IDENTIFIER,
89
- options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
90
- });
91
- }
92
- return {
93
- entrypoint,
94
- plugins
95
- };
96
- },
97
- validateSchema() {
98
- return PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
99
- },
100
- addRuntimeExports() {
101
- pluginsExportsUtils.addExport(
102
- `export { default as designToken } from '${pluginName}/runtime-design-token'`
103
- );
104
- }
105
- };
106
- }
107
- });
108
- export {
109
- cli_default as default
110
- };
@@ -1,5 +0,0 @@
1
- import { default as default2 } from "./runtime";
2
- export * from "./runtime";
3
- export {
4
- default2 as default
5
- };
@@ -1,18 +0,0 @@
1
- var postcss_plugin_default = ({
2
- cssVarsHash = {}
3
- } = {}) => ({
4
- postcssPlugin: "postcss-replace-css-vars",
5
- Declaration(decl) {
6
- if (decl.value && typeof decl.value === "string") {
7
- decl.value = decl.value.replace(/--\S*/g, (match) => {
8
- if (cssVarsHash[match]) {
9
- return cssVarsHash[match];
10
- }
11
- return match;
12
- });
13
- }
14
- }
15
- });
16
- export {
17
- postcss_plugin_default as default
18
- };
@@ -1,6 +0,0 @@
1
- import designTokenPlugin from "./plugin";
2
- export * from "./plugin";
3
- var runtime_default = designTokenPlugin;
4
- export {
5
- runtime_default as default
6
- };
@@ -1,66 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import { jsx } from "react/jsx-runtime";
18
- import hoistNonReactStatics from "hoist-non-react-statics";
19
- import React, { useContext } from "react";
20
- const DesignTokenContext = React.createContext({});
21
- const useDesignTokens = () => useContext(DesignTokenContext);
22
- var plugin_default = (options = {}) => ({
23
- name: "@modern-js/plugin-design-token",
24
- setup: () => ({
25
- hoc({ App }, next) {
26
- const DesignTokenAppWrapper = (props) => {
27
- const {
28
- token = {},
29
- useStyledComponentsThemeProvider = false,
30
- useDesignTokenContext = false
31
- } = options;
32
- if (useStyledComponentsThemeProvider && useDesignTokenContext) {
33
- const { ThemeProvider } = require("@modern-js/runtime/styled");
34
- return /* @__PURE__ */ jsx(ThemeProvider, {
35
- theme: token,
36
- children: /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
37
- value: token,
38
- children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
39
- })
40
- });
41
- } else if (useStyledComponentsThemeProvider) {
42
- const { ThemeProvider } = require("@modern-js/runtime/styled");
43
- return /* @__PURE__ */ jsx(ThemeProvider, {
44
- theme: token,
45
- children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
46
- });
47
- } else if (useDesignTokenContext) {
48
- return /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
49
- value: token,
50
- children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
51
- });
52
- } else {
53
- return /* @__PURE__ */ jsx(App, __spreadValues({}, props));
54
- }
55
- };
56
- return next({
57
- App: hoistNonReactStatics(DesignTokenAppWrapper, App)
58
- });
59
- }
60
- })
61
- });
62
- export {
63
- DesignTokenContext,
64
- plugin_default as default,
65
- useDesignTokens
66
- };
@@ -1,4 +0,0 @@
1
- import { default as default2 } from "./cli";
2
- export {
3
- default2 as default
4
- };
@@ -1,45 +0,0 @@
1
- import { applyOptionsChain, logger } from "@modern-js/utils";
2
- import { merge, cloneDeep } from "@modern-js/utils/lodash";
3
- const checkIfExistNotAllowKeys = (tailwindConfig) => {
4
- const notAllowExistKeys = ["theme"];
5
- let notAllowKey = "";
6
- const ret = Object.keys(tailwindConfig).some(
7
- (key) => notAllowExistKeys.includes(key) && (notAllowKey = key)
8
- );
9
- return [ret, notAllowKey];
10
- };
11
- const getPureDesignSystemConfig = (designSystemConfig) => {
12
- const pureDesignSystemConfig = cloneDeep(designSystemConfig);
13
- delete pureDesignSystemConfig.supportStyledComponents;
14
- return pureDesignSystemConfig;
15
- };
16
- const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
17
- const purgeConfig = merge(
18
- {
19
- enabled: process.env.NODE_ENV === "production",
20
- layers: ["utilities"],
21
- content: []
22
- },
23
- option.pureConfig || {}
24
- );
25
- const defaultTailwindConfig = tailwindVersion === "3" ? { content: purgeConfig.content } : {
26
- purge: purgeConfig
27
- };
28
- const tailwindConfig = applyOptionsChain(
29
- defaultTailwindConfig,
30
- tailwindcss || {}
31
- );
32
- const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
33
- const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
34
- if (exist) {
35
- logger.error(
36
- `should not exist '${key}' on tools.tailwindcss, please remove it`
37
- );
38
- process.exit(0);
39
- }
40
- tailwindConfig.theme = designSystemConfig || {};
41
- return tailwindConfig;
42
- };
43
- export {
44
- getTailwindConfig
45
- };
File without changes
@@ -1,86 +0,0 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
- import path from "path";
22
- import { fs } from "@modern-js/utils";
23
- const template = (configPath) => `
24
- function _interopRequireDefault(obj) {
25
- return obj && obj.__esModule ? obj : { default: obj };
26
- }
27
- const modernConfig = _interopRequireDefault(require('${configPath}')).default;
28
-
29
- const theme =
30
- modernConfig && modernConfig.source && modernConfig.source.designSystem
31
- ? modernConfig.source.designSystem
32
- : {};
33
- const tailwindcss =
34
- modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss
35
- ? modernConfig.tools.tailwindcss
36
- : {};
37
-
38
- module.exports = {
39
- theme,
40
- ...tailwindcss,
41
- };
42
- `;
43
- const TWIN_MACRO_NAME = "twin.macro";
44
- const checkTwinMacroExist = (appDirectory) => __async(void 0, null, function* () {
45
- const packageJson = (yield fs.readJSON(path.join(appDirectory, "package.json"), {
46
- throws: false
47
- })) || {};
48
- return Boolean(
49
- typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
50
- );
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
- };
63
- function getTailwindPath(appDirectory) {
64
- try {
65
- return require.resolve("tailwindcss", { paths: [appDirectory, __dirname] });
66
- } catch (err) {
67
- return "tailwindcss";
68
- }
69
- }
70
- function getTailwindVersion(appDirectory) {
71
- try {
72
- const packageJsonPath = require.resolve("tailwindcss/package.json", {
73
- paths: [appDirectory, __dirname]
74
- });
75
- return require(packageJsonPath).version.split(".")[0];
76
- } catch (err) {
77
- return "3";
78
- }
79
- }
80
- export {
81
- checkTwinMacroExist,
82
- getTailwindPath,
83
- getTailwindVersion,
84
- getTwinMacroMajorVersion,
85
- template
86
- };