Skip to content

Commit ad9ccdd

Browse files
committed
docs
1 parent 7c922d7 commit ad9ccdd

File tree

13 files changed

+52
-231
lines changed

13 files changed

+52
-231
lines changed

docs/en/_sidebar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- [Attribute types](/en/tsx/attribute-types/attribute-types.md)
2424
- Custom Decorator
2525
- [Custom Decorator](/en/custom/custom.md)
26-
- Migrate from v2
27-
- [Migrate from v2](/en/migrate-from-v2/migrate-from-v2.md)
26+
- Migration
27+
- [Migrate from v2 to v3](/en/migration/from-v2-to-v3.md)
2828
- Stage3 decorators
2929
- [Stage3 decorators](/en/stage3-decorators/stage3-decorators.md)

docs/en/compatibility/-deprecated- reflect-metadata/code-usage.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/en/compatibility/-deprecated- reflect-metadata/code-webpack-alias-vue-config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/en/compatibility/-deprecated- reflect-metadata/code-webpack-alias-webpack-config.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/en/compatibility/-deprecated- reflect-metadata/reflect-metadata.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/en/migrate-from-v2/migrate-from-v2.md renamed to docs/en/migration/from-v2-to-v3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Migrate from v2
1+
## Migrate from v2 to v3
22

33
To migrate from v2, you need to change your project with some break changes.
44

@@ -10,13 +10,13 @@ In 3.x, decorator `Component` is same to `ComponentBase`, and you should cast cl
1010

1111
It is recommended to use `toNative` to transform a class component into a vue options API component, after that, the transformed component could be used as a native vue component in where vue accepts it.
1212

13-
[](./breaking-changes-toNative.ts ':include :type=code typescript')
13+
[](./from-v2-to-v3-breaking-changes-toNative.ts ':include :type=code typescript')
1414

1515
### Depreactate init class property despends on another in constructor
1616

1717
This is not allowed now.
1818

19-
[](./breaking-changes-classProperty.ts ':include :type=code typescript')
19+
[](./from-v2-to-v3-breaking-changes-classProperty.ts ':include :type=code typescript')
2020

2121
### Remove `index-return-cons`
2222

docs/en/quick-start/quick-start.md

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -28,102 +28,7 @@ Enable `experimentalDecorators` in `tsconfig.json` in project root directory.
2828

2929
### In JavaScript projects
3030

31-
#### Vite
32-
33-
1. Install the required dependencies:
34-
35-
```shell
36-
npm install @haixing_hu/vue3-class-component
37-
npm install @babel/core @babel/runtime @babel/preset-env
38-
npm install @babel/plugin-proposal-decorators @babel/plugin-transform-class-properties @babel/plugin-transform-runtime
39-
```
40-
41-
2. Configure [Babel] by using [@babel/plugin-transform-class-properties] and
42-
[@babel/plugin-proposal-decorators] plugins. A possible [Babel] configuration
43-
file `babelrc.json` is as follows:
44-
45-
```json
46-
{
47-
"presets": [
48-
["@babel/preset-env", { "modules": false }]
49-
],
50-
"plugins": [
51-
"@babel/plugin-transform-runtime",
52-
["@babel/plugin-proposal-decorators", { "version": "2023-05" }],
53-
"@babel/plugin-transform-class-properties"
54-
]
55-
}
56-
```
57-
58-
**Note:** When bundling with [vite], make sure to set the `modules` parameter
59-
of `@babel/preset-env` to `false`.
60-
61-
3. Configure [vite] by modifying the `vite.config.js` file to add support for
62-
[Babel]. A possible `vite.config.js` file is as follows:
63-
64-
```js
65-
import { fileURLToPath, URL } from 'node:url';
66-
import { defineConfig } from 'vite';
67-
import vue from '@vitejs/plugin-vue';
68-
import * as babel from '@babel/core';
69-
70-
// A very simple Vite plugin support babel transpilation
71-
const babelPlugin = {
72-
name: 'plugin-babel',
73-
transform: (src, id) => {
74-
if (/\.(jsx?|vue)$/.test(id)) { // the pattern of the file to handle
75-
return babel.transform(src, {
76-
filename: id,
77-
babelrc: true,
78-
});
79-
}
80-
},
81-
};
82-
83-
// https://vitejs.dev/config/
84-
export default defineConfig({
85-
plugins: [
86-
vue({
87-
script: {
88-
babelParserPlugins: ['decorators'], // must enable decorators support
89-
},
90-
}),
91-
babelPlugin, // must be after the vue plugin
92-
],
93-
resolve: {
94-
alias: {
95-
'@': fileURLToPath(new URL('./src', import.meta.url)),
96-
},
97-
},
98-
});
99-
```
100-
101-
#### Webpack
102-
103-
1. Install the required dependencies:
104-
105-
```shell
106-
npm install @haixing_hu/vue3-class-component
107-
npm install @babel/core @babel/runtime @babel/preset-env
108-
npm install @babel/plugin-proposal-decorators @babel/plugin-transform-class-properties @babel/plugin-transform-runtime
109-
```
110-
111-
2. Configure [Babel] by using the [@babel/plugin-transform-class-properties]
112-
and [@babel/plugin-proposal-decorators] plugins. A possible [Babel]
113-
configuration file `babelrc.json` is as follows:
114-
115-
```json
116-
{
117-
"presets": [
118-
"@babel/preset-env"
119-
],
120-
"plugins": [
121-
"@babel/plugin-transform-runtime",
122-
["@babel/plugin-proposal-decorators", { "version": "2023-05" }],
123-
"@babel/plugin-transform-class-properties"
124-
]
125-
}
126-
```
31+
`vue-facing-decorator` could be used in pure JavaScript Vue projects. you must enable decorator features manully(e.g. transform decorators by `babel`).
12732

12833
## How to use?
12934

docs/zh-cn/_sidebar.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@
2222
- [TSX](/zh-cn/tsx/tsx-render/tsx-render.md)
2323
- [属性类型](/zh-cn/tsx/attribute-types/attribute-types.md)
2424
- 自定义装饰器
25-
- [自定义装饰器](/zh-cn/custom/custom.md)
25+
- [自定义装饰器](/zh-cn/custom/custom.md)
26+
- 从旧版迁移
27+
- [v2迁移到v3](/zh-cn/migration/from-v2-to-v3.md)
28+
- Stage3装饰器
29+
- [Stage3装饰器](/zh-cn/stage3-decorators/stage3-decorators.md)

0 commit comments

Comments
 (0)