@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,102 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
+ ## 2.0.0-beta.4
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - 92f0eade39: feat:
12
+
13
+ 1. add style config and add new hook
14
+ 2. add dts alias logic
15
+ 3. add copy logic
16
+ 4. add log logic
17
+ 5. add skipDeps config
18
+
19
+ feat:
20
+
21
+ 1. 添加样式配置以及新的 hook
22
+ 2. 添加 dts 别名处理
23
+ 3. 添加 copy 逻辑
24
+ 4. 添加日志逻辑
25
+ 5. 添加 skipDeps 配置
26
+
27
+ - 92f0eade39: feat:
28
+
29
+ 1. core: 增加 test 函数
30
+ 2. module plugins: 增加 `babel`, `mainField`, `target` 插件
31
+ 3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
32
+ 4. 增加 designSystem 配置
33
+
34
+ feat:
35
+
36
+ 1. core: add test method
37
+ 2. module plugins: add `babel`, `mainField`, `target` plugin
38
+ 3. storybook: change some logic and add tspath webpack plugin
39
+ 4. add `designSystem` config
40
+
41
+ ### Patch Changes
42
+
43
+ - d6546ad916: add buildConfig style in module-tools and remove tools
44
+ 在 module-tools 里新增 buildConfig style 并删除 tools
45
+ - 67472ca: fix: move babel-plugin-marcos to plugin-tailwindcss
46
+
47
+ fix: 将 babel-plugin-marcos 依赖移动到 plugin-tailwindcss 中
48
+
49
+ - Updated dependencies [2344eb26ed]
50
+ - Updated dependencies [a11fcf8b50]
51
+ - Updated dependencies [a931594]
52
+ - Updated dependencies [e7ce063]
53
+ - Updated dependencies [b18fa8f3ed]
54
+ - Updated dependencies [7879e8f]
55
+ - Updated dependencies [50d4675]
56
+ - Updated dependencies [c9e800d39a]
57
+ - Updated dependencies [6604f1b]
58
+ - Updated dependencies [6aca875]
59
+ - Updated dependencies [fda836f]
60
+ - Updated dependencies [d6bc321]
61
+ - Updated dependencies [3e57f2bd58]
62
+ - Updated dependencies [2e6031955e]
63
+ - Updated dependencies [c5798d2]
64
+ - Updated dependencies [fbf5eed5aa]
65
+ - Updated dependencies [a2509bfbdb]
66
+ - Updated dependencies [a7c6883]
67
+ - Updated dependencies [425e57092d]
68
+ - Updated dependencies [e4357f1856]
69
+ - Updated dependencies [7b7d12c]
70
+ - Updated dependencies [4369648ae2]
71
+ - Updated dependencies [92f0eade39]
72
+ - Updated dependencies [92c0994468]
73
+ - Updated dependencies [2cc2eb3]
74
+ - Updated dependencies [edd1cfb1af]
75
+ - Updated dependencies [cc971eabfc]
76
+ - Updated dependencies [5b9049f2e9]
77
+ - Updated dependencies [6bda14ed71]
78
+ - Updated dependencies [92004d1906]
79
+ - Updated dependencies [b8bbe036c7]
80
+ - Updated dependencies [40ed5874c6]
81
+ - Updated dependencies [60d5378632]
82
+ - Updated dependencies [d5a31df781]
83
+ - Updated dependencies [dda38c9c3e]
84
+ - Updated dependencies [8b8e1bb571]
85
+ - Updated dependencies [3bbea92b2a]
86
+ - Updated dependencies [9144c21]
87
+ - Updated dependencies [b710adb843]
88
+ - Updated dependencies [18aaf42249]
89
+ - Updated dependencies [34702d5]
90
+ - Updated dependencies [fcace5b5b9]
91
+ - Updated dependencies [ea7cf06]
92
+ - Updated dependencies [bbe4c4a]
93
+ - Updated dependencies [e4558a0]
94
+ - Updated dependencies [abf3421a75]
95
+ - Updated dependencies [543be9558e]
96
+ - Updated dependencies [14b712da84]
97
+ - @modern-js/runtime@2.0.0-beta.4
98
+ - @modern-js/utils@2.0.0-beta.4
99
+
3
100
  ## 2.0.0-beta.3
4
101
 
5
102
  ### Major Changes
@@ -1,124 +1,177 @@
1
- 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; }
2
- 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; }
3
- 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; }
4
- import path from 'path';
5
- import { PLUGIN_SCHEMAS, fs, CONFIG_CACHE_DIR, globby, nanoid, slash } from '@modern-js/utils';
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import path from "path";
22
+ import {
23
+ PLUGIN_SCHEMAS,
24
+ fs,
25
+ CONFIG_CACHE_DIR,
26
+ globby,
27
+ nanoid,
28
+ slash
29
+ } from "@modern-js/utils";
6
30
  import DesignTokenPlugin from "./design-token/cli";
7
31
  import { getTailwindConfig } from "./tailwind";
8
32
  import { template, checkTwinMacroNotExist } from "./utils";
9
- const supportCssInJsLibrary = 'styled-components';
10
- export const getRandomTwConfigFileName = internalDirectory => {
11
- return slash(path.join(internalDirectory, `tailwind.config.${Date.now()}.${nanoid()}.js`));
33
+ const supportCssInJsLibrary = "styled-components";
34
+ const getRandomTwConfigFileName = (internalDirectory) => {
35
+ return slash(
36
+ path.join(
37
+ internalDirectory,
38
+ `tailwind.config.${Date.now()}.${nanoid()}.js`
39
+ )
40
+ );
12
41
  };
13
- export default (({
14
- pluginName
15
- } = {
16
- pluginName: '@modern-js/plugin-tailwindcss'
42
+ var cli_default = ({ pluginName } = {
43
+ pluginName: "@modern-js/plugin-tailwindcss"
17
44
  }) => ({
18
- name: '@modern-js/plugin-tailwindcss',
19
- // support designSystem.supportStyledComponents
20
- usePlugins: [DesignTokenPlugin({
21
- pluginName
22
- })],
23
- setup: async api => {
24
- const {
25
- appDirectory,
26
- internalDirectory
27
- } = api.useAppContext();
28
- let internalTwConfigPath = '';
29
- // When reinstalling dependencies, most of the time the project will be restarted
30
- const notHaveTwinMacro = await checkTwinMacroNotExist(appDirectory);
45
+ name: "@modern-js/plugin-tailwindcss",
46
+ usePlugins: [
47
+ DesignTokenPlugin({
48
+ pluginName
49
+ })
50
+ ],
51
+ setup: (api) => __async(void 0, null, function* () {
52
+ const { appDirectory, internalDirectory } = api.useAppContext();
53
+ let internalTwConfigPath = "";
54
+ const notHaveTwinMacro = yield checkTwinMacroNotExist(appDirectory);
31
55
  return {
32
56
  prepare() {
33
57
  if (notHaveTwinMacro) {
34
58
  return;
35
59
  }
36
60
  internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
37
- const globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, '*.cjs'));
61
+ const globPattern = slash(
62
+ path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs")
63
+ );
38
64
  const files = globby.sync(globPattern, {
39
65
  absolute: true
40
66
  });
41
67
  if (files.length > 0) {
42
- fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), 'utf-8');
68
+ fs.writeFileSync(
69
+ internalTwConfigPath,
70
+ template(files[files.length - 1]),
71
+ "utf-8"
72
+ );
43
73
  }
44
74
  },
45
75
  validateSchema() {
46
- return PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
76
+ return PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
47
77
  },
48
78
  config() {
49
79
  return {
50
80
  tools: {
51
- // TODO: Add interface about postcss config
52
- // TODO: In module project, also is called, but should not be called.
53
- postcss: config => {
54
- var _modernConfig$tools, _modernConfig$source;
81
+ postcss: (config) => {
82
+ var _a, _b;
55
83
  const modernConfig = api.useResolvedConfigContext();
56
- const tailwindConfig = getTailwindConfig(modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$tools = modernConfig.tools) === null || _modernConfig$tools === void 0 ? void 0 : _modernConfig$tools.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$source = modernConfig.source) === null || _modernConfig$source === void 0 ? void 0 : _modernConfig$source.designSystem, {
57
- pureConfig: {
58
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
59
- // about storybook
60
- './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
84
+ const tailwindConfig = getTailwindConfig(
85
+ (_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
86
+ (_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
87
+ {
88
+ pureConfig: {
89
+ content: [
90
+ "./config/html/**/*.html",
91
+ "./config/html/**/*.ejs",
92
+ "./config/html/**/*.hbs",
93
+ "./src/**/*.js",
94
+ "./src/**/*.jsx",
95
+ "./src/**/*.ts",
96
+ "./src/**/*.tsx",
97
+ "./storybook/**/*",
98
+ "./styles/**/*.less",
99
+ "./styles/**/*.css",
100
+ "./styles/**/*.sass",
101
+ "./styles/**/*.scss"
102
+ ]
103
+ }
61
104
  }
62
- });
105
+ );
63
106
  if (Array.isArray(config.postcssOptions.plugins)) {
64
- config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
107
+ config.postcssOptions.plugins.push(
108
+ require("tailwindcss")(tailwindConfig)
109
+ );
65
110
  } else {
66
- config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
111
+ config.postcssOptions.plugins = [
112
+ require("tailwindcss")(tailwindConfig)
113
+ ];
67
114
  }
68
115
  },
69
- babel(config) {
70
- var _config$plugins;
116
+ babel(_, { addPlugins }) {
71
117
  if (notHaveTwinMacro) {
72
118
  return;
73
119
  }
74
- const twinConfig = {
75
- twin: {
76
- preset: supportCssInJsLibrary,
77
- config: internalTwConfigPath
78
- }
79
- };
80
- (_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.some(plugin => {
81
- if (Array.isArray(plugin) && plugin[0]) {
82
- const pluginTarget = plugin[0];
83
- let pluginOptions = plugin[1];
84
- if (typeof pluginTarget === 'string' &&
85
- // TODO: use babel chain
86
- slash(pluginTarget).includes('compiled/babel-plugin-macros')) {
87
- if (pluginOptions) {
88
- pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
89
- } else {
90
- plugin.push(twinConfig);
120
+ addPlugins([
121
+ [
122
+ require.resolve("babel-plugin-macros"),
123
+ {
124
+ twin: {
125
+ preset: supportCssInJsLibrary,
126
+ config: internalTwConfigPath
91
127
  }
92
- return true;
93
128
  }
94
- }
95
- return false;
96
- });
129
+ ]
130
+ ]);
97
131
  }
98
132
  }
99
133
  };
100
134
  },
101
- beforeBuildTask({
102
- config
103
- }) {
135
+ beforeBuildTask({ config }) {
104
136
  const modernConfig = api.useResolvedConfigContext();
105
- const {
106
- designSystem
107
- } = modernConfig;
108
- const tailwindConfig = getTailwindConfig(config.style.tailwindCss, designSystem, {
109
- pureConfig: {
110
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
111
- // about storybook
112
- './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
137
+ const { designSystem } = modernConfig;
138
+ const tailwindConfig = getTailwindConfig(
139
+ config.style.tailwindCss,
140
+ designSystem,
141
+ {
142
+ pureConfig: {
143
+ content: [
144
+ "./config/html/**/*.html",
145
+ "./config/html/**/*.ejs",
146
+ "./config/html/**/*.hbs",
147
+ "./src/**/*.js",
148
+ "./src/**/*.jsx",
149
+ "./src/**/*.ts",
150
+ "./src/**/*.tsx",
151
+ "./storybook/**/*",
152
+ "./styles/**/*.less",
153
+ "./styles/**/*.css",
154
+ "./styles/**/*.sass",
155
+ "./styles/**/*.scss"
156
+ ]
157
+ }
113
158
  }
114
- });
159
+ );
115
160
  if (Array.isArray(config.style.postcss.plugins)) {
116
- config.style.postcss.plugins.push(require('tailwindcss')(tailwindConfig));
161
+ config.style.postcss.plugins.push(
162
+ require("tailwindcss")(tailwindConfig)
163
+ );
117
164
  } else {
118
- config.style.postcss.plugins = [require('tailwindcss')(tailwindConfig)];
165
+ config.style.postcss.plugins = [
166
+ require("tailwindcss")(tailwindConfig)
167
+ ];
119
168
  }
120
169
  return config;
121
170
  }
122
171
  };
123
- }
124
- }));
172
+ })
173
+ });
174
+ export {
175
+ cli_default as default,
176
+ getRandomTwConfigFileName
177
+ };
@@ -1,27 +1,36 @@
1
- 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; }
2
- 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; }
3
- 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; }
4
- import { lazyImport, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
5
- export default (({
6
- pluginName
7
- } = {
8
- pluginName: '@modern-js/plugin-tailwindcss'
9
- }) => ({
10
- name: '@modern-js/plugin-design-token',
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import {
18
+ lazyImport,
19
+ PLUGIN_SCHEMAS,
20
+ createRuntimeExportsUtils
21
+ } from "@modern-js/utils";
22
+ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
23
+ name: "@modern-js/plugin-design-token",
11
24
  setup(api) {
12
25
  let pluginsExportsUtils;
13
- const resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
14
- const PLUGIN_IDENTIFIER = 'designToken';
15
- const getDesignTokens = designSystem => {
26
+ const resolveConfig = lazyImport("tailwindcss/resolveConfig", require);
27
+ const PLUGIN_IDENTIFIER = "designToken";
28
+ const getDesignTokens = (designSystem) => {
16
29
  const tailwindcssConfig = {};
17
- tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
18
-
19
- // not use default design token when designToken.defaultTheme is false or theme is false
30
+ tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
20
31
  if (!designSystem) {
21
32
  tailwindcssConfig.presets = [];
22
33
  }
23
-
24
- // when only designSystem exist, need remove supportStyledComponents
25
34
  if (designSystem) {
26
35
  delete tailwindcssConfig.theme.supportStyledComponents;
27
36
  }
@@ -30,35 +39,32 @@ export default (({
30
39
  return {
31
40
  config() {
32
41
  const appContext = api.useAppContext();
33
- pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'plugins');
42
+ pluginsExportsUtils = createRuntimeExportsUtils(
43
+ appContext.internalDirectory,
44
+ "plugins"
45
+ );
34
46
  return {
35
47
  source: {
36
48
  alias: {
37
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
49
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
38
50
  }
39
51
  },
40
- tools: {
41
- // TODO: support less、scss、css vars
42
- // less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
43
- // sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
44
- // postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
45
- }
52
+ tools: {}
46
53
  };
47
54
  },
48
- modifyEntryImports({
49
- entrypoint,
50
- imports
51
- }) {
52
- var _userConfig$source$de, _userConfig$source;
55
+ modifyEntryImports({ entrypoint, imports }) {
56
+ var _a, _b;
53
57
  const userConfig = api.useResolvedConfigContext();
54
- 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 : {};
55
- if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
58
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
59
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
56
60
  const designTokens = getDesignTokens(userConfig.source.designSystem);
57
61
  imports.push({
58
- value: '@modern-js/runtime/plugins',
59
- specifiers: [{
60
- imported: PLUGIN_IDENTIFIER
61
- }],
62
+ value: "@modern-js/runtime/plugins",
63
+ specifiers: [
64
+ {
65
+ imported: PLUGIN_IDENTIFIER
66
+ }
67
+ ],
62
68
  initialize: `
63
69
  const designTokens = ${JSON.stringify(designTokens)};
64
70
  `
@@ -69,22 +75,18 @@ export default (({
69
75
  imports
70
76
  };
71
77
  },
72
- modifyEntryRuntimePlugins({
73
- entrypoint,
74
- plugins
75
- }) {
76
- var _userConfig$source$de2, _userConfig$source2;
78
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
79
+ var _a, _b;
77
80
  const userConfig = api.useResolvedConfigContext();
78
- 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 : {};
81
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
79
82
  let useSCThemeProvider = true;
80
83
  if (designSystem) {
81
- // when designSystem exist, designToken.styledComponents`s default value is false.
82
- useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
84
+ useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
83
85
  }
84
- if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
86
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
85
87
  plugins.push({
86
88
  name: PLUGIN_IDENTIFIER,
87
- options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
89
+ options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
88
90
  });
89
91
  }
90
92
  return {
@@ -93,12 +95,16 @@ export default (({
93
95
  };
94
96
  },
95
97
  validateSchema() {
96
- // add source.designSystem.supportStyledComponents config
97
- return PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
98
+ return PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
98
99
  },
99
100
  addRuntimeExports() {
100
- pluginsExportsUtils.addExport(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
101
+ pluginsExportsUtils.addExport(
102
+ `export { default as designToken } from '${pluginName}/runtime-design-token'`
103
+ );
101
104
  }
102
105
  };
103
106
  }
104
- }));
107
+ });
108
+ export {
109
+ cli_default as default
110
+ };
File without changes
@@ -1,2 +1,5 @@
1
- export { default } from "./runtime";
2
- export * from "./runtime";
1
+ import { default as default2 } from "./runtime";
2
+ export * from "./runtime";
3
+ export {
4
+ default2 as default
5
+ };
@@ -1,15 +1,18 @@
1
- export default (({
2
- cssVarsHash: _cssVarsHash = {}
1
+ var postcss_plugin_default = ({
2
+ cssVarsHash = {}
3
3
  } = {}) => ({
4
- postcssPlugin: 'postcss-replace-css-vars',
4
+ postcssPlugin: "postcss-replace-css-vars",
5
5
  Declaration(decl) {
6
- if (decl.value && typeof decl.value === 'string') {
7
- decl.value = decl.value.replace(/--\S*/g, match => {
8
- if (_cssVarsHash[match]) {
9
- return _cssVarsHash[match];
6
+ if (decl.value && typeof decl.value === "string") {
7
+ decl.value = decl.value.replace(/--\S*/g, (match) => {
8
+ if (cssVarsHash[match]) {
9
+ return cssVarsHash[match];
10
10
  }
11
11
  return match;
12
12
  });
13
13
  }
14
14
  }
15
- }));
15
+ });
16
+ export {
17
+ postcss_plugin_default as default
18
+ };
@@ -1,3 +1,6 @@
1
1
  import designTokenPlugin from "./plugin";
2
2
  export * from "./plugin";
3
- export default designTokenPlugin;
3
+ var runtime_default = designTokenPlugin;
4
+ export {
5
+ runtime_default as default
6
+ };