@varlet/cli 1.23.4-alpha.4 → 1.23.4-alpha.8
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/README.en-US.md +28 -2
- package/README.md +26 -0
- package/lib/compiler/compileScript.js +1 -1
- package/lib/config/vite.config.js +1 -0
- package/package.json +2 -2
package/README.en-US.md
CHANGED
|
@@ -55,6 +55,32 @@ The `varlet.config.js` in the project root directory is used to manage the speci
|
|
|
55
55
|
| `analysis` | Document statistics related | _SiteAnalysis_ | `-` |
|
|
56
56
|
| `pc` | PC-side document structure configuration | _SitePC_ | `-` |
|
|
57
57
|
| `mobile` | Mobile document structure configuration | _SiteMobile_ | `-` |
|
|
58
|
+
| `moduleCompatible` | Module compatible config | _Record<string, string>_ | `-` |
|
|
59
|
+
|
|
60
|
+
#### Module Compatible
|
|
61
|
+
|
|
62
|
+
Some external dependencies may need to be compatible with module syntax to achieve the purpose of compiling correctly to `commonjs` and `esmodule`. For example, the wording of `esmodule` of `dayjs` is
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import dayjs from 'dayjs/esm'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In order to build `commonjs`, the writing method is
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import * as dayjs from 'dayjs'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
In the project, we embrace the first way of writing the `esmodule` module, and make the following configuration for adaptation
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
// varlet.config.js
|
|
78
|
+
module.exports = {
|
|
79
|
+
moduleCompatible: {
|
|
80
|
+
"import dayjs from 'dayjs/esm'\n": "import * as dayjs from 'dayjs'\n"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
58
84
|
|
|
59
85
|
#### SiteThemes
|
|
60
86
|
|
|
@@ -93,7 +119,7 @@ Code snippets are highlighted, based on [highlight.js](https://highlightjs.org/)
|
|
|
93
119
|
|
|
94
120
|
| Parameter | Description | Type | Default |
|
|
95
121
|
| ----- | -------------- | -------- | ---------- |
|
|
96
|
-
| `style` | highlight
|
|
122
|
+
| `style` | highlight css link | _string_ | `-` |
|
|
97
123
|
|
|
98
124
|
#### SiteAnalysis
|
|
99
125
|
|
|
@@ -101,7 +127,7 @@ Statistics related to buried points
|
|
|
101
127
|
|
|
102
128
|
| Parameter | Description | Type | Default |
|
|
103
129
|
| ----- | -------------- | -------- | ---------- |
|
|
104
|
-
| `baidu` |
|
|
130
|
+
| `baidu` | Baidu statistics script address | _string_ | `-` |
|
|
105
131
|
|
|
106
132
|
#### SitePC, SiteMobile
|
|
107
133
|
|
package/README.md
CHANGED
|
@@ -53,6 +53,32 @@ yarn dev
|
|
|
53
53
|
| `analysis` | 文档统计相关 | _SiteAnalysis_ | `-` |
|
|
54
54
|
| `pc` | pc端文档结构配置 | _SitePC_ | `-` |
|
|
55
55
|
| `mobile` | mobile端文档结构配置 | _SiteMobile_ | `-` |
|
|
56
|
+
| `moduleCompatible` | 模块兼容配置 | _Record<string, string>_ | `-` |
|
|
57
|
+
|
|
58
|
+
#### 模块适配对象
|
|
59
|
+
|
|
60
|
+
一些外部依赖可能需要进行模块语法的适配,以达到可以正确编译到`commonjs`和`esmodule`的目的,例如`dayjs`的`esmodule`写法是
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import dayjs from 'dayjs/esm'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
而为了构建`commonjs`时的写法是
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import * as dayjs from 'dayjs'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
在项目中我们拥抱`esmodule`模块使用第一种写法,并做如下配置进行适配
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
// varlet.config.js
|
|
76
|
+
module.exports = {
|
|
77
|
+
moduleCompatible: {
|
|
78
|
+
"import dayjs from 'dayjs/esm'\n": "import * as dayjs from 'dayjs'\n"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
56
82
|
|
|
57
83
|
#### SiteThemes
|
|
58
84
|
|
|
@@ -177,7 +177,7 @@ function compileCommonJSEntry(dir, publicDirs) {
|
|
|
177
177
|
publicDirs.forEach(function (dirname) {
|
|
178
178
|
var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
|
|
179
179
|
publicComponents.push(publicComponent);
|
|
180
|
-
requires.push("
|
|
180
|
+
requires.push("var " + publicComponent + " = require('./" + dirname + "')['default']");
|
|
181
181
|
plugins.push(publicComponent + ".install && app.use(" + publicComponent + ")");
|
|
182
182
|
cssRequires.push("require('./" + dirname + "/style')");
|
|
183
183
|
lessRequires.push("require('./" + dirname + "/style/less')");
|
|
@@ -84,6 +84,7 @@ function inlineCSS(fileName, dir) {
|
|
|
84
84
|
var cssCode = (0, fs_extra_1.readFileSync)(cssFile, 'utf-8');
|
|
85
85
|
var jsCode = (0, fs_extra_1.readFileSync)(jsFile, 'utf-8');
|
|
86
86
|
var injectCode = ";(function(){var style=document.createElement('style');style.type='text/css';style.rel='stylesheet';style.appendChild(document.createTextNode(`" + cssCode.replace(/\\/g, '\\\\') + "`));var head=document.querySelector('head');head.appendChild(style)})();";
|
|
87
|
+
(0, fs_extra_1.copyFileSync)(cssFile, (0, path_1.resolve)(constant_1.LIB_DIR, 'style.css'));
|
|
87
88
|
(0, fs_extra_1.removeSync)(cssFile);
|
|
88
89
|
(0, fs_extra_1.writeFileSync)(jsFile, "" + injectCode + jsCode);
|
|
89
90
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "1.23.4-alpha.
|
|
3
|
+
"version": "1.23.4-alpha.8+c5c2b12f",
|
|
4
4
|
"description": "cli of varlet",
|
|
5
5
|
"bin": {
|
|
6
6
|
"varlet-cli": "./lib/index.js"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dev": "tsc --watch",
|
|
32
32
|
"build": "tsc"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c5c2b12f163bed130b3c6c0ee0eb805fe4a015f1",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/core": "^7.14.8",
|
|
37
37
|
"@babel/preset-env": "^7.14.8",
|