@varlet/cli 2.7.0-alpha.1673633577294 → 2.7.0-alpha.1673640473187

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.
@@ -27,9 +27,6 @@ export async function compile() {
27
27
  process.env.TARGET_MODULE = 'module';
28
28
  process.env.BABEL_MODULE = 'module';
29
29
  await runTask('module', compileModule);
30
- process.env.TARGET_MODULE = 'commonjs';
31
- process.env.BABEL_MODULE = 'commonjs';
32
- await runTask('commonjs', compileModule);
33
30
  process.env.BABEL_MODULE = '';
34
31
  process.env.TARGET_MODULE = 'bundle';
35
32
  await runTask('bundle', compileModule);
@@ -4,7 +4,7 @@ import { resolve } from 'path';
4
4
  import { EXAMPLE_DIR_NAME, TESTS_DIR_NAME, DOCS_DIR_NAME, SRC_DIR, ES_DIR, STYLE_DIR_NAME, LIB_DIR, UMD_DIR, } from '../shared/constant.js';
5
5
  import { getPublicDirs, isDir, isDTS, isLess, isScript, isSFC } from '../shared/fsUtils.js';
6
6
  import { compileSFC } from './compileSFC.js';
7
- import { compileESEntry, compileCommonJSEntry, compileScriptFile, getScriptExtname } from './compileScript.js';
7
+ import { compileESEntry, compileScriptFile, getScriptExtname } from './compileScript.js';
8
8
  import { clearLessFiles, compileLess } from './compileStyle.js';
9
9
  import { getBundleConfig } from '../config/vite.config.js';
10
10
  import { getVarletConfig } from '../config/varlet.config.js';
@@ -61,7 +61,7 @@ export async function compileModule() {
61
61
  await compileBundle();
62
62
  return;
63
63
  }
64
- const dest = targetModule === 'commonjs' ? LIB_DIR : ES_DIR;
64
+ const dest = ES_DIR;
65
65
  await copy(SRC_DIR, dest);
66
66
  const moduleDir = await readdir(dest);
67
67
  await Promise.all(moduleDir.map((filename) => {
@@ -70,12 +70,7 @@ export async function compileModule() {
70
70
  return isDir(file) ? compileDir(file) : null;
71
71
  }));
72
72
  const publicDirs = await getPublicDirs();
73
- if (targetModule === 'commonjs') {
74
- await compileCommonJSEntry(dest, publicDirs);
75
- }
76
- else {
77
- await compileESEntry(dest, publicDirs);
78
- }
73
+ await compileESEntry(dest, publicDirs);
79
74
  clearLessFiles(dest);
80
75
  generateReference(dest);
81
76
  }
@@ -1,7 +1,6 @@
1
1
  export declare const IMPORT_FROM_DEPENDENCE_RE: RegExp;
2
2
  export declare const EXPORT_FROM_DEPENDENCE_RE: RegExp;
3
3
  export declare const IMPORT_DEPENDENCE_RE: RegExp;
4
- export declare const REQUIRE_DEPENDENCE_RE: RegExp;
5
4
  export declare const scriptExtNames: string[];
6
5
  export declare const styleExtNames: string[];
7
6
  export declare const scriptIndexes: string[];
@@ -11,6 +10,5 @@ export declare const resolveDependence: (file: string, script: string) => string
11
10
  export declare const moduleCompatible: (script: string) => Promise<string>;
12
11
  export declare function compileScript(script: string, file: string): Promise<void>;
13
12
  export declare function compileScriptFile(file: string): Promise<void>;
14
- export declare function getScriptExtname(): ".js" | ".mjs";
13
+ export declare function getScriptExtname(): string;
15
14
  export declare function compileESEntry(dir: string, publicDirs: string[]): Promise<void>;
16
- export declare function compileCommonJSEntry(dir: string, publicDirs: string[]): Promise<void>;
@@ -13,8 +13,6 @@ export const IMPORT_FROM_DEPENDENCE_RE = /import\s+?[\w\s{},$*]+\s+from\s+?(".*?
13
13
  export const EXPORT_FROM_DEPENDENCE_RE = /export\s+?[\w\s{},$*]+\s+from\s+?(".*?"|'.*?')/g;
14
14
  // https://regexr.com/764ve
15
15
  export const IMPORT_DEPENDENCE_RE = /import\s+(".*?"|'.*?')/g;
16
- // https://regexr.com/764vn
17
- export const REQUIRE_DEPENDENCE_RE = /require\((".*?"|'.*?')\)/g;
18
16
  export const scriptExtNames = ['.vue', '.ts', '.tsx', '.mjs', '.js', '.jsx'];
19
17
  export const styleExtNames = ['.less', '.css'];
20
18
  export const scriptIndexes = ['index.mjs', 'index.vue', 'index.ts', 'index.tsx', 'index.js', 'index.jsx'];
@@ -80,8 +78,7 @@ export const resolveDependence = (file, script) => {
80
78
  return script
81
79
  .replace(IMPORT_FROM_DEPENDENCE_RE, replacer)
82
80
  .replace(EXPORT_FROM_DEPENDENCE_RE, replacer)
83
- .replace(IMPORT_DEPENDENCE_RE, replacer)
84
- .replace(REQUIRE_DEPENDENCE_RE, replacer);
81
+ .replace(IMPORT_DEPENDENCE_RE, replacer);
85
82
  };
86
83
  export const moduleCompatible = async (script) => {
87
84
  const moduleCompatible = get(await getVarletConfig(), 'moduleCompatible', {});
@@ -112,10 +109,7 @@ export async function compileScriptFile(file) {
112
109
  await compileScript(sources, file);
113
110
  }
114
111
  export function getScriptExtname() {
115
- if (process.env.TARGET_MODULE === 'module') {
116
- return '.mjs';
117
- }
118
- return '.js';
112
+ return '.mjs';
119
113
  }
120
114
  export async function compileESEntry(dir, publicDirs) {
121
115
  const imports = [];
@@ -183,54 +177,3 @@ export default {
183
177
  writeFile(resolve(dir, 'style.mjs'), styleTemplate, 'utf-8'),
184
178
  ]);
185
179
  }
186
- export async function compileCommonJSEntry(dir, publicDirs) {
187
- const requires = [];
188
- const plugins = [];
189
- const cssRequires = [];
190
- const publicComponents = [];
191
- const exports = [];
192
- publicDirs.forEach((dirname) => {
193
- const publicComponent = bigCamelize(dirname);
194
- const module = `'./${dirname}/index.js'`;
195
- publicComponents.push(publicComponent);
196
- requires.push(`var ${publicComponent} = require(${module})['default']`);
197
- exports.push(`...ignoreDefault(require(${module}))`);
198
- plugins.push(`${publicComponent}.install && app.use(${publicComponent})`);
199
- cssRequires.push(`require('./${dirname}/style/index.js')`);
200
- });
201
- const version = `const version = '${getVersion()}'`;
202
- const install = `
203
- function install(app) {
204
- ${plugins.join('\n ')}
205
- }
206
- `;
207
- const indexTemplate = `\
208
- ${requires.join('\n')}\n
209
- ${version}
210
- ${install}
211
-
212
- function ignoreDefault(module) {
213
- return Object.keys(module).reduce((exports, key) => {
214
- if (key !== 'default') {
215
- exports[key] = module[key]
216
- }
217
-
218
- return exports
219
- }, {})
220
- }
221
-
222
- module.exports = {
223
- version,
224
- install,
225
- ${exports.join(',\n ')},
226
- ${publicComponents.join(',\n ')}
227
- }
228
- `;
229
- const styleTemplate = `\
230
- ${cssRequires.join('\n')}
231
- `;
232
- await Promise.all([
233
- writeFile(resolve(dir, 'index.js'), indexTemplate, 'utf-8'),
234
- writeFile(resolve(dir, 'style.js'), styleTemplate, 'utf-8'),
235
- ]);
236
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.7.0-alpha.1673633577294",
3
+ "version": "2.7.0-alpha.1673640473187",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -66,8 +66,8 @@
66
66
  "vite": "4.0.4",
67
67
  "vue": "3.2.25",
68
68
  "vue-jest": "^5.0.0-alpha.8",
69
- "@varlet/vite-plugins": "2.7.0-alpha.1673633577294",
70
- "@varlet/shared": "2.7.0-alpha.1673633577294"
69
+ "@varlet/vite-plugins": "2.7.0-alpha.1673640473187",
70
+ "@varlet/shared": "2.7.0-alpha.1673640473187"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/babel__core": "^7.1.12",
@@ -79,8 +79,8 @@
79
79
  "@types/node": "^18.7.20",
80
80
  "@types/semver": "^7.3.9",
81
81
  "@types/inquirer": "^9.0.2",
82
- "@varlet/touch-emulator": "2.7.0-alpha.1673633577294",
83
- "@varlet/icons": "2.7.0-alpha.1673633577294"
82
+ "@varlet/touch-emulator": "2.7.0-alpha.1673640473187",
83
+ "@varlet/icons": "2.7.0-alpha.1673640473187"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@vue/runtime-core": "3.2.16",
@@ -90,8 +90,8 @@
90
90
  "lodash-es": "^4.17.21",
91
91
  "vue": "3.2.25",
92
92
  "vue-router": "4.0.12",
93
- "@varlet/touch-emulator": "2.7.0-alpha.1673633577294",
94
- "@varlet/icons": "2.7.0-alpha.1673633577294"
93
+ "@varlet/icons": "2.7.0-alpha.1673640473187",
94
+ "@varlet/touch-emulator": "2.7.0-alpha.1673640473187"
95
95
  },
96
96
  "scripts": {
97
97
  "dev": "tsc --watch",