Skip to content

Commit 7128ba7

Browse files
committed
docs review
1 parent 733415c commit 7128ba7

File tree

4 files changed

+191
-107
lines changed

4 files changed

+191
-107
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"editor.formatOnSave": false
77
},
88
"[markdown]": {
9-
"editor.formatOnSave": true
9+
"editor.formatOnSave": true,
10+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1011
},
1112
"editor.codeActionsOnSave": {
1213
"source.fixAll.eslint": "explicit"

packages/docs/guide/configuration.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
---
2-
---
1+
<script setup>
2+
import CodeExample from '../components/CodeExample.vue'
3+
</script>
34

45
# Configuration
56

67
VueTypes has a global configuration object that can be used to customize the library's behavior.
78

8-
The configuration is exposed both as a property of the default export, and as a named export:
9-
10-
::: tabs
9+
The configuration is exposed both as a property of the default export and as a named export:
1110

12-
== Named export
11+
<CodeExample>
1312

1413
```js
1514
import { config } from 'vue-types'
1615

1716
VueTypes.config === config
1817
```
1918

20-
== Default export
19+
---
2120

22-
```js{sss.js}
21+
```js
2322
import VueTypes from 'vue-types'
2423

2524
VueTypes.config === config
2625
```
2726

28-
:::
27+
</CodeExample>
2928

3029
## Configuration Options
3130

32-
- `silent`: (boolean, default `false`) set to `true` to prevent VueTypes from logging validation warnings.
31+
- `silent`: (boolean, default `false`) Set to `true` to prevent VueTypes from logging validation warnings.
3332

34-
- `logLevel`: (string, default `warn`) allows choosing which console method will be used to display validation errors. Available options are `log`, `warn`, `error`, `debug` and`info`.
33+
- `logLevel`: (string, default `warn`) Allows choosing which console method will be used to display validation errors. Available options are `log`, `warn`, `error`, `debug`, and `info`.

packages/docs/guide/installation.md

+37-41
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
This guide covers VueTypes 6+.
55

66
- **VueTypes 6+ is compatible with Vue 3**.
7-
- VueTypes 4+ is compatible with **Vue 2 and Vue 3**.
8-
- VueTypes 2 is compatible with **Vue 1 and 2**.
7+
- **VueTypes 4+ is compatible with Vue 2 and Vue 3**.
8+
- **VueTypes 2 is compatible with Vue 1 and 2**.
99
:::
1010

11-
## NPM package
11+
## NPM Package
12+
13+
To install VueTypes via npm, use the following command:
1214

1315
```bash
1416
npm install vue-types --save
1517
```
1618

17-
## CDN delivered script
19+
## CDN Delivered Script
1820

19-
Add the following script tags before your code:
21+
Include the following script tags before your code:
2022

2123
```html
2224
<script src="https://unpkg.com/vue-types@6"></script>
@@ -26,7 +28,7 @@ Add the following script tags before your code:
2628
<script src="https://cdn.jsdelivr.net/npm/vue-types@6/dist/index.umd.js"></script>
2729
```
2830

29-
In modern browsers [supporting ES Modules](https://caniuse.com/es6-module), you can import the library like this:
31+
For modern browsers [supporting ES Modules](https://caniuse.com/es6-module), you can import the library as follows:
3032

3133
```html
3234
<script type="module">
@@ -40,58 +42,53 @@ In modern browsers [supporting ES Modules](https://caniuse.com/es6-module), you
4042
</script>
4143
```
4244

43-
## Usage with bundlers
45+
## Usage with Bundlers
4446

4547
VueTypes is published as a **native ESM module** with CommonJS and UMD support.
46-
47-
Modern bundlers and tools should be able to pick the correct entry point based on your configuration automatically.
48+
Modern bundlers and tools will automatically select the appropriate entry point based on your configuration.
4849

4950
```js
5051
import { string, oneOf } from 'vue-types' // or: import VueTypes from 'vue-types';
5152
```
5253

53-
## Production build
54+
## Production Build
5455

55-
Vue.js does not validate components' props when used in a production build. Using a bundler such as Webpack or Rollup, you can shrink VueTypes file size by around **70%** (minified and gzipped) by removing the validation logic while preserving the library's API methods. VueTypes ships with a `vue-types/shim` module that can be used as an alias in production builds to achieve that result.
56+
Vue.js does not validate component props in production builds. By using a bundler such as Webpack or Rollup, you can reduce the VueTypes file size by approximately **70%** (minified and gzipped) by removing validation logic while preserving the library's API methods. VueTypes provides a `vue-types/shim` module that can be used as an alias in production builds to achieve this optimization.
5657

5758
::: danger NOTE
58-
Note that all validation functions in the shim version (including `validateType` and `VueTypes.utils.validate`) always return `true`.
59+
In the shim version, all validation functions (including `validateType` and `VueTypes.utils.validate`) always return `true`.
5960
:::
6061

61-
By just aliasing `vue-types` to `vue-types/shim`, bundlers should be able to pick the module type that fits your configuration (ES, CommonJS, ...).
62-
63-
See below for common configuration scenarios.
62+
By aliasing `vue-types` to `vue-types/shim`, bundlers will automatically select the appropriate module type (ES, CommonJS, etc.) based on your configuration.
6463

65-
::: details More details
64+
### Common Configuration Scenarios
6665

67-
Here is a table showing the full and shim versions of the library for each module system.
66+
The following table displays the full and shim versions of the library for different module systems:
6867

69-
| Module system | Full Library entry point | Shim entry point |
68+
| Module System | Full Library Entry Point | Shim Entry Point |
7069
| ------------- | ------------------------ | ---------------- |
71-
| ES6 ES | `index.mjs` | `shim.mjs` |
70+
| ES6 (ES) | `index.mjs` | `shim.mjs` |
7271
| CommonJS | `index.cjs` | `shim.cjs` |
7372
| UMD | `index.umd.js` | `shim.umd.js` |
7473

75-
:::
76-
77-
### CDN usage
74+
### CDN Usage
7875

79-
If you're including the library via a `script` tag, use the dedicated shim build file:
76+
If including the library via a `script` tag, use the dedicated shim build file:
8077

8178
```html
8279
<script src="https://unpkg.com/vue-types@6/shim.umd.js"></script>
8380
```
8481

85-
### Vite
82+
### Vite Configuration
8683

87-
You can use the [conditional config](https://vitejs.dev/config/#conditional-config) feature to set a production-only [alias](https://vitejs.dev/config/#resolve-alias):
84+
Use [conditional config](https://vitejs.dev/config/#conditional-config) to set a production-only [alias](https://vitejs.dev/config/#resolve-alias):
8885

8986
```js
9087
// vite.config.js
9188

9289
export default function ({ mode }) {
9390
return {
94-
// ... other config settings
91+
// Other config settings
9592
resolve: {
9693
...(mode === 'production' && {
9794
alias: {
@@ -103,18 +100,18 @@ export default function ({ mode }) {
103100
}
104101
```
105102

106-
### Webpack
103+
### Webpack Configuration
107104

108-
The following example will shim the module in Webpack by adding an [alias field](https://webpack.js.org/configuration/resolve/#resolve-alias) to the configuration when `NODE_ENV` is set to `"production"`:
105+
To use the shim in Webpack, add an [alias field](https://webpack.js.org/configuration/resolve/#resolve-alias) to the configuration when `NODE_ENV` is set to `"production"`:
109106

110107
```js
111108
// webpack.config.js
112109

113110
return {
114-
// ... configuration
111+
// Other configuration settings
115112
resolve: {
116113
alias: {
117-
// ... other aliases
114+
// Other aliases
118115
...(process.env.NODE_ENV === 'production' && {
119116
'vue-types': 'vue-types/shim',
120117
}),
@@ -123,35 +120,34 @@ return {
123120
}
124121
```
125122

126-
### Rollup
123+
### Rollup Configuration
127124

128-
The following example will shim the module in rollup using [@rollup/plugin-alias](https://www.npmjs.com/package/@rollup/plugin-alias):
125+
Use [@rollup/plugin-alias](https://www.npmjs.com/package/@rollup/plugin-alias) to apply the shim in Rollup:
129126

130127
```js
131128
// rollup.config.js
132129
import alias from '@rollup/plugin-alias'
133130

134131
return {
135-
// ... configuration
132+
// Other configuration settings
136133
plugins: [
137134
alias({
138135
entries: {
139136
'vue-types': 'vue-types/shim',
140137
},
141138
}),
142-
// ...other plugins
139+
// Other plugins
143140
],
144141
}
145142
```
146143

147144
::: warning
148-
If you are using [@rollup/plugin-node-resolve](https://www.npmjs.com/package/@rollup/plugin-node-resolve), place the alias plugin **before** the resolve plugin.
149-
145+
If using [@rollup/plugin-node-resolve](https://www.npmjs.com/package/@rollup/plugin-node-resolve), place the alias plugin **before** the resolve plugin.
150146
:::
151147

152-
### Nuxt
148+
### Nuxt Configuration
153149

154-
VueTypes provides a Nuxt module that will automatically enable the shim for production builds:
150+
VueTypes provides a Nuxt module that automatically enables the shim for production builds:
155151

156152
```sh
157153
npm install vue-types-nuxt --save-dev
@@ -161,20 +157,20 @@ npm install vue-types-nuxt --save-dev
161157
// nuxt.config.ts
162158

163159
export default {
164-
// ...
160+
// Other settings
165161
modules: ['vue-types-nuxt'],
166162
}
167163
```
168164

169-
The module accepts a `shim` boolean option to turn the shim on/off forcefully:
165+
To explicitly enable the shim, set the `shim` option:
170166

171167
```ts
172168
// nuxt.config.ts
173169

174170
export default {
175171
modules: ['vue-types-nuxt'],
176172

177-
// use the shim even during development
173+
// Enable the shim even during development
178174
vueTypes: {
179175
shim: true,
180176
},

0 commit comments

Comments
 (0)