@modern-js/plugin-tailwindcss 2.4.1-beta.0 → 2.6.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 +29 -3
- package/dist/{js/node → cjs}/cli.js +11 -23
- package/dist/{js/node → cjs}/design-token/cli/index.js +7 -16
- package/dist/{js/node → cjs}/design-token/index.js +4 -0
- package/dist/{js/node → cjs}/design-token/runtime/index.js +4 -0
- package/dist/{js/node → cjs}/design-token/runtime/plugin.js +8 -30
- package/dist/{js/node → cjs}/index.js +4 -0
- package/dist/{js/node → cjs}/tailwind.js +2 -0
- package/dist/{js/node → cjs}/utils.js +8 -24
- package/dist/{js/treeshaking → esm}/cli.js +4 -0
- package/dist/{js/treeshaking → esm}/design-token/cli/index.js +2 -1
- package/dist/{js/treeshaking → esm}/tailwind.js +2 -0
- package/dist/{js/modern → esm-node}/cli.js +7 -23
- package/dist/{js/modern → esm-node}/design-token/cli/index.js +7 -18
- package/dist/esm-node/design-token/runtime/plugin.js +38 -0
- package/dist/{js/modern → esm-node}/tailwind.js +2 -0
- package/dist/{js/modern → esm-node}/utils.js +4 -24
- package/package.json +17 -18
- package/dist/js/modern/design-token/runtime/plugin.js +0 -66
- /package/dist/{js/node → cjs}/design-token/postcss-plugin/index.js +0 -0
- /package/dist/{js/node → cjs}/types.js +0 -0
- /package/dist/{js/treeshaking → esm}/design-token/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/design-token/postcss-plugin/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/design-token/runtime/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/design-token/runtime/plugin.js +0 -0
- /package/dist/{js/treeshaking → esm}/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/types.js +0 -0
- /package/dist/{js/treeshaking → esm}/utils.js +0 -0
- /package/dist/{js/modern → esm-node}/design-token/index.js +0 -0
- /package/dist/{js/modern → esm-node}/design-token/postcss-plugin/index.js +0 -0
- /package/dist/{js/modern → esm-node}/design-token/runtime/index.js +0 -0
- /package/dist/{js/modern → esm-node}/index.js +0 -0
- /package/dist/{js/modern → esm-node}/types.js +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
-
## 2.
|
3
|
+
## 2.6.0
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
+
- Updated dependencies [671477d]
|
8
|
+
- Updated dependencies [e1f799e]
|
9
|
+
- Updated dependencies [7915ab3]
|
10
|
+
- Updated dependencies [a909ad1]
|
11
|
+
- Updated dependencies [49fa0b1]
|
12
|
+
- Updated dependencies [0fe658a]
|
13
|
+
- Updated dependencies [1906d7b]
|
14
|
+
- @modern-js/runtime@2.6.0
|
15
|
+
- @modern-js/utils@2.6.0
|
16
|
+
|
17
|
+
## 2.5.0
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- 89ca6cc: refactor: merge build-config into scripts/build
|
22
|
+
|
23
|
+
refactor: 把 build-config 合并进 scripts/build
|
24
|
+
|
25
|
+
- 30614fa: chore: modify package.json entry fields and build config
|
26
|
+
chore: 更改 package.json entry 字段以及构建配置
|
27
|
+
- Updated dependencies [89ca6cc]
|
28
|
+
- Updated dependencies [7cb8bb4]
|
29
|
+
- Updated dependencies [30614fa]
|
7
30
|
- Updated dependencies [7a25271]
|
31
|
+
- Updated dependencies [8871bb8]
|
32
|
+
- Updated dependencies [1b0ce87]
|
33
|
+
- Updated dependencies [0d75c27]
|
8
34
|
- Updated dependencies [11c053b]
|
9
35
|
- Updated dependencies [a0f2ab1]
|
10
|
-
- @modern-js/runtime@2.
|
11
|
-
- @modern-js/utils@2.
|
36
|
+
- @modern-js/runtime@2.5.0
|
37
|
+
- @modern-js/utils@2.5.0
|
12
38
|
|
13
39
|
## 2.4.0
|
14
40
|
|
@@ -17,30 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
return to;
|
18
18
|
};
|
19
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.
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
25
|
mod
|
22
26
|
));
|
23
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
25
|
-
return new Promise((resolve, reject) => {
|
26
|
-
var fulfilled = (value) => {
|
27
|
-
try {
|
28
|
-
step(generator.next(value));
|
29
|
-
} catch (e) {
|
30
|
-
reject(e);
|
31
|
-
}
|
32
|
-
};
|
33
|
-
var rejected = (value) => {
|
34
|
-
try {
|
35
|
-
step(generator.throw(value));
|
36
|
-
} catch (e) {
|
37
|
-
reject(e);
|
38
|
-
}
|
39
|
-
};
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
42
|
-
});
|
43
|
-
};
|
44
28
|
var cli_exports = {};
|
45
29
|
__export(cli_exports, {
|
46
30
|
default: () => cli_default,
|
@@ -65,15 +49,16 @@ var cli_default = ({ pluginName } = {
|
|
65
49
|
pluginName: "@modern-js/plugin-tailwindcss"
|
66
50
|
}) => ({
|
67
51
|
name: "@modern-js/plugin-tailwindcss",
|
52
|
+
// support designSystem.supportStyledComponents
|
68
53
|
usePlugins: [
|
69
54
|
(0, import_cli.default)({
|
70
55
|
pluginName
|
71
56
|
})
|
72
57
|
],
|
73
|
-
setup: (api) =>
|
58
|
+
setup: async (api) => {
|
74
59
|
const { appDirectory, internalDirectory } = api.useAppContext();
|
75
60
|
let internalTwConfigPath = "";
|
76
|
-
const haveTwinMacro =
|
61
|
+
const haveTwinMacro = await (0, import_utils2.checkTwinMacroExist)(appDirectory);
|
77
62
|
const tailwindPath = (0, import_utils2.getTailwindPath)(appDirectory);
|
78
63
|
const tailwindVersion = (0, import_utils2.getTailwindVersion)(appDirectory);
|
79
64
|
const defaultContent = [
|
@@ -84,6 +69,7 @@ var cli_default = ({ pluginName } = {
|
|
84
69
|
"./src/**/*.jsx",
|
85
70
|
"./src/**/*.ts",
|
86
71
|
"./src/**/*.tsx",
|
72
|
+
// about storybook
|
87
73
|
"./storybook/**/*"
|
88
74
|
];
|
89
75
|
return {
|
@@ -132,6 +118,8 @@ var cli_default = ({ pluginName } = {
|
|
132
118
|
};
|
133
119
|
return {
|
134
120
|
tools: {
|
121
|
+
// TODO: Add interface about postcss config
|
122
|
+
// TODO: In module project, also is called, but should not be called.
|
135
123
|
postcss: (config) => {
|
136
124
|
initTailwindConfig();
|
137
125
|
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
@@ -182,7 +170,7 @@ var cli_default = ({ pluginName } = {
|
|
182
170
|
return config;
|
183
171
|
}
|
184
172
|
};
|
185
|
-
}
|
173
|
+
}
|
186
174
|
});
|
187
175
|
// Annotate the CommonJS export names for ESM import in node:
|
188
176
|
0 && (module.exports = {
|
@@ -1,21 +1,7 @@
|
|
1
1
|
var __defProp = Object.defineProperty;
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
-
var __spreadValues = (a, b) => {
|
9
|
-
for (var prop in b || (b = {}))
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
12
|
-
if (__getOwnPropSymbols)
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
-
if (__propIsEnum.call(b, prop))
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
16
|
-
}
|
17
|
-
return a;
|
18
|
-
};
|
19
5
|
var __export = (target, all) => {
|
20
6
|
for (var name in all)
|
21
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -43,7 +29,7 @@ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss
|
|
43
29
|
const PLUGIN_IDENTIFIER = "designToken";
|
44
30
|
const getDesignTokens = (designSystem) => {
|
45
31
|
const tailwindcssConfig = {};
|
46
|
-
tailwindcssConfig.theme = designSystem ?
|
32
|
+
tailwindcssConfig.theme = designSystem ? { ...designSystem } : {};
|
47
33
|
if (!designSystem) {
|
48
34
|
tailwindcssConfig.presets = [];
|
49
35
|
}
|
@@ -65,7 +51,12 @@ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss
|
|
65
51
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
66
52
|
}
|
67
53
|
},
|
68
|
-
tools: {
|
54
|
+
tools: {
|
55
|
+
// TODO: support less、scss、css vars
|
56
|
+
// less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
|
57
|
+
// sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
|
58
|
+
// postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
|
59
|
+
}
|
69
60
|
};
|
70
61
|
},
|
71
62
|
modifyEntryImports({ entrypoint, imports }) {
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
};
|
19
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
20
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.
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
26
|
mod
|
23
27
|
));
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
};
|
19
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
20
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.
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
26
|
mod
|
23
27
|
));
|
@@ -2,22 +2,8 @@ var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
-
var __spreadValues = (a, b) => {
|
11
|
-
for (var prop in b || (b = {}))
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
14
|
-
if (__getOwnPropSymbols)
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
16
|
-
if (__propIsEnum.call(b, prop))
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
18
|
-
}
|
19
|
-
return a;
|
20
|
-
};
|
21
7
|
var __export = (target, all) => {
|
22
8
|
for (var name in all)
|
23
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -31,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
31
17
|
return to;
|
32
18
|
};
|
33
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.
|
34
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
35
25
|
mod
|
36
26
|
));
|
@@ -59,26 +49,14 @@ var plugin_default = (options = {}) => ({
|
|
59
49
|
} = options;
|
60
50
|
if (useStyledComponentsThemeProvider && useDesignTokenContext) {
|
61
51
|
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
62
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
|
63
|
-
theme: token,
|
64
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
|
65
|
-
value: token,
|
66
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
67
|
-
})
|
68
|
-
});
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, { theme: token, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, { value: token, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props }) }) });
|
69
53
|
} else if (useStyledComponentsThemeProvider) {
|
70
54
|
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
71
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
|
72
|
-
theme: token,
|
73
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
74
|
-
});
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, { theme: token, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props }) });
|
75
56
|
} else if (useDesignTokenContext) {
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
|
77
|
-
value: token,
|
78
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
79
|
-
});
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, { value: token, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props }) });
|
80
58
|
} else {
|
81
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App,
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props });
|
82
60
|
}
|
83
61
|
};
|
84
62
|
return next({
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
return to;
|
18
18
|
};
|
19
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.
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
25
|
mod
|
22
26
|
));
|
@@ -38,7 +38,9 @@ const getPureDesignSystemConfig = (designSystemConfig) => {
|
|
38
38
|
const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
|
39
39
|
const purgeConfig = (0, import_lodash.merge)(
|
40
40
|
{
|
41
|
+
// TODO: how the operating environment is determined
|
41
42
|
enabled: process.env.NODE_ENV === "production",
|
43
|
+
// TODO: Remove or not
|
42
44
|
layers: ["utilities"],
|
43
45
|
content: []
|
44
46
|
},
|
@@ -17,30 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
return to;
|
18
18
|
};
|
19
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.
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
25
|
mod
|
22
26
|
));
|
23
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
25
|
-
return new Promise((resolve, reject) => {
|
26
|
-
var fulfilled = (value) => {
|
27
|
-
try {
|
28
|
-
step(generator.next(value));
|
29
|
-
} catch (e) {
|
30
|
-
reject(e);
|
31
|
-
}
|
32
|
-
};
|
33
|
-
var rejected = (value) => {
|
34
|
-
try {
|
35
|
-
step(generator.throw(value));
|
36
|
-
} catch (e) {
|
37
|
-
reject(e);
|
38
|
-
}
|
39
|
-
};
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
42
|
-
});
|
43
|
-
};
|
44
28
|
var utils_exports = {};
|
45
29
|
__export(utils_exports, {
|
46
30
|
checkTwinMacroExist: () => checkTwinMacroExist,
|
@@ -73,14 +57,14 @@ module.exports = {
|
|
73
57
|
};
|
74
58
|
`;
|
75
59
|
const TWIN_MACRO_NAME = "twin.macro";
|
76
|
-
const checkTwinMacroExist = (appDirectory) =>
|
77
|
-
const packageJson =
|
60
|
+
const checkTwinMacroExist = async (appDirectory) => {
|
61
|
+
const packageJson = await import_utils.fs.readJSON(import_path.default.join(appDirectory, "package.json"), {
|
78
62
|
throws: false
|
79
|
-
})
|
63
|
+
}) || {};
|
80
64
|
return Boolean(
|
81
65
|
typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
|
82
66
|
);
|
83
|
-
}
|
67
|
+
};
|
84
68
|
const getTwinMacroMajorVersion = (appDirectory) => {
|
85
69
|
try {
|
86
70
|
const pkgJsonPath = require.resolve(`${TWIN_MACRO_NAME}/package.json`, {
|
@@ -137,6 +137,7 @@ var cli_default = function() {
|
|
137
137
|
}).pluginName;
|
138
138
|
return {
|
139
139
|
name: "@modern-js/plugin-tailwindcss",
|
140
|
+
// support designSystem.supportStyledComponents
|
140
141
|
usePlugins: [
|
141
142
|
designTokenPlugin({
|
142
143
|
pluginName: pluginName
|
@@ -166,6 +167,7 @@ var cli_default = function() {
|
|
166
167
|
"./src/**/*.jsx",
|
167
168
|
"./src/**/*.ts",
|
168
169
|
"./src/**/*.tsx",
|
170
|
+
// about storybook
|
169
171
|
"./storybook/**/*"
|
170
172
|
];
|
171
173
|
return [
|
@@ -205,6 +207,8 @@ var cli_default = function() {
|
|
205
207
|
};
|
206
208
|
return {
|
207
209
|
tools: {
|
210
|
+
// TODO: Add interface about postcss config
|
211
|
+
// TODO: In module project, also is called, but should not be called.
|
208
212
|
postcss: function(config) {
|
209
213
|
initTailwindConfig();
|
210
214
|
var tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
@@ -67,7 +67,9 @@ var getPureDesignSystemConfig = function(designSystemConfig) {
|
|
67
67
|
var getTailwindConfig = function(tailwindVersion, tailwindcss, designSystem) {
|
68
68
|
var option = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
69
69
|
var purgeConfig = merge({
|
70
|
+
// TODO: how the operating environment is determined
|
70
71
|
enabled: process.env.NODE_ENV === "production",
|
72
|
+
// TODO: Remove or not
|
71
73
|
layers: [
|
72
74
|
"utilities"
|
73
75
|
],
|
@@ -1,23 +1,3 @@
|
|
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
1
|
import path from "path";
|
22
2
|
import {
|
23
3
|
PLUGIN_SCHEMAS,
|
@@ -49,15 +29,16 @@ var cli_default = ({ pluginName } = {
|
|
49
29
|
pluginName: "@modern-js/plugin-tailwindcss"
|
50
30
|
}) => ({
|
51
31
|
name: "@modern-js/plugin-tailwindcss",
|
32
|
+
// support designSystem.supportStyledComponents
|
52
33
|
usePlugins: [
|
53
34
|
designTokenPlugin({
|
54
35
|
pluginName
|
55
36
|
})
|
56
37
|
],
|
57
|
-
setup: (api) =>
|
38
|
+
setup: async (api) => {
|
58
39
|
const { appDirectory, internalDirectory } = api.useAppContext();
|
59
40
|
let internalTwConfigPath = "";
|
60
|
-
const haveTwinMacro =
|
41
|
+
const haveTwinMacro = await checkTwinMacroExist(appDirectory);
|
61
42
|
const tailwindPath = getTailwindPath(appDirectory);
|
62
43
|
const tailwindVersion = getTailwindVersion(appDirectory);
|
63
44
|
const defaultContent = [
|
@@ -68,6 +49,7 @@ var cli_default = ({ pluginName } = {
|
|
68
49
|
"./src/**/*.jsx",
|
69
50
|
"./src/**/*.ts",
|
70
51
|
"./src/**/*.tsx",
|
52
|
+
// about storybook
|
71
53
|
"./storybook/**/*"
|
72
54
|
];
|
73
55
|
return {
|
@@ -116,6 +98,8 @@ var cli_default = ({ pluginName } = {
|
|
116
98
|
};
|
117
99
|
return {
|
118
100
|
tools: {
|
101
|
+
// TODO: Add interface about postcss config
|
102
|
+
// TODO: In module project, also is called, but should not be called.
|
119
103
|
postcss: (config) => {
|
120
104
|
initTailwindConfig();
|
121
105
|
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
@@ -166,7 +150,7 @@ var cli_default = ({ pluginName } = {
|
|
166
150
|
return config;
|
167
151
|
}
|
168
152
|
};
|
169
|
-
}
|
153
|
+
}
|
170
154
|
});
|
171
155
|
export {
|
172
156
|
cli_default as default,
|
@@ -1,19 +1,3 @@
|
|
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
1
|
import {
|
18
2
|
lazyImport,
|
19
3
|
PLUGIN_SCHEMAS,
|
@@ -27,7 +11,7 @@ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss
|
|
27
11
|
const PLUGIN_IDENTIFIER = "designToken";
|
28
12
|
const getDesignTokens = (designSystem) => {
|
29
13
|
const tailwindcssConfig = {};
|
30
|
-
tailwindcssConfig.theme = designSystem ?
|
14
|
+
tailwindcssConfig.theme = designSystem ? { ...designSystem } : {};
|
31
15
|
if (!designSystem) {
|
32
16
|
tailwindcssConfig.presets = [];
|
33
17
|
}
|
@@ -49,7 +33,12 @@ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss
|
|
49
33
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
50
34
|
}
|
51
35
|
},
|
52
|
-
tools: {
|
36
|
+
tools: {
|
37
|
+
// TODO: support less、scss、css vars
|
38
|
+
// less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
|
39
|
+
// sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
|
40
|
+
// postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
|
41
|
+
}
|
53
42
|
};
|
54
43
|
},
|
55
44
|
modifyEntryImports({ entrypoint, imports }) {
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import hoistNonReactStatics from "hoist-non-react-statics";
|
3
|
+
import React, { useContext } from "react";
|
4
|
+
const DesignTokenContext = React.createContext({});
|
5
|
+
const useDesignTokens = () => useContext(DesignTokenContext);
|
6
|
+
var plugin_default = (options = {}) => ({
|
7
|
+
name: "@modern-js/plugin-design-token",
|
8
|
+
setup: () => ({
|
9
|
+
hoc({ App }, next) {
|
10
|
+
const DesignTokenAppWrapper = (props) => {
|
11
|
+
const {
|
12
|
+
token = {},
|
13
|
+
useStyledComponentsThemeProvider = false,
|
14
|
+
useDesignTokenContext = false
|
15
|
+
} = options;
|
16
|
+
if (useStyledComponentsThemeProvider && useDesignTokenContext) {
|
17
|
+
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
18
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme: token, children: /* @__PURE__ */ jsx(DesignTokenContext.Provider, { value: token, children: /* @__PURE__ */ jsx(App, { ...props }) }) });
|
19
|
+
} else if (useStyledComponentsThemeProvider) {
|
20
|
+
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
21
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme: token, children: /* @__PURE__ */ jsx(App, { ...props }) });
|
22
|
+
} else if (useDesignTokenContext) {
|
23
|
+
return /* @__PURE__ */ jsx(DesignTokenContext.Provider, { value: token, children: /* @__PURE__ */ jsx(App, { ...props }) });
|
24
|
+
} else {
|
25
|
+
return /* @__PURE__ */ jsx(App, { ...props });
|
26
|
+
}
|
27
|
+
};
|
28
|
+
return next({
|
29
|
+
App: hoistNonReactStatics(DesignTokenAppWrapper, App)
|
30
|
+
});
|
31
|
+
}
|
32
|
+
})
|
33
|
+
});
|
34
|
+
export {
|
35
|
+
DesignTokenContext,
|
36
|
+
plugin_default as default,
|
37
|
+
useDesignTokens
|
38
|
+
};
|
@@ -16,7 +16,9 @@ const getPureDesignSystemConfig = (designSystemConfig) => {
|
|
16
16
|
const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
|
17
17
|
const purgeConfig = merge(
|
18
18
|
{
|
19
|
+
// TODO: how the operating environment is determined
|
19
20
|
enabled: process.env.NODE_ENV === "production",
|
21
|
+
// TODO: Remove or not
|
20
22
|
layers: ["utilities"],
|
21
23
|
content: []
|
22
24
|
},
|
@@ -1,23 +1,3 @@
|
|
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
1
|
import path from "path";
|
22
2
|
import { fs } from "@modern-js/utils";
|
23
3
|
const template = (configPath) => `
|
@@ -41,14 +21,14 @@ module.exports = {
|
|
41
21
|
};
|
42
22
|
`;
|
43
23
|
const TWIN_MACRO_NAME = "twin.macro";
|
44
|
-
const checkTwinMacroExist = (appDirectory) =>
|
45
|
-
const packageJson =
|
24
|
+
const checkTwinMacroExist = async (appDirectory) => {
|
25
|
+
const packageJson = await fs.readJSON(path.join(appDirectory, "package.json"), {
|
46
26
|
throws: false
|
47
|
-
})
|
27
|
+
}) || {};
|
48
28
|
return Boolean(
|
49
29
|
typeof packageJson.dependencies === "object" && packageJson.dependencies[TWIN_MACRO_NAME] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[TWIN_MACRO_NAME]
|
50
30
|
);
|
51
|
-
}
|
31
|
+
};
|
52
32
|
const getTwinMacroMajorVersion = (appDirectory) => {
|
53
33
|
try {
|
54
34
|
const pkgJsonPath = require.resolve(`${TWIN_MACRO_NAME}/package.json`, {
|
package/package.json
CHANGED
@@ -11,28 +11,27 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.6.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
|
-
"main": "./dist/
|
18
|
-
"module": "./dist/
|
19
|
-
"jsnext:modern": "./dist/js/modern/index.js",
|
17
|
+
"main": "./dist/cjs/index.js",
|
18
|
+
"module": "./dist/esm/index.js",
|
20
19
|
"exports": {
|
21
20
|
".": {
|
22
21
|
"node": {
|
23
22
|
"jsnext:source": "./src/index.ts",
|
24
|
-
"require": "./dist/
|
23
|
+
"require": "./dist/cjs/index.js"
|
25
24
|
},
|
26
|
-
"default": "./dist/
|
25
|
+
"default": "./dist/cjs/index.js"
|
27
26
|
},
|
28
27
|
"./cli": {
|
29
28
|
"jsnext:source": "./src/cli.ts",
|
30
|
-
"default": "./dist/
|
29
|
+
"default": "./dist/cjs/cli.js"
|
31
30
|
},
|
32
31
|
"./runtime-design-token": {
|
33
32
|
"jsnext:source": "./src/design-token/index.js",
|
34
|
-
"node": "./dist/
|
35
|
-
"default": "./dist/
|
33
|
+
"node": "./dist/cjs/design-token/index.js",
|
34
|
+
"default": "./dist/esm/design-token/index.js"
|
36
35
|
}
|
37
36
|
},
|
38
37
|
"typesVersions": {
|
@@ -46,7 +45,7 @@
|
|
46
45
|
"@babel/runtime": "^7.18.0",
|
47
46
|
"babel-plugin-macros": "3.1.0",
|
48
47
|
"hoist-non-react-statics": "^3.3.2",
|
49
|
-
"@modern-js/utils": "2.
|
48
|
+
"@modern-js/utils": "2.6.0"
|
50
49
|
},
|
51
50
|
"devDependencies": {
|
52
51
|
"@types/jest": "^27",
|
@@ -56,17 +55,17 @@
|
|
56
55
|
"jest": "^27",
|
57
56
|
"react": "^18",
|
58
57
|
"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": "
|
65
|
-
"@scripts/jest-config": "2.
|
58
|
+
"@modern-js/core": "2.6.0",
|
59
|
+
"@modern-js/module-tools": "2.6.0",
|
60
|
+
"@modern-js/runtime": "2.6.0",
|
61
|
+
"@modern-js/types": "2.6.0",
|
62
|
+
"@scripts/build": "2.6.0",
|
63
|
+
"@modern-js/app-tools": "2.6.0",
|
64
|
+
"@scripts/jest-config": "2.6.0"
|
66
65
|
},
|
67
66
|
"peerDependencies": {
|
68
67
|
"tailwindcss": ">= 2.0.0 || >= 3.0.0",
|
69
|
-
"@modern-js/runtime": "^2.
|
68
|
+
"@modern-js/runtime": "^2.6.0"
|
70
69
|
},
|
71
70
|
"peerDependenciesMeta": {
|
72
71
|
"@modern-js/runtime": {
|
@@ -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
|
-
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|