@varlet/cli 1.25.1-alpha.1643124613252 → 1.25.1

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.
@@ -93,16 +93,19 @@ function compile(cmd) {
93
93
  return [4 /*yield*/, runTask('module', compileModule_1.compileModule)];
94
94
  case 3:
95
95
  _b.sent();
96
- return [4 /*yield*/, runTask('commonjs', function () { return (0, compileModule_1.compileModule)('commonjs'); })];
96
+ return [4 /*yield*/, runTask('esm bundle', function () { return (0, compileModule_1.compileModule)('esm-bundle'); })];
97
97
  case 4:
98
+ _b.sent();
99
+ return [4 /*yield*/, runTask('commonjs', function () { return (0, compileModule_1.compileModule)('commonjs'); })];
100
+ case 5:
98
101
  _b.sent();
99
102
  _a = !cmd.noUmd;
100
- if (!_a) return [3 /*break*/, 6];
103
+ if (!_a) return [3 /*break*/, 7];
101
104
  return [4 /*yield*/, runTask('umd', function () { return (0, compileModule_1.compileModule)('umd'); })];
102
- case 5:
103
- _a = (_b.sent());
104
- _b.label = 6;
105
105
  case 6:
106
+ _a = (_b.sent());
107
+ _b.label = 7;
108
+ case 7:
106
109
  _a;
107
110
  return [2 /*return*/];
108
111
  }
@@ -1,4 +1,5 @@
1
1
  export declare function compileUMD(): Promise<void>;
2
+ export declare function compileESMBundle(): Promise<void>;
2
3
  export declare function compileDir(dir: string): Promise<void>;
3
4
  export declare function compileFile(file: string): Promise<void>;
4
- export declare function compileModule(modules?: 'umd' | 'commonjs' | boolean): Promise<void>;
5
+ export declare function compileModule(modules?: 'umd' | 'commonjs' | 'esm-bundle' | boolean): Promise<void>;
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileModule = exports.compileFile = exports.compileDir = exports.compileUMD = void 0;
39
+ exports.compileModule = exports.compileFile = exports.compileDir = exports.compileESMBundle = exports.compileUMD = void 0;
40
40
  var vite_1 = require("vite");
41
41
  var path_1 = require("path");
42
42
  var fs_extra_1 = require("fs-extra");
@@ -57,6 +57,15 @@ function compileUMD() {
57
57
  });
58
58
  }
59
59
  exports.compileUMD = compileUMD;
60
+ function compileESMBundle() {
61
+ return new Promise(function (resolve, reject) {
62
+ var config = (0, vite_config_1.getESMBundleConfig)((0, varlet_config_1.getVarletConfig)());
63
+ (0, vite_1.build)(config)
64
+ .then(function () { return resolve(); })
65
+ .catch(reject);
66
+ });
67
+ }
68
+ exports.compileESMBundle = compileESMBundle;
60
69
  function compileDir(dir) {
61
70
  return __awaiter(this, void 0, void 0, function () {
62
71
  var dirs;
@@ -138,13 +147,19 @@ function compileModule(modules) {
138
147
  _a.sent();
139
148
  return [2 /*return*/];
140
149
  case 2:
150
+ if (!(modules === 'esm-bundle')) return [3 /*break*/, 4];
151
+ return [4 /*yield*/, compileESMBundle()];
152
+ case 3:
153
+ _a.sent();
154
+ return [2 /*return*/];
155
+ case 4:
141
156
  process.env.BABEL_MODULE = modules === 'commonjs' ? 'commonjs' : 'module';
142
157
  dest = modules === 'commonjs' ? constant_1.LIB_DIR : constant_1.ES_DIR;
143
158
  return [4 /*yield*/, (0, fs_extra_1.copy)(constant_1.SRC_DIR, dest)];
144
- case 3:
159
+ case 5:
145
160
  _a.sent();
146
161
  return [4 /*yield*/, (0, fs_extra_1.readdir)(dest)];
147
- case 4:
162
+ case 6:
148
163
  moduleDir = _a.sent();
149
164
  return [4 /*yield*/, Promise.all(moduleDir.map(function (filename) {
150
165
  var file = (0, path_1.resolve)(dest, filename);
@@ -154,13 +169,13 @@ function compileModule(modules) {
154
169
  }
155
170
  return (0, fsUtils_1.isDir)(file) ? compileDir(file) : null;
156
171
  }))];
157
- case 5:
172
+ case 7:
158
173
  _a.sent();
159
174
  return [4 /*yield*/, (0, fsUtils_1.getPublicDirs)()];
160
- case 6:
175
+ case 8:
161
176
  publicDirs = _a.sent();
162
177
  return [4 /*yield*/, (modules === 'commonjs' ? (0, compileScript_1.compileCommonJSEntry)(dest, publicDirs) : (0, compileScript_1.compileESEntry)(dest, publicDirs))];
163
- case 7:
178
+ case 9:
164
179
  _a.sent();
165
180
  (0, compileTypes_1.generateReference)(dest);
166
181
  return [2 /*return*/];
@@ -1,4 +1,5 @@
1
1
  import { InlineConfig } from 'vite';
2
2
  export declare function getDevConfig(varletConfig: Record<string, any>): InlineConfig;
3
3
  export declare function getBuildConfig(varletConfig: Record<string, any>): InlineConfig;
4
+ export declare function getESMBundleConfig(varletConfig: Record<string, any>): InlineConfig;
4
5
  export declare function getUMDConfig(varletConfig: Record<string, any>): InlineConfig;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getUMDConfig = exports.getBuildConfig = exports.getDevConfig = void 0;
17
+ exports.getUMDConfig = exports.getESMBundleConfig = exports.getBuildConfig = exports.getDevConfig = void 0;
18
18
  var plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
19
19
  var markdown_vite_plugin_1 = __importDefault(require("@varlet/markdown-vite-plugin"));
20
20
  var plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
@@ -102,6 +102,34 @@ function clear() {
102
102
  },
103
103
  };
104
104
  }
105
+ function getESMBundleConfig(varletConfig) {
106
+ var name = (0, lodash_1.get)(varletConfig, 'name');
107
+ var fileName = "".concat((0, lodash_1.kebabCase)(name), ".esm.js");
108
+ return {
109
+ logLevel: 'silent',
110
+ build: {
111
+ emptyOutDir: true,
112
+ lib: {
113
+ name: name,
114
+ formats: ['es'],
115
+ fileName: function () { return fileName; },
116
+ entry: (0, path_1.resolve)(constant_1.ES_DIR, 'umdIndex.js'),
117
+ },
118
+ rollupOptions: {
119
+ external: ['vue'],
120
+ output: {
121
+ dir: constant_1.ES_DIR,
122
+ exports: 'named',
123
+ globals: {
124
+ vue: 'Vue',
125
+ },
126
+ },
127
+ },
128
+ },
129
+ plugins: [clear()],
130
+ };
131
+ }
132
+ exports.getESMBundleConfig = getESMBundleConfig;
105
133
  function getUMDConfig(varletConfig) {
106
134
  var name = (0, lodash_1.get)(varletConfig, 'name');
107
135
  var fileName = "".concat((0, lodash_1.kebabCase)(name), ".js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.25.1-alpha.1643124613252",
3
+ "version": "1.25.1",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -33,9 +33,9 @@
33
33
  "@babel/helper-plugin-utils": "^7.14.5",
34
34
  "@babel/preset-env": "^7.14.8",
35
35
  "@babel/preset-typescript": "^7.14.5",
36
- "@varlet/icons": "1.25.1-alpha.1643124613252",
37
- "@varlet/markdown-vite-plugin": "1.25.1-alpha.1643124613252",
38
- "@varlet/touch-emulator": "1.25.1-alpha.1643124613252",
36
+ "@varlet/icons": "1.25.1",
37
+ "@varlet/markdown-vite-plugin": "1.25.1",
38
+ "@varlet/touch-emulator": "1.25.1",
39
39
  "@vitejs/plugin-vue": "1.9.2",
40
40
  "@vitejs/plugin-vue-jsx": "1.1.8",
41
41
  "@vue/babel-plugin-jsx": "1.0.7",
@@ -74,7 +74,7 @@
74
74
  "@types/semver": "^7.3.9"
75
75
  },
76
76
  "peerDependencies": {
77
- "@varlet/touch-emulator": "1.25.1-alpha.1643124613252",
77
+ "@varlet/touch-emulator": "1.25.1",
78
78
  "@vue/test-utils": "^2.0.0-rc.6",
79
79
  "clipboard": "^2.0.6",
80
80
  "live-server": "^1.2.1",
@@ -18,6 +18,7 @@
18
18
  <div
19
19
  :id="`clip-target-${cid}`"
20
20
  class="var-site-code-example__code"
21
+ :class="[disabledFold ? 'var-site-code-example--scroller' : null]"
21
22
  ref="code"
22
23
  :style="{
23
24
  height: height >= 0 ? `${height}px` : undefined,
@@ -57,18 +58,17 @@ export default defineComponent({
57
58
  const clipboard: Ref = ref(get(config, 'pc.clipboard', {}))
58
59
  const height: Ref<number> = ref(-1)
59
60
 
60
- let fullHeight = 0
61
-
62
61
  const toggle = async () => {
63
62
  const foldHeight = fold.value.foldHeight
64
63
 
65
64
  if (height.value === foldHeight) {
65
+ height.value = -1
66
+ await nextTick()
67
+ const { offsetHeight } = code.value as HTMLElement
66
68
  height.value = foldHeight
67
69
  await doubleRaf()
68
- height.value = fullHeight
70
+ height.value = offsetHeight
69
71
  } else {
70
- height.value = fullHeight
71
- await doubleRaf()
72
72
  height.value = foldHeight
73
73
  }
74
74
  }
@@ -81,8 +81,7 @@ export default defineComponent({
81
81
  })
82
82
 
83
83
  const { offsetHeight } = code.value as HTMLElement
84
- fullHeight = offsetHeight
85
- disabledFold.value = fullHeight - fold.value.foldHeight < offset
84
+ disabledFold.value = offsetHeight - fold.value.foldHeight < offset
86
85
  height.value = fold.value?.defaultFold ? fold.value?.foldHeight : -1
87
86
  })
88
87
 
@@ -20,4 +20,10 @@
20
20
  overflow: hidden;
21
21
  border-radius: 4px;
22
22
  }
23
+
24
+ &--scroller {
25
+ code {
26
+ white-space: nowrap;
27
+ }
28
+ }
23
29
  }