@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.6

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 (41) hide show
  1. package/CHANGELOG.md +197 -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 +156 -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 +31 -24
  17. package/dist/js/node/design-token/postcss-plugin/index.js +30 -13
  18. package/dist/js/node/design-token/runtime/index.js +33 -22
  19. package/dist/js/node/design-token/runtime/plugin.js +68 -40
  20. package/dist/js/node/index.js +29 -11
  21. package/dist/js/node/modern-app.env.d.js +0 -0
  22. package/dist/js/node/tailwind.js +51 -27
  23. package/dist/js/node/types.js +15 -0
  24. package/dist/js/node/utils.js +61 -16
  25. package/dist/js/treeshaking/cli.js +265 -132
  26. package/dist/js/treeshaking/design-token/cli/index.js +116 -99
  27. package/dist/js/treeshaking/design-token/global.d.js +1 -0
  28. package/dist/js/treeshaking/design-token/index.js +3 -2
  29. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
  30. package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
  31. package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
  32. package/dist/js/treeshaking/index.js +2 -1
  33. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  34. package/dist/js/treeshaking/tailwind.js +86 -42
  35. package/dist/js/treeshaking/types.js +1 -0
  36. package/dist/js/treeshaking/utils.js +159 -44
  37. package/dist/types/cli.d.ts +3 -1
  38. package/dist/types/design-token/cli/index.d.ts +2 -0
  39. package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
  40. package/dist/types/design-token/runtime/plugin.d.ts +2 -0
  41. package/package.json +11 -10
@@ -1,33 +1,52 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ 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
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var cli_exports = {};
33
+ __export(cli_exports, {
34
+ default: () => cli_default
5
35
  });
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',
36
+ module.exports = __toCommonJS(cli_exports);
37
+ var import_utils = require("@modern-js/utils");
38
+ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
39
+ name: "@modern-js/plugin-design-token",
17
40
  setup(api) {
18
41
  let pluginsExportsUtils;
19
- const resolveConfig = (0, _utils.lazyImport)('tailwindcss/resolveConfig', require);
20
- const PLUGIN_IDENTIFIER = 'designToken';
21
- const getDesignTokens = designSystem => {
42
+ const resolveConfig = (0, import_utils.lazyImport)("tailwindcss/resolveConfig", require);
43
+ const PLUGIN_IDENTIFIER = "designToken";
44
+ const getDesignTokens = (designSystem) => {
22
45
  const tailwindcssConfig = {};
23
- tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
24
-
25
- // not use default design token when designToken.defaultTheme is false or theme is false
46
+ tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
26
47
  if (!designSystem) {
27
48
  tailwindcssConfig.presets = [];
28
49
  }
29
-
30
- // when only designSystem exist, need remove supportStyledComponents
31
50
  if (designSystem) {
32
51
  delete tailwindcssConfig.theme.supportStyledComponents;
33
52
  }
@@ -36,35 +55,32 @@ var _default = ({
36
55
  return {
37
56
  config() {
38
57
  const appContext = api.useAppContext();
39
- pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'plugins');
58
+ pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
59
+ appContext.internalDirectory,
60
+ "plugins"
61
+ );
40
62
  return {
41
63
  source: {
42
64
  alias: {
43
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
65
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
44
66
  }
45
67
  },
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
- }
68
+ tools: {}
52
69
  };
53
70
  },
54
- modifyEntryImports({
55
- entrypoint,
56
- imports
57
- }) {
58
- var _userConfig$source$de, _userConfig$source;
71
+ modifyEntryImports({ entrypoint, imports }) {
72
+ var _a, _b;
59
73
  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) {
74
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
75
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
62
76
  const designTokens = getDesignTokens(userConfig.source.designSystem);
63
77
  imports.push({
64
- value: '@modern-js/runtime/plugins',
65
- specifiers: [{
66
- imported: PLUGIN_IDENTIFIER
67
- }],
78
+ value: "@modern-js/runtime/plugins",
79
+ specifiers: [
80
+ {
81
+ imported: PLUGIN_IDENTIFIER
82
+ }
83
+ ],
68
84
  initialize: `
69
85
  const designTokens = ${JSON.stringify(designTokens)};
70
86
  `
@@ -75,22 +91,18 @@ var _default = ({
75
91
  imports
76
92
  };
77
93
  },
78
- modifyEntryRuntimePlugins({
79
- entrypoint,
80
- plugins
81
- }) {
82
- var _userConfig$source$de2, _userConfig$source2;
94
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
95
+ var _a, _b;
83
96
  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 : {};
97
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
85
98
  let useSCThemeProvider = true;
86
99
  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;
100
+ useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
89
101
  }
90
- if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
102
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
91
103
  plugins.push({
92
104
  name: PLUGIN_IDENTIFIER,
93
- options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
105
+ options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
94
106
  });
95
107
  }
96
108
  return {
@@ -99,13 +111,15 @@ var _default = ({
99
111
  };
100
112
  },
101
113
  validateSchema() {
102
- // add source.designSystem.supportStyledComponents config
103
- return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
114
+ return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
104
115
  },
105
116
  addRuntimeExports() {
106
- pluginsExportsUtils.addExport(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
117
+ pluginsExportsUtils.addExport(
118
+ `export { default as designToken } from '${pluginName}/runtime-design-token'`
119
+ );
107
120
  }
108
121
  };
109
122
  }
110
123
  });
111
- exports.default = _default;
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {});
File without changes
@@ -1,26 +1,33 @@
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 design_token_exports = {};
26
+ __export(design_token_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(design_token_exports);
30
+ var import_runtime = __toESM(require("./runtime"));
31
+ __reExport(design_token_exports, require("./runtime"), module.exports);
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {});
@@ -1,22 +1,39 @@
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 postcss_plugin_exports = {};
19
+ __export(postcss_plugin_exports, {
20
+ default: () => postcss_plugin_default
5
21
  });
6
- exports.default = void 0;
7
- var _default = ({
8
- cssVarsHash: _cssVarsHash = {}
22
+ module.exports = __toCommonJS(postcss_plugin_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;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {});
@@ -1,23 +1,34 @@
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 runtime_exports = {};
26
+ __export(runtime_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(runtime_exports);
30
+ var import_plugin = __toESM(require("./plugin"));
31
+ __reExport(runtime_exports, require("./plugin"), module.exports);
32
+ var runtime_default = import_plugin.default;
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {});
@@ -1,66 +1,94 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ 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
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var plugin_exports = {};
39
+ __export(plugin_exports, {
40
+ DesignTokenContext: () => DesignTokenContext,
41
+ default: () => plugin_default,
42
+ useDesignTokens: () => useDesignTokens
5
43
  });
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',
44
+ module.exports = __toCommonJS(plugin_exports);
45
+ var import_jsx_runtime = require("react/jsx-runtime");
46
+ var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
47
+ var import_react = __toESM(require("react"));
48
+ const DesignTokenContext = import_react.default.createContext({});
49
+ const useDesignTokens = () => (0, import_react.useContext)(DesignTokenContext);
50
+ var plugin_default = (options = {}) => ({
51
+ name: "@modern-js/plugin-design-token",
22
52
  setup: () => ({
23
- hoc({
24
- App
25
- }, next) {
26
- const DesignTokenAppWrapper = props => {
53
+ hoc({ App }, next) {
54
+ const DesignTokenAppWrapper = (props) => {
27
55
  const {
28
56
  token = {},
29
57
  useStyledComponentsThemeProvider = false,
30
58
  useDesignTokenContext = false
31
59
  } = options;
32
60
  if (useStyledComponentsThemeProvider && useDesignTokenContext) {
33
- const {
34
- ThemeProvider
35
- } = require('@modern-js/runtime/styled');
36
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
61
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
37
63
  theme: token,
38
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DesignTokenContext.Provider, {
64
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
39
65
  value: token,
40
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
66
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
41
67
  })
42
68
  });
43
69
  } else if (useStyledComponentsThemeProvider) {
44
- const {
45
- ThemeProvider
46
- } = require('@modern-js/runtime/styled');
47
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
70
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
48
72
  theme: token,
49
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
73
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
50
74
  });
51
75
  } else if (useDesignTokenContext) {
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DesignTokenContext.Provider, {
76
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
53
77
  value: token,
54
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
78
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
55
79
  });
56
80
  } else {
57
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props));
81
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props));
58
82
  }
59
83
  };
60
84
  return next({
61
- App: (0, _hoistNonReactStatics.default)(DesignTokenAppWrapper, App)
85
+ App: (0, import_hoist_non_react_statics.default)(DesignTokenAppWrapper, App)
62
86
  });
63
87
  }
64
88
  })
65
89
  });
66
- exports.default = _default;
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ DesignTokenContext,
93
+ useDesignTokens
94
+ });
@@ -1,13 +1,31 @@
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 src_exports = {};
25
+ __export(src_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(src_exports);
29
+ var import_cli = __toESM(require("./cli"));
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {});
File without changes
@@ -1,44 +1,68 @@
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 tailwind_exports = {};
19
+ __export(tailwind_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(tailwind_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;
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ getTailwindConfig
68
+ });