@varlet/cli 2.7.3-alpha.1675189320554 → 2.7.3-alpha.1675236177820
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.
|
@@ -10,6 +10,9 @@ const EXPORT = 'export default';
|
|
|
10
10
|
const SFC = '__sfc__';
|
|
11
11
|
const SFC_DECLARE = `const ${SFC} = `;
|
|
12
12
|
const RENDER = '__render__';
|
|
13
|
+
export function declareEmptySFC() {
|
|
14
|
+
return `${SFC_DECLARE}{}\n`;
|
|
15
|
+
}
|
|
13
16
|
export function replaceExportToDeclare(script) {
|
|
14
17
|
return script.replace(EXPORT, SFC_DECLARE);
|
|
15
18
|
}
|
|
@@ -33,9 +36,9 @@ export async function compileSFC(sfc) {
|
|
|
33
36
|
const id = hash(sources);
|
|
34
37
|
const { descriptor } = parseSFC(sources, { sourceMap: false });
|
|
35
38
|
const { script, scriptSetup, template, styles } = descriptor;
|
|
39
|
+
let scriptContent;
|
|
40
|
+
let bindingMetadata;
|
|
36
41
|
if (script || scriptSetup) {
|
|
37
|
-
let scriptContent;
|
|
38
|
-
let bindingMetadata;
|
|
39
42
|
if (scriptSetup) {
|
|
40
43
|
const { content, bindings } = compileScriptSFC(descriptor, { id });
|
|
41
44
|
scriptContent = content;
|
|
@@ -46,45 +49,48 @@ export async function compileSFC(sfc) {
|
|
|
46
49
|
scriptContent = script.content;
|
|
47
50
|
}
|
|
48
51
|
scriptContent = replaceExportToDeclare(scriptContent);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
}
|
|
53
|
+
if (!scriptContent) {
|
|
54
|
+
scriptContent = declareEmptySFC();
|
|
55
|
+
}
|
|
56
|
+
// scoped
|
|
57
|
+
const hasScope = styles.some((style) => style.scoped);
|
|
58
|
+
const scopeId = hasScope ? `data-v-${id}` : '';
|
|
59
|
+
if (template) {
|
|
60
|
+
const render = compileTemplate({
|
|
61
|
+
id,
|
|
62
|
+
source: template.content,
|
|
63
|
+
filename: sfc,
|
|
64
|
+
compilerOptions: {
|
|
65
|
+
scopeId,
|
|
66
|
+
bindingMetadata,
|
|
67
|
+
},
|
|
68
|
+
}).code;
|
|
69
|
+
scriptContent = injectRender(scriptContent, render);
|
|
70
|
+
}
|
|
71
|
+
if (scopeId) {
|
|
72
|
+
scriptContent = injectScopeId(scriptContent, scopeId);
|
|
73
|
+
}
|
|
74
|
+
scriptContent = injectExport(scriptContent);
|
|
75
|
+
await compileScript(scriptContent, sfc);
|
|
76
|
+
// style
|
|
77
|
+
for (let index = 0; index < styles.length; index++) {
|
|
78
|
+
const style = styles[index];
|
|
79
|
+
const file = replaceExt(sfc, `Sfc${index || ''}.${style.lang || 'css'}`);
|
|
80
|
+
const { base, dir } = parse(file);
|
|
81
|
+
const dependencyPath = normalizeStyleDependency(base, STYLE_IMPORT_RE);
|
|
82
|
+
const cssFile = resolve(dir, `./style/index${getScriptExtname()}`);
|
|
83
|
+
let { code } = compileStyle({
|
|
84
|
+
source: style.content,
|
|
85
|
+
filename: file,
|
|
86
|
+
id: scopeId,
|
|
87
|
+
scoped: style.scoped,
|
|
88
|
+
});
|
|
89
|
+
code = extractStyleDependencies(file, code, STYLE_IMPORT_RE);
|
|
90
|
+
writeFileSync(file, clearEmptyLine(code), 'utf-8');
|
|
91
|
+
smartAppendFileSync(cssFile, `import '${dependencyPath}.css'\n`);
|
|
92
|
+
if (style.lang === 'less') {
|
|
93
|
+
await compileLess(file);
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.7.3-alpha.
|
|
3
|
+
"version": "2.7.3-alpha.1675236177820",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"vite": "4.0.4",
|
|
69
69
|
"vue": "3.2.25",
|
|
70
70
|
"vue-jest": "^5.0.0-alpha.8",
|
|
71
|
-
"@varlet/vite-plugins": "2.7.3-alpha.
|
|
72
|
-
"@varlet/shared": "2.7.3-alpha.
|
|
71
|
+
"@varlet/vite-plugins": "2.7.3-alpha.1675236177820",
|
|
72
|
+
"@varlet/shared": "2.7.3-alpha.1675236177820"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/babel__core": "^7.1.12",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/semver": "^7.3.9",
|
|
83
83
|
"@types/inquirer": "^9.0.2",
|
|
84
84
|
"@types/sharp": "0.31.1",
|
|
85
|
-
"@varlet/
|
|
86
|
-
"@varlet/
|
|
85
|
+
"@varlet/touch-emulator": "2.7.3-alpha.1675236177820",
|
|
86
|
+
"@varlet/icons": "2.7.3-alpha.1675236177820"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@vue/runtime-core": "3.2.16",
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"lodash-es": "^4.17.21",
|
|
94
94
|
"vue": "3.2.25",
|
|
95
95
|
"vue-router": "4.0.12",
|
|
96
|
-
"@varlet/icons": "2.7.3-alpha.
|
|
97
|
-
"@varlet/touch-emulator": "2.7.3-alpha.
|
|
96
|
+
"@varlet/icons": "2.7.3-alpha.1675236177820",
|
|
97
|
+
"@varlet/touch-emulator": "2.7.3-alpha.1675236177820"
|
|
98
98
|
},
|
|
99
99
|
"scripts": {
|
|
100
100
|
"dev": "tsc --watch",
|