@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.4
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 +97 -0
- package/dist/js/modern/cli.js +132 -79
- package/dist/js/modern/design-token/cli/index.js +57 -51
- package/dist/js/modern/design-token/global.d.js +0 -0
- package/dist/js/modern/design-token/index.js +5 -2
- package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
- package/dist/js/modern/design-token/runtime/index.js +4 -1
- package/dist/js/modern/design-token/runtime/plugin.js +41 -29
- package/dist/js/modern/index.js +4 -1
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/tailwind.js +28 -21
- package/dist/js/modern/utils.js +32 -8
- package/dist/js/node/cli.js +152 -90
- package/dist/js/node/design-token/cli/index.js +70 -56
- package/dist/js/node/design-token/global.d.js +0 -0
- package/dist/js/node/design-token/index.js +29 -24
- package/dist/js/node/design-token/postcss-plugin/index.js +28 -13
- package/dist/js/node/design-token/runtime/index.js +31 -22
- package/dist/js/node/design-token/runtime/plugin.js +65 -40
- package/dist/js/node/index.js +27 -11
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/tailwind.js +47 -27
- package/dist/js/node/utils.js +56 -16
- package/dist/js/treeshaking/cli.js +265 -132
- package/dist/js/treeshaking/design-token/cli/index.js +116 -99
- package/dist/js/treeshaking/design-token/global.d.js +1 -0
- package/dist/js/treeshaking/design-token/index.js +3 -2
- package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
- package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
- package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
- package/dist/js/treeshaking/index.js +2 -1
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/tailwind.js +86 -42
- package/dist/js/treeshaking/types.js +1 -0
- package/dist/js/treeshaking/utils.js +159 -44
- package/dist/types/cli.d.ts +3 -1
- package/dist/types/design-token/cli/index.d.ts +2 -0
- package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
- package/dist/types/design-token/runtime/plugin.d.ts +2 -0
- package/package.json +11 -10
@@ -1,33 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
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 stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
default: () => cli_default
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
var
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
var
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
var import_utils = require("@modern-js/utils");
|
24
|
+
var __defProp2 = Object.defineProperty;
|
25
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
26
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
27
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
28
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
29
|
+
var __spreadValues = (a, b) => {
|
30
|
+
for (var prop in b || (b = {}))
|
31
|
+
if (__hasOwnProp2.call(b, prop))
|
32
|
+
__defNormalProp(a, prop, b[prop]);
|
33
|
+
if (__getOwnPropSymbols)
|
34
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
35
|
+
if (__propIsEnum.call(b, prop))
|
36
|
+
__defNormalProp(a, prop, b[prop]);
|
37
|
+
}
|
38
|
+
return a;
|
39
|
+
};
|
40
|
+
var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
|
41
|
+
name: "@modern-js/plugin-design-token",
|
17
42
|
setup(api) {
|
18
43
|
let pluginsExportsUtils;
|
19
|
-
const resolveConfig = (0,
|
20
|
-
const PLUGIN_IDENTIFIER =
|
21
|
-
const getDesignTokens = designSystem => {
|
44
|
+
const resolveConfig = (0, import_utils.lazyImport)("tailwindcss/resolveConfig", require);
|
45
|
+
const PLUGIN_IDENTIFIER = "designToken";
|
46
|
+
const getDesignTokens = (designSystem) => {
|
22
47
|
const tailwindcssConfig = {};
|
23
|
-
tailwindcssConfig.theme = designSystem ?
|
24
|
-
|
25
|
-
// not use default design token when designToken.defaultTheme is false or theme is false
|
48
|
+
tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
|
26
49
|
if (!designSystem) {
|
27
50
|
tailwindcssConfig.presets = [];
|
28
51
|
}
|
29
|
-
|
30
|
-
// when only designSystem exist, need remove supportStyledComponents
|
31
52
|
if (designSystem) {
|
32
53
|
delete tailwindcssConfig.theme.supportStyledComponents;
|
33
54
|
}
|
@@ -36,35 +57,32 @@ var _default = ({
|
|
36
57
|
return {
|
37
58
|
config() {
|
38
59
|
const appContext = api.useAppContext();
|
39
|
-
pluginsExportsUtils = (0,
|
60
|
+
pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
|
61
|
+
appContext.internalDirectory,
|
62
|
+
"plugins"
|
63
|
+
);
|
40
64
|
return {
|
41
65
|
source: {
|
42
66
|
alias: {
|
43
|
-
|
67
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
44
68
|
}
|
45
69
|
},
|
46
|
-
tools: {
|
47
|
-
// TODO: support less、scss、css vars
|
48
|
-
// less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
|
49
|
-
// sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
|
50
|
-
// postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
|
51
|
-
}
|
70
|
+
tools: {}
|
52
71
|
};
|
53
72
|
},
|
54
|
-
modifyEntryImports({
|
55
|
-
|
56
|
-
imports
|
57
|
-
}) {
|
58
|
-
var _userConfig$source$de, _userConfig$source;
|
73
|
+
modifyEntryImports({ entrypoint, imports }) {
|
74
|
+
var _a, _b;
|
59
75
|
const userConfig = api.useResolvedConfigContext();
|
60
|
-
const designSystem = (
|
61
|
-
if (typeof designSystem ===
|
76
|
+
const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
|
77
|
+
if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
|
62
78
|
const designTokens = getDesignTokens(userConfig.source.designSystem);
|
63
79
|
imports.push({
|
64
|
-
value:
|
65
|
-
specifiers: [
|
66
|
-
|
67
|
-
|
80
|
+
value: "@modern-js/runtime/plugins",
|
81
|
+
specifiers: [
|
82
|
+
{
|
83
|
+
imported: PLUGIN_IDENTIFIER
|
84
|
+
}
|
85
|
+
],
|
68
86
|
initialize: `
|
69
87
|
const designTokens = ${JSON.stringify(designTokens)};
|
70
88
|
`
|
@@ -75,22 +93,18 @@ var _default = ({
|
|
75
93
|
imports
|
76
94
|
};
|
77
95
|
},
|
78
|
-
modifyEntryRuntimePlugins({
|
79
|
-
|
80
|
-
plugins
|
81
|
-
}) {
|
82
|
-
var _userConfig$source$de2, _userConfig$source2;
|
96
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
97
|
+
var _a, _b;
|
83
98
|
const userConfig = api.useResolvedConfigContext();
|
84
|
-
const designSystem = (
|
99
|
+
const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
|
85
100
|
let useSCThemeProvider = true;
|
86
101
|
if (designSystem) {
|
87
|
-
|
88
|
-
useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
|
102
|
+
useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
|
89
103
|
}
|
90
|
-
if (typeof designSystem ===
|
104
|
+
if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
|
91
105
|
plugins.push({
|
92
106
|
name: PLUGIN_IDENTIFIER,
|
93
|
-
options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ?
|
107
|
+
options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
|
94
108
|
});
|
95
109
|
}
|
96
110
|
return {
|
@@ -99,13 +113,13 @@ var _default = ({
|
|
99
113
|
};
|
100
114
|
},
|
101
115
|
validateSchema() {
|
102
|
-
|
103
|
-
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
|
116
|
+
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
|
104
117
|
},
|
105
118
|
addRuntimeExports() {
|
106
|
-
pluginsExportsUtils.addExport(
|
119
|
+
pluginsExportsUtils.addExport(
|
120
|
+
`export { default as designToken } from '${pluginName}/runtime-design-token'`
|
121
|
+
);
|
107
122
|
}
|
108
123
|
};
|
109
124
|
}
|
110
125
|
});
|
111
|
-
exports.default = _default;
|
File without changes
|
@@ -1,26 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
5
|
-
|
6
|
-
var
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
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 });
|
11
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
|
+
var stdin_exports = {};
|
26
|
+
__export(stdin_exports, {
|
27
|
+
default: () => import_runtime.default
|
12
28
|
});
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
17
|
-
if (key in exports && exports[key] === _runtime[key]) return;
|
18
|
-
Object.defineProperty(exports, key, {
|
19
|
-
enumerable: true,
|
20
|
-
get: function () {
|
21
|
-
return _runtime[key];
|
22
|
-
}
|
23
|
-
});
|
24
|
-
});
|
25
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
29
|
+
module.exports = __toCommonJS(stdin_exports);
|
30
|
+
var import_runtime = __toESM(require("./runtime"));
|
31
|
+
__reExport(stdin_exports, require("./runtime"), module.exports);
|
@@ -1,22 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
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 stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
default: () => postcss_plugin_default
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
var
|
8
|
-
cssVarsHash
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
var postcss_plugin_default = ({
|
24
|
+
cssVarsHash = {}
|
9
25
|
} = {}) => ({
|
10
|
-
postcssPlugin:
|
26
|
+
postcssPlugin: "postcss-replace-css-vars",
|
11
27
|
Declaration(decl) {
|
12
|
-
if (decl.value && typeof decl.value ===
|
13
|
-
decl.value = decl.value.replace(/--\S*/g, match => {
|
14
|
-
if (
|
15
|
-
return
|
28
|
+
if (decl.value && typeof decl.value === "string") {
|
29
|
+
decl.value = decl.value.replace(/--\S*/g, (match) => {
|
30
|
+
if (cssVarsHash[match]) {
|
31
|
+
return cssVarsHash[match];
|
16
32
|
}
|
17
33
|
return match;
|
18
34
|
});
|
19
35
|
}
|
20
36
|
}
|
21
37
|
});
|
22
|
-
exports.default = _default;
|
@@ -1,23 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
|
+
var stdin_exports = {};
|
26
|
+
__export(stdin_exports, {
|
27
|
+
default: () => runtime_default
|
5
28
|
});
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
11
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
12
|
-
if (key in exports && exports[key] === _plugin[key]) return;
|
13
|
-
Object.defineProperty(exports, key, {
|
14
|
-
enumerable: true,
|
15
|
-
get: function () {
|
16
|
-
return _plugin[key];
|
17
|
-
}
|
18
|
-
});
|
19
|
-
});
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
22
|
-
var _default = _plugin.default;
|
23
|
-
exports.default = _default;
|
29
|
+
module.exports = __toCommonJS(stdin_exports);
|
30
|
+
var import_plugin = __toESM(require("./plugin"));
|
31
|
+
__reExport(stdin_exports, require("./plugin"), module.exports);
|
32
|
+
var runtime_default = import_plugin.default;
|
@@ -1,66 +1,91 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var stdin_exports = {};
|
25
|
+
__export(stdin_exports, {
|
26
|
+
DesignTokenContext: () => DesignTokenContext,
|
27
|
+
default: () => plugin_default,
|
28
|
+
useDesignTokens: () => useDesignTokens
|
5
29
|
});
|
6
|
-
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
var
|
21
|
-
|
30
|
+
module.exports = __toCommonJS(stdin_exports);
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
32
|
+
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
33
|
+
var import_react = __toESM(require("react"));
|
34
|
+
var __defProp2 = Object.defineProperty;
|
35
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
36
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
37
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
38
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
39
|
+
var __spreadValues = (a, b) => {
|
40
|
+
for (var prop in b || (b = {}))
|
41
|
+
if (__hasOwnProp2.call(b, prop))
|
42
|
+
__defNormalProp(a, prop, b[prop]);
|
43
|
+
if (__getOwnPropSymbols)
|
44
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
45
|
+
if (__propIsEnum.call(b, prop))
|
46
|
+
__defNormalProp(a, prop, b[prop]);
|
47
|
+
}
|
48
|
+
return a;
|
49
|
+
};
|
50
|
+
const DesignTokenContext = import_react.default.createContext({});
|
51
|
+
const useDesignTokens = () => (0, import_react.useContext)(DesignTokenContext);
|
52
|
+
var plugin_default = (options = {}) => ({
|
53
|
+
name: "@modern-js/plugin-design-token",
|
22
54
|
setup: () => ({
|
23
|
-
hoc({
|
24
|
-
|
25
|
-
}, next) {
|
26
|
-
const DesignTokenAppWrapper = props => {
|
55
|
+
hoc({ App }, next) {
|
56
|
+
const DesignTokenAppWrapper = (props) => {
|
27
57
|
const {
|
28
58
|
token = {},
|
29
59
|
useStyledComponentsThemeProvider = false,
|
30
60
|
useDesignTokenContext = false
|
31
61
|
} = options;
|
32
62
|
if (useStyledComponentsThemeProvider && useDesignTokenContext) {
|
33
|
-
const {
|
34
|
-
|
35
|
-
} = require('@modern-js/runtime/styled');
|
36
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
|
63
|
+
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
|
37
65
|
theme: token,
|
38
|
-
children:
|
66
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
|
39
67
|
value: token,
|
40
|
-
children:
|
68
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
41
69
|
})
|
42
70
|
});
|
43
71
|
} else if (useStyledComponentsThemeProvider) {
|
44
|
-
const {
|
45
|
-
|
46
|
-
} = require('@modern-js/runtime/styled');
|
47
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
|
72
|
+
const { ThemeProvider } = require("@modern-js/runtime/styled");
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
|
48
74
|
theme: token,
|
49
|
-
children:
|
75
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
50
76
|
});
|
51
77
|
} else if (useDesignTokenContext) {
|
52
|
-
return
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
|
53
79
|
value: token,
|
54
|
-
children:
|
80
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
|
55
81
|
});
|
56
82
|
} else {
|
57
|
-
return
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props));
|
58
84
|
}
|
59
85
|
};
|
60
86
|
return next({
|
61
|
-
App: (0,
|
87
|
+
App: (0, import_hoist_non_react_statics.default)(DesignTokenAppWrapper, App)
|
62
88
|
});
|
63
89
|
}
|
64
90
|
})
|
65
91
|
});
|
66
|
-
exports.default = _default;
|
package/dist/js/node/index.js
CHANGED
@@ -1,13 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
5
|
-
|
6
|
-
Object.
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
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 });
|
10
16
|
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var stdin_exports = {};
|
25
|
+
__export(stdin_exports, {
|
26
|
+
default: () => import_cli.default
|
11
27
|
});
|
12
|
-
|
13
|
-
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
29
|
+
var import_cli = __toESM(require("./cli"));
|
File without changes
|
package/dist/js/node/tailwind.js
CHANGED
@@ -1,44 +1,64 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
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 stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
getTailwindConfig: () => getTailwindConfig
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
var
|
8
|
-
var
|
9
|
-
const checkIfExistNotAllowKeys = tailwindConfig => {
|
10
|
-
const notAllowExistKeys = [
|
11
|
-
let notAllowKey =
|
12
|
-
const ret = Object.keys(tailwindConfig).some(
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
var import_utils = require("@modern-js/utils");
|
24
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
25
|
+
const checkIfExistNotAllowKeys = (tailwindConfig) => {
|
26
|
+
const notAllowExistKeys = ["theme"];
|
27
|
+
let notAllowKey = "";
|
28
|
+
const ret = Object.keys(tailwindConfig).some(
|
29
|
+
(key) => notAllowExistKeys.includes(key) && (notAllowKey = key)
|
30
|
+
);
|
13
31
|
return [ret, notAllowKey];
|
14
32
|
};
|
15
|
-
const getPureDesignSystemConfig = designSystemConfig => {
|
16
|
-
const pureDesignSystemConfig = (0,
|
33
|
+
const getPureDesignSystemConfig = (designSystemConfig) => {
|
34
|
+
const pureDesignSystemConfig = (0, import_lodash.cloneDeep)(designSystemConfig);
|
17
35
|
delete pureDesignSystemConfig.supportStyledComponents;
|
18
36
|
return pureDesignSystemConfig;
|
19
37
|
};
|
20
38
|
const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
21
|
-
const purgeConfig = (0,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
39
|
+
const purgeConfig = (0, import_lodash.merge)(
|
40
|
+
{
|
41
|
+
enabled: process.env.NODE_ENV === "production",
|
42
|
+
layers: ["utilities"],
|
43
|
+
content: []
|
44
|
+
},
|
45
|
+
option.pureConfig || {}
|
46
|
+
);
|
28
47
|
const defaultTailwindConfig = {
|
29
48
|
purge: purgeConfig
|
30
49
|
};
|
31
|
-
const tailwindConfig = (0,
|
32
|
-
|
50
|
+
const tailwindConfig = (0, import_utils.applyOptionsChain)(
|
51
|
+
defaultTailwindConfig,
|
52
|
+
tailwindcss || {}
|
53
|
+
);
|
54
|
+
const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
|
33
55
|
const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
|
34
56
|
if (exist) {
|
35
|
-
|
36
|
-
|
57
|
+
import_utils.logger.error(
|
58
|
+
`should not exist '${key}' on tools.tailwindcss, please remove it`
|
59
|
+
);
|
37
60
|
process.exit(0);
|
38
61
|
}
|
39
|
-
|
40
|
-
// Because there is no default theme configuration
|
41
62
|
tailwindConfig.theme = designSystemConfig || {};
|
42
63
|
return tailwindConfig;
|
43
64
|
};
|
44
|
-
exports.getTailwindConfig = getTailwindConfig;
|