@modern-js/plugin-tailwindcss 2.35.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/cli.js CHANGED
@@ -1,59 +1,73 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- tailwindcssPlugin: function() {
14
- return tailwindcssPlugin;
15
- },
16
- default: function() {
17
- return _default;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var cli_exports = {};
30
+ __export(cli_exports, {
31
+ default: () => cli_default,
32
+ tailwindcssPlugin: () => tailwindcssPlugin
19
33
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
- const _utils = require("@modern-js/utils");
23
- const _cli = require("./design-token/cli");
24
- const _config = require("./config");
25
- const _utils1 = require("./utils");
26
- const _macro = require("./macro");
34
+ module.exports = __toCommonJS(cli_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("@modern-js/utils");
37
+ var import_cli = require("./design-token/cli");
38
+ var import_config = require("./config");
39
+ var import_utils2 = require("./utils");
40
+ var import_macro = require("./macro");
27
41
  const tailwindcssPlugin = ({ pluginName } = {
28
42
  pluginName: "@modern-js/plugin-tailwindcss"
29
43
  }) => ({
30
44
  name: "@modern-js/plugin-tailwindcss",
31
45
  // support designSystem.supportStyledComponents
32
46
  usePlugins: [
33
- (0, _cli.designTokenPlugin)({
47
+ (0, import_cli.designTokenPlugin)({
34
48
  pluginName
35
49
  })
36
50
  ],
37
51
  setup: async (api) => {
38
52
  const { appDirectory, internalDirectory } = api.useAppContext();
39
53
  let internalTwConfigPath = "";
40
- const haveTwinMacro = await (0, _macro.checkTwinMacroExist)(appDirectory);
41
- const tailwindPath = (0, _utils1.getTailwindPath)(appDirectory);
42
- const tailwindVersion = (0, _utils1.getTailwindVersion)(appDirectory);
43
- const userTailwindConfig = await (0, _config.loadConfigFile)(appDirectory);
54
+ const haveTwinMacro = await (0, import_macro.checkTwinMacroExist)(appDirectory);
55
+ const tailwindPath = (0, import_utils2.getTailwindPath)(appDirectory);
56
+ const tailwindVersion = (0, import_utils2.getTailwindVersion)(appDirectory);
57
+ const userTailwindConfig = await (0, import_config.loadConfigFile)(appDirectory);
44
58
  return {
45
59
  prepare() {
46
60
  if (haveTwinMacro) {
47
- const twinMajorVersion = (0, _macro.getTwinMacroMajorVersion)(appDirectory);
61
+ const twinMajorVersion = (0, import_macro.getTwinMacroMajorVersion)(appDirectory);
48
62
  const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
49
63
  if (useConfigPath) {
50
- internalTwConfigPath = (0, _macro.getRandomTwConfigFileName)(internalDirectory);
51
- const globPattern = (0, _utils.slash)(_path.default.join(appDirectory, _utils.CONFIG_CACHE_DIR, "*.cjs"));
52
- const files = _utils.globby.sync(globPattern, {
64
+ internalTwConfigPath = (0, import_macro.getRandomTwConfigFileName)(internalDirectory);
65
+ const globPattern = (0, import_utils.slash)(import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR, "*.cjs"));
66
+ const files = import_utils.globby.sync(globPattern, {
53
67
  absolute: true
54
68
  });
55
69
  if (files.length > 0) {
56
- _utils.fs.writeFileSync(internalTwConfigPath, (0, _macro.template)(files[files.length - 1]), "utf-8");
70
+ import_utils.fs.writeFileSync(internalTwConfigPath, (0, import_macro.template)(files[files.length - 1]), "utf-8");
57
71
  }
58
72
  }
59
73
  }
@@ -75,14 +89,14 @@ const tailwindcssPlugin = ({ pluginName } = {
75
89
  let tailwindConfig;
76
90
  const initTailwindConfig = () => {
77
91
  if (!tailwindConfig) {
78
- var _modernConfig_tools, _modernConfig, _modernConfig_source, _modernConfig1;
92
+ var _modernConfig_tools, _modernConfig_source;
79
93
  const modernConfig = api.useResolvedConfigContext();
80
- tailwindConfig = (0, _config.getTailwindConfig)({
94
+ tailwindConfig = (0, import_config.getTailwindConfig)({
81
95
  appDirectory,
82
96
  tailwindVersion,
83
97
  userConfig: userTailwindConfig,
84
- extraConfig: (_modernConfig = modernConfig) === null || _modernConfig === void 0 ? void 0 : (_modernConfig_tools = _modernConfig.tools) === null || _modernConfig_tools === void 0 ? void 0 : _modernConfig_tools.tailwindcss,
85
- designSystem: (_modernConfig1 = modernConfig) === null || _modernConfig1 === void 0 ? void 0 : (_modernConfig_source = _modernConfig1.source) === null || _modernConfig_source === void 0 ? void 0 : _modernConfig_source.designSystem
98
+ extraConfig: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_tools = modernConfig.tools) === null || _modernConfig_tools === void 0 ? void 0 : _modernConfig_tools.tailwindcss,
99
+ designSystem: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_source = modernConfig.source) === null || _modernConfig_source === void 0 ? void 0 : _modernConfig_source.designSystem
86
100
  });
87
101
  }
88
102
  };
@@ -121,7 +135,7 @@ const tailwindcssPlugin = ({ pluginName } = {
121
135
  },
122
136
  beforeBuildTask(config) {
123
137
  const modernConfig = api.useResolvedConfigContext();
124
- const tailwindConfig = (0, _config.getTailwindConfig)({
138
+ const tailwindConfig = (0, import_config.getTailwindConfig)({
125
139
  appDirectory,
126
140
  tailwindVersion,
127
141
  userConfig: userTailwindConfig,
@@ -136,13 +150,14 @@ const tailwindcssPlugin = ({ pluginName } = {
136
150
  tailwindPlugin
137
151
  ];
138
152
  }
139
- return config;
140
- },
141
- modifyLibuild(config, next) {
142
153
  config.transformCache = false;
143
- return next(config);
154
+ return config;
144
155
  }
145
156
  };
146
157
  }
147
158
  });
148
- const _default = tailwindcssPlugin;
159
+ var cli_default = tailwindcssPlugin;
160
+ // Annotate the CommonJS export names for ESM import in node:
161
+ 0 && (module.exports = {
162
+ tailwindcssPlugin
163
+ });
@@ -1,41 +1,55 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- loadConfigFile: function() {
14
- return loadConfigFile;
15
- },
16
- getTailwindConfig: function() {
17
- return getTailwindConfig;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var config_exports = {};
30
+ __export(config_exports, {
31
+ getTailwindConfig: () => getTailwindConfig,
32
+ loadConfigFile: () => loadConfigFile
19
33
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
- const _utils = require("@modern-js/utils");
23
- const _lodash = require("@modern-js/utils/lodash");
24
- const _nodebundlerequire = require("@modern-js/node-bundle-require");
34
+ module.exports = __toCommonJS(config_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("@modern-js/utils");
37
+ var import_lodash = require("@modern-js/utils/lodash");
38
+ var import_node_bundle_require = require("@modern-js/node-bundle-require");
25
39
  function getDefaultContent(appDirectory) {
26
40
  const defaultContent = [
27
41
  "./src/**/*.{js,jsx,ts,tsx}"
28
42
  ];
29
- if (_utils.fs.existsSync(_path.default.join(appDirectory, "storybook"))) {
43
+ if (import_utils.fs.existsSync(import_path.default.join(appDirectory, "storybook"))) {
30
44
  defaultContent.push("./storybook/**/*");
31
45
  }
32
- if (_utils.fs.existsSync(_path.default.join(appDirectory, "config/html"))) {
46
+ if (import_utils.fs.existsSync(import_path.default.join(appDirectory, "config/html"))) {
33
47
  defaultContent.push("./config/html/**/*.{html,ejs,hbs}");
34
48
  }
35
49
  return defaultContent;
36
50
  }
37
51
  const getPureDesignSystemConfig = (config) => {
38
- const pureConfig = (0, _lodash.cloneDeep)(config);
52
+ const pureConfig = (0, import_lodash.cloneDeep)(config);
39
53
  delete pureConfig.supportStyledComponents;
40
54
  return pureConfig;
41
55
  };
@@ -53,10 +67,10 @@ async function loadConfigFile(appDirectory) {
53
67
  "cjs",
54
68
  "mjs"
55
69
  ];
56
- const configs = extensions.map((ext) => _path.default.resolve(appDirectory, `tailwind.config.${ext}`));
57
- const configFile = (0, _utils.findExists)(configs);
70
+ const configs = extensions.map((ext) => import_path.default.resolve(appDirectory, `tailwind.config.${ext}`));
71
+ const configFile = (0, import_utils.findExists)(configs);
58
72
  if (configFile) {
59
- const mod = await (0, _nodebundlerequire.bundleRequire)(configFile);
73
+ const mod = await (0, import_node_bundle_require.bundleRequire)(configFile);
60
74
  return mod.default || mod;
61
75
  }
62
76
  return {};
@@ -69,10 +83,15 @@ const getTailwindConfig = ({ tailwindVersion, appDirectory, userConfig, extraCon
69
83
  purge: getV2PurgeConfig(content)
70
84
  };
71
85
  Object.assign(tailwindConfig, userConfig);
72
- tailwindConfig = extraConfig ? (0, _utils.applyOptionsChain)(tailwindConfig, extraConfig) : tailwindConfig;
86
+ tailwindConfig = extraConfig ? (0, import_utils.applyOptionsChain)(tailwindConfig, extraConfig) : tailwindConfig;
73
87
  const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
74
88
  if (designSystemConfig && Object.keys(designSystemConfig).length > 0) {
75
89
  tailwindConfig.theme = designSystemConfig;
76
90
  }
77
91
  return tailwindConfig;
78
92
  };
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ getTailwindConfig,
96
+ loadConfigFile
97
+ });
@@ -1,21 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "designTokenPlugin", {
6
- enumerable: true,
7
- get: function() {
8
- return designTokenPlugin;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var cli_exports = {};
20
+ __export(cli_exports, {
21
+ designTokenPlugin: () => designTokenPlugin
10
22
  });
11
- const _utils = require("@modern-js/utils");
23
+ module.exports = __toCommonJS(cli_exports);
24
+ var import_utils = require("@modern-js/utils");
12
25
  const designTokenPlugin = ({ pluginName } = {
13
26
  pluginName: "@modern-js/plugin-tailwindcss"
14
27
  }) => ({
15
28
  name: "@modern-js/plugin-design-token",
16
29
  setup(api) {
17
30
  let pluginsExportsUtils;
18
- const resolveConfig = (0, _utils.lazyImport)("tailwindcss/resolveConfig", require);
31
+ const resolveConfig = (0, import_utils.lazyImport)("tailwindcss/resolveConfig", require);
19
32
  const PLUGIN_IDENTIFIER = "designToken";
20
33
  const getDesignTokens = (designSystem) => {
21
34
  const tailwindcssConfig = {};
@@ -33,7 +46,7 @@ const designTokenPlugin = ({ pluginName } = {
33
46
  return {
34
47
  config() {
35
48
  const appContext = api.useAppContext();
36
- pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
49
+ pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
37
50
  return {
38
51
  source: {
39
52
  alias: {
@@ -73,8 +86,7 @@ const designTokenPlugin = ({ pluginName } = {
73
86
  const designSystem = (_userConfig_source_designSystem = (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.designSystem) !== null && _userConfig_source_designSystem !== void 0 ? _userConfig_source_designSystem : {};
74
87
  let useSCThemeProvider = true;
75
88
  if (designSystem) {
76
- var _designSystem;
77
- useSCThemeProvider = ((_designSystem = designSystem) === null || _designSystem === void 0 ? void 0 : _designSystem.supportStyledComponents) || false;
89
+ useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
78
90
  }
79
91
  if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
80
92
  plugins.push({
@@ -122,3 +134,7 @@ const designTokenPlugin = ({ pluginName } = {
122
134
  };
123
135
  }
124
136
  });
137
+ // Annotate the CommonJS export names for ESM import in node:
138
+ 0 && (module.exports = {
139
+ designTokenPlugin
140
+ });
@@ -1,13 +1,40 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _runtime.default;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var design_token_exports = {};
31
+ __export(design_token_exports, {
32
+ default: () => import_runtime.default
33
+ });
34
+ module.exports = __toCommonJS(design_token_exports);
35
+ var import_runtime = __toESM(require("./runtime"));
36
+ __reExport(design_token_exports, require("./runtime"), module.exports);
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ ...require("./runtime")
10
40
  });
11
- const _export_star = require("@swc/helpers/_/_export_star");
12
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
- const _runtime = /* @__PURE__ */ _interop_require_default._(_export_star._(require("./runtime"), exports));
@@ -1,14 +1,27 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var postcss_plugin_exports = {};
20
+ __export(postcss_plugin_exports, {
21
+ default: () => postcss_plugin_default
10
22
  });
11
- const _default = ({ cssVarsHash = {} } = {}) => ({
23
+ module.exports = __toCommonJS(postcss_plugin_exports);
24
+ var postcss_plugin_default = ({ cssVarsHash = {} } = {}) => ({
12
25
  postcssPlugin: "postcss-replace-css-vars",
13
26
  Declaration(decl) {
14
27
  if (decl.value && typeof decl.value === "string") {
@@ -1,14 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var runtime_exports = {};
31
+ __export(runtime_exports, {
32
+ default: () => runtime_default
33
+ });
34
+ module.exports = __toCommonJS(runtime_exports);
35
+ var import_plugin = __toESM(require("./plugin"));
36
+ __reExport(runtime_exports, require("./plugin"), module.exports);
37
+ var runtime_default = import_plugin.default;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ ...require("./plugin")
10
41
  });
11
- const _export_star = require("@swc/helpers/_/_export_star");
12
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
- const _plugin = /* @__PURE__ */ _interop_require_default._(_export_star._(require("./plugin"), exports));
14
- const _default = _plugin.default;
@@ -1,33 +1,44 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- DesignTokenContext: function() {
14
- return DesignTokenContext;
15
- },
16
- useDesignTokens: function() {
17
- return useDesignTokens;
18
- },
19
- default: function() {
20
- return _default;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var plugin_exports = {};
30
+ __export(plugin_exports, {
31
+ DesignTokenContext: () => DesignTokenContext,
32
+ default: () => plugin_default,
33
+ useDesignTokens: () => useDesignTokens
22
34
  });
23
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
24
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
25
- const _jsxruntime = require("react/jsx-runtime");
26
- const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default._(require("hoist-non-react-statics"));
27
- const _react = /* @__PURE__ */ _interop_require_wildcard._(require("react"));
28
- const DesignTokenContext = /* @__PURE__ */ _react.default.createContext({});
29
- const useDesignTokens = () => (0, _react.useContext)(DesignTokenContext);
30
- const _default = (options = {}) => ({
35
+ module.exports = __toCommonJS(plugin_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
38
+ var import_react = __toESM(require("react"));
39
+ const DesignTokenContext = /* @__PURE__ */ import_react.default.createContext({});
40
+ const useDesignTokens = () => (0, import_react.useContext)(DesignTokenContext);
41
+ var plugin_default = (options = {}) => ({
31
42
  name: "@modern-js/plugin-design-token",
32
43
  setup: () => ({
33
44
  hoc({ App }, next) {
@@ -35,39 +46,44 @@ const _default = (options = {}) => ({
35
46
  const { token = {}, useStyledComponentsThemeProvider = false, useDesignTokenContext = false } = options;
36
47
  if (useStyledComponentsThemeProvider && useDesignTokenContext) {
37
48
  const { ThemeProvider } = require("@modern-js/runtime/styled");
38
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(ThemeProvider, {
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
39
50
  theme: token,
40
- children: /* @__PURE__ */ (0, _jsxruntime.jsx)(DesignTokenContext.Provider, {
51
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
41
52
  value: token,
42
- children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
53
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
43
54
  ...props
44
55
  })
45
56
  })
46
57
  });
47
58
  } else if (useStyledComponentsThemeProvider) {
48
59
  const { ThemeProvider } = require("@modern-js/runtime/styled");
49
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(ThemeProvider, {
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
50
61
  theme: token,
51
- children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
62
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
52
63
  ...props
53
64
  })
54
65
  });
55
66
  } else if (useDesignTokenContext) {
56
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(DesignTokenContext.Provider, {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
57
68
  value: token,
58
- children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
69
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
59
70
  ...props
60
71
  })
61
72
  });
62
73
  } else {
63
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
74
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
64
75
  ...props
65
76
  });
66
77
  }
67
78
  };
68
79
  return next({
69
- App: (0, _hoistnonreactstatics.default)(DesignTokenAppWrapper, App)
80
+ App: (0, import_hoist_non_react_statics.default)(DesignTokenAppWrapper, App)
70
81
  });
71
82
  }
72
83
  })
73
84
  });
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ DesignTokenContext,
88
+ useDesignTokens
89
+ });
package/dist/cjs/index.js CHANGED
@@ -1,21 +1,30 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
6
7
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- tailwindcssPlugin: function() {
14
- return _cli.tailwindcssPlugin;
15
- },
16
- default: function() {
17
- return _default;
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ default: () => src_default,
22
+ tailwindcssPlugin: () => import_cli.tailwindcssPlugin
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_cli = require("./cli");
26
+ var src_default = import_cli.tailwindcssPlugin;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ tailwindcssPlugin
19
30
  });
20
- const _cli = require("./cli");
21
- const _default = _cli.tailwindcssPlugin;