-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1445 from empathyco/feat/EMP-3849-create-vue3-mig…
…ration-test-package build: Create Vue 3 migration test package
- Loading branch information
Showing
22 changed files
with
667 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_VUE_COMPAT_MODE = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: ['plugin:@empathyco/x/all'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: 'tsconfig.eslint.json' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# vue3-migration-test | ||
|
||
[Vue 3 Migration Guide](https://v3-migration.vuejs.org/migration-build.html) | ||
|
||
To check compile-time errors & warnings: | ||
|
||
``` | ||
pnpm --filter vue3-migration-test run build | ||
``` | ||
|
||
To check command-line / browser console warnings: | ||
|
||
``` | ||
pnpm --filter vue3-migration-test run dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>vue3-migration-test</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "vue3-migration-test", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"preview": "vite preview", | ||
"lint": "eslint . --ext .ts,.vue", | ||
"build": "vue-tsc && vite build" | ||
}, | ||
"dependencies": { | ||
"@vue/compat": "^3.4.22", | ||
"vue": "^3.4.22", | ||
"vue-router": "^4.3.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vue/runtime-dom": "^3.4.22", | ||
"typescript": "~4.9.4", | ||
"vite": "^4.5.0", | ||
"vue-tsc": "^2.0.13" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<div id="app"> | ||
<h1>vue3-migration-test</h1> | ||
<nav> | ||
<RouterLink v-for="route in $router.options.routes" :key="route.path" :to="route.path"> | ||
{{ route.name }} | ||
</RouterLink> | ||
</nav> | ||
<main> | ||
<RouterView /> | ||
</main> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"></script> | ||
|
||
<style lang="scss" scoped> | ||
#app { | ||
nav { | ||
display: flex; | ||
gap: 0.5rem; | ||
flex-wrap: wrap; | ||
margin: 1rem 0; | ||
} | ||
} | ||
</style> |
2 changes: 2 additions & 0 deletions
2
packages/_vue3-migration-test/src/components/animations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as TestAnimateWidth } from './test-animate-width.vue'; | ||
export { default as TestFade } from './test-fade.vue'; |
15 changes: 15 additions & 0 deletions
15
packages/_vue3-migration-test/src/components/animations/test-animate-width.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<div> | ||
<button @click="visible = !visible">Toggle</button> | ||
<AnimateWidth> | ||
<div v-if="visible" style="width: 300px">Element to animate</div> | ||
</AnimateWidth> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import AnimateWidth from '../../../../x-components/src/components/animations/animate-width.vue'; | ||
const visible = ref(true); | ||
</script> |
15 changes: 15 additions & 0 deletions
15
packages/_vue3-migration-test/src/components/animations/test-fade.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<div> | ||
<button @click="shouldRender = !shouldRender">Toggle</button> | ||
<Fade> | ||
<p v-if="shouldRender">León is southern Spain</p> | ||
</Fade> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import Fade from '../../../../x-components/src/components/animations/fade.vue'; | ||
const shouldRender = ref(false); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './animations'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, configureCompat, createApp } from 'vue'; | ||
import App from './App.vue'; | ||
import router from './router'; | ||
|
||
// Warnings that cannot be solved in Vue 2 (a.k.a. breaking changes) are suppressed | ||
const VUE_COMPAT_MODE = Number(import.meta.env.VITE_VUE_COMPAT_MODE); | ||
if (VUE_COMPAT_MODE === 2) { | ||
configureCompat({ | ||
INSTANCE_LISTENERS: 'suppress-warning' | ||
}); | ||
} | ||
|
||
createApp(App as Component) | ||
.use(router) | ||
.mount('#app'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createRouter, createWebHistory } from 'vue-router'; | ||
import { TestAnimateWidth, TestFade } from './'; | ||
|
||
const routes = [ | ||
{ | ||
path: '/animate-width', | ||
name: 'AnimateWidth', | ||
component: TestAnimateWidth | ||
}, | ||
{ | ||
path: '/fade', | ||
name: 'Fade', | ||
component: TestFade | ||
} | ||
]; | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(), | ||
routes | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare module 'vue' { | ||
import { CompatVue } from '@vue/runtime-dom'; | ||
const Vue: CompatVue; | ||
export default Vue; | ||
export * from '@vue/runtime-dom'; | ||
const { configureCompat } = Vue; | ||
export { configureCompat }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv; | ||
} | ||
|
||
interface ImportMetaEnv { | ||
readonly VITE_VUE_COMPAT_MODE: '2' | '3'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.vue", "vite.config.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2019", | ||
"module": "esnext", | ||
"strict": true, | ||
"jsx": "preserve", | ||
"importHelpers": true, | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
"rootDir": "src", | ||
"baseUrl": ".", | ||
"types": ["node"], | ||
"lib": ["esnext", "dom", "dom.iterable", "scripthost"] | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.vue"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { resolve } from 'path'; | ||
import vue from '@vitejs/plugin-vue'; | ||
import { defineConfig, loadEnv } from 'vite'; | ||
import { vueDocsPlugin } from '../x-components/vite.config'; | ||
|
||
export default defineConfig(({ mode }) => { | ||
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; | ||
const { VITE_VUE_COMPAT_MODE } = process.env; | ||
const VUE_COMPAT_MODE = Number(VITE_VUE_COMPAT_MODE); | ||
if (VUE_COMPAT_MODE !== 2 && VUE_COMPAT_MODE !== 3) { | ||
throw new Error( | ||
`Invalid VITE_VUE_COMPAT_MODE value ('${VITE_VUE_COMPAT_MODE ?? ''}'), expected '2' | '3'` | ||
); | ||
} | ||
return { | ||
plugins: [ | ||
vue({ | ||
template: { | ||
compilerOptions: { | ||
compatConfig: { | ||
MODE: VUE_COMPAT_MODE | ||
} | ||
} | ||
} | ||
}), | ||
vueDocsPlugin | ||
], | ||
resolve: { | ||
alias: { | ||
vue: resolve(__dirname, 'node_modules/@vue/compat') | ||
} | ||
}, | ||
optimizeDeps: { | ||
exclude: ['@empathyco/x-components'] | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.