@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.
Files changed (40) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/dist/js/modern/cli.js +132 -79
  3. package/dist/js/modern/design-token/cli/index.js +57 -51
  4. package/dist/js/modern/design-token/global.d.js +0 -0
  5. package/dist/js/modern/design-token/index.js +5 -2
  6. package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
  7. package/dist/js/modern/design-token/runtime/index.js +4 -1
  8. package/dist/js/modern/design-token/runtime/plugin.js +41 -29
  9. package/dist/js/modern/index.js +4 -1
  10. package/dist/js/modern/modern-app.env.d.js +0 -0
  11. package/dist/js/modern/tailwind.js +28 -21
  12. package/dist/js/modern/utils.js +32 -8
  13. package/dist/js/node/cli.js +152 -90
  14. package/dist/js/node/design-token/cli/index.js +70 -56
  15. package/dist/js/node/design-token/global.d.js +0 -0
  16. package/dist/js/node/design-token/index.js +29 -24
  17. package/dist/js/node/design-token/postcss-plugin/index.js +28 -13
  18. package/dist/js/node/design-token/runtime/index.js +31 -22
  19. package/dist/js/node/design-token/runtime/plugin.js +65 -40
  20. package/dist/js/node/index.js +27 -11
  21. package/dist/js/node/modern-app.env.d.js +0 -0
  22. package/dist/js/node/tailwind.js +47 -27
  23. package/dist/js/node/utils.js +56 -16
  24. package/dist/js/treeshaking/cli.js +265 -132
  25. package/dist/js/treeshaking/design-token/cli/index.js +116 -99
  26. package/dist/js/treeshaking/design-token/global.d.js +1 -0
  27. package/dist/js/treeshaking/design-token/index.js +3 -2
  28. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
  29. package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
  30. package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
  31. package/dist/js/treeshaking/index.js +2 -1
  32. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  33. package/dist/js/treeshaking/tailwind.js +86 -42
  34. package/dist/js/treeshaking/types.js +1 -0
  35. package/dist/js/treeshaking/utils.js +159 -44
  36. package/dist/types/cli.d.ts +3 -1
  37. package/dist/types/design-token/cli/index.d.ts +2 -0
  38. package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
  39. package/dist/types/design-token/runtime/plugin.d.ts +2 -0
  40. package/package.json +11 -10
@@ -1,33 +1,54 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.default = void 0;
7
- var _utils = require("@modern-js/utils");
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- var _default = ({
12
- pluginName
13
- } = {
14
- pluginName: '@modern-js/plugin-tailwindcss'
15
- }) => ({
16
- name: '@modern-js/plugin-design-token',
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, _utils.lazyImport)('tailwindcss/resolveConfig', require);
20
- const PLUGIN_IDENTIFIER = 'designToken';
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 ? _objectSpread({}, 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, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'plugins');
60
+ pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
61
+ appContext.internalDirectory,
62
+ "plugins"
63
+ );
40
64
  return {
41
65
  source: {
42
66
  alias: {
43
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
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
- entrypoint,
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 = (_userConfig$source$de = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
61
- if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
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: '@modern-js/runtime/plugins',
65
- specifiers: [{
66
- imported: PLUGIN_IDENTIFIER
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
- entrypoint,
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 = (_userConfig$source$de2 = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
99
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
85
100
  let useSCThemeProvider = true;
86
101
  if (designSystem) {
87
- // when designSystem exist, designToken.styledComponents`s default value is false.
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 === 'object' && designSystem.supportStyledComponents) {
104
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
91
105
  plugins.push({
92
106
  name: PLUGIN_IDENTIFIER,
93
- options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
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
- // add source.designSystem.supportStyledComponents config
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(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {};
7
- Object.defineProperty(exports, "default", {
8
- enumerable: true,
9
- get: function () {
10
- return _runtime.default;
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
- var _runtime = _interopRequireWildcard(require("./runtime"));
14
- Object.keys(_runtime).forEach(function (key) {
15
- if (key === "default" || key === "__esModule") return;
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.default = void 0;
7
- var _default = ({
8
- cssVarsHash: _cssVarsHash = {}
22
+ module.exports = __toCommonJS(stdin_exports);
23
+ var postcss_plugin_default = ({
24
+ cssVarsHash = {}
9
25
  } = {}) => ({
10
- postcssPlugin: 'postcss-replace-css-vars',
26
+ postcssPlugin: "postcss-replace-css-vars",
11
27
  Declaration(decl) {
12
- if (decl.value && typeof decl.value === 'string') {
13
- decl.value = decl.value.replace(/--\S*/g, match => {
14
- if (_cssVarsHash[match]) {
15
- return _cssVarsHash[match];
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- var _exportNames = {};
7
- exports.default = void 0;
8
- var _plugin = _interopRequireWildcard(require("./plugin"));
9
- Object.keys(_plugin).forEach(function (key) {
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- exports.useDesignTokens = exports.default = exports.DesignTokenContext = void 0;
7
- var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
8
- var _react = _interopRequireWildcard(require("react"));
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- 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); }
11
- 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; }
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- const DesignTokenContext = /*#__PURE__*/_react.default.createContext({});
17
- exports.DesignTokenContext = DesignTokenContext;
18
- const useDesignTokens = () => (0, _react.useContext)(DesignTokenContext);
19
- exports.useDesignTokens = useDesignTokens;
20
- var _default = (options = {}) => ({
21
- name: '@modern-js/plugin-design-token',
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
- App
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
- ThemeProvider
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: /*#__PURE__*/(0, _jsxRuntime.jsx)(DesignTokenContext.Provider, {
66
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
39
67
  value: token,
40
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
68
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
41
69
  })
42
70
  });
43
71
  } else if (useStyledComponentsThemeProvider) {
44
- const {
45
- ThemeProvider
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: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
75
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
50
76
  });
51
77
  } else if (useDesignTokenContext) {
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DesignTokenContext.Provider, {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
53
79
  value: token,
54
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
80
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
55
81
  });
56
82
  } else {
57
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props));
83
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props));
58
84
  }
59
85
  };
60
86
  return next({
61
- App: (0, _hoistNonReactStatics.default)(DesignTokenAppWrapper, App)
87
+ App: (0, import_hoist_non_react_statics.default)(DesignTokenAppWrapper, App)
62
88
  });
63
89
  }
64
90
  })
65
91
  });
66
- exports.default = _default;
@@ -1,13 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _cli.default;
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
- var _cli = _interopRequireDefault(require("./cli"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ module.exports = __toCommonJS(stdin_exports);
29
+ var import_cli = __toESM(require("./cli"));
File without changes
@@ -1,44 +1,64 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.getTailwindConfig = void 0;
7
- var _utils = require("@modern-js/utils");
8
- var _lodash = require("@modern-js/utils/lodash");
9
- const checkIfExistNotAllowKeys = tailwindConfig => {
10
- const notAllowExistKeys = ['theme'];
11
- let notAllowKey = '';
12
- const ret = Object.keys(tailwindConfig).some(key => notAllowExistKeys.includes(key) && (notAllowKey = key));
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, _lodash.cloneDeep)(designSystemConfig);
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, _lodash.merge)({
22
- // TODO: how the operating environment is determined
23
- enabled: process.env.NODE_ENV === 'production',
24
- // TODO: Remove or not
25
- layers: ['utilities'],
26
- content: []
27
- }, option.pureConfig || {});
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, _utils.applyOptionsChain)(defaultTailwindConfig, tailwindcss || {});
32
- const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
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
- _utils.logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
36
- // eslint-disable-next-line no-process-exit
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;