Skip to content

Commit a1f4842

Browse files
committed
test: test compatibility with Vue CLI 3
1 parent 44b32b4 commit a1f4842

20 files changed

+12869
-1321
lines changed

Diff for: README.md

+48-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ English | [简体中文](./docs/README.zh-CN.md)
3030

3131
- Support Vue 2.6 / 2.7 / 3
3232
- Support SSR (Nuxt 2 / 3)
33+
- Support Vite, Vue CLI 3 / 4 / 5 ...
3334
- Support microfrontends (like [wujie](https://github.com/Tencent/wujie))
3435
- Edit mode two-way binding
3536
- Local registration + local configuration, or global registration + global configuration (Powered by [vue-global-config](https://github.com/cloydlau/vue-global-config))
@@ -502,6 +503,7 @@ npm add json-editor-vue vanilla-jsoneditor
502503
export default {
503504
build: {
504505
extend(config) {
506+
// Getting webpack to recognize the `.mjs` file
505507
config.module.rules.push({
506508
test: /\.mjs$/,
507509
include: /node_modules/,
@@ -539,6 +541,7 @@ export default {
539541
plugins: ['~/plugins/JsonEditorVue.client'],
540542
build: {
541543
extend(config) {
544+
// Getting webpack to recognize the `.mjs` file
542545
config.module.rules.push({
543546
test: /\.mjs$/,
544547
include: /node_modules/,
@@ -590,6 +593,7 @@ npm add json-editor-vue vanilla-jsoneditor @vue/composition-api
590593
export default {
591594
build: {
592595
extend(config) {
596+
// Getting webpack to recognize the `.mjs` file
593597
config.module.rules.push({
594598
test: /\.mjs$/,
595599
include: /node_modules/,
@@ -636,6 +640,7 @@ export default {
636640
plugins: ['~/plugins/JsonEditorVue.client'],
637641
build: {
638642
extend(config) {
643+
// Getting webpack to recognize the `.mjs` file
639644
config.module.rules.push({
640645
test: /\.mjs$/,
641646
include: /node_modules/,
@@ -685,19 +690,58 @@ Ready to use right out of the box.
685690

686691
<br>
687692

688-
### Vue CLI 5 / webpack 5
693+
### Vue CLI 5 (webpack 5)
689694

690695
Ready to use right out of the box.
691696

692697
<br>
693698

694-
### Vue CLI 4 / webpack 4
699+
### Vue CLI 4 (webpack 4)
695700

696-
Vite 4 (Rollup 3) uses ES2020 as compiler target by default, therefore Vite-4-built outputs should be transpiled in webpack 4:
701+
Vite 4 (Rollup 3) uses ES2020 as compiler target by default, therefore Vite-4-built outputs should be transpiled in webpack 4.
697702

698703
```js
704+
// vue.config.js
705+
706+
module.exports = {
707+
transpileDependencies: ['json-editor-vue'],
708+
}
709+
```
710+
711+
<br>
712+
713+
### Vue CLI 3 (webpack 4)
714+
715+
Vite 4 (Rollup 3) uses ES2020 as compiler target by default, therefore Vite-4-built outputs should be transpiled in webpack 4.
716+
717+
```shell
718+
npm add @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining -D
719+
```
720+
721+
```js
722+
// babel.config.js
723+
724+
module.exports = {
725+
plugins: [
726+
'@babel/plugin-proposal-nullish-coalescing-operator',
727+
'@babel/plugin-proposal-optional-chaining',
728+
],
729+
}
730+
```
731+
732+
```js
733+
// vue.config.js
734+
699735
module.exports = {
700736
transpileDependencies: ['json-editor-vue'],
737+
chainWebpack(config) {
738+
// Getting webpack to recognize the `.mjs` file
739+
config.module
740+
.rule('mjs')
741+
.type('javascript/auto')
742+
.include.add(/node_modules/)
743+
.end()
744+
},
701745
}
702746
```
703747

@@ -708,7 +752,7 @@ module.exports = {
708752
| Name | Description | Type | Default |
709753
| ------- | --------------------------------------------------------------------------------------------- | ------------- | -------- |
710754
| v-model | binding value | `any` | |
711-
| mode | edit mode, <br>use `v-model:mode` in Vue 3 <br>or `:mode.sync` in Vue 2 | [Mode](#Mode) | `'tree'` |
755+
| mode | edit mode, <br>use `[v-model]:mode` in Vue 3 <br>or `:mode[.sync]` in Vue 2 | [Mode](#Mode) | `'tree'` |
712756
| ... | properties of [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) | | |
713757

714758
> ⚠ kebab-case is required for tag & prop name when using from CDN

Diff for: demo/vue-cli3/.browserslistrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 1%
2+
last 2 versions

Diff for: demo/vue-cli3/.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?

Diff for: demo/vue-cli3/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# vue-cli3
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Customize configuration
19+
See [Configuration Reference](https://cli.vuejs.org/config/).

Diff for: demo/vue-cli3/babel.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app',
4+
],
5+
plugins: [
6+
'@babel/plugin-proposal-nullish-coalescing-operator',
7+
'@babel/plugin-proposal-optional-chaining',
8+
],
9+
}

0 commit comments

Comments
 (0)