-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Build mechanics have changed significantly with the introduction of the version for Vue 3. Although there shouldn't be any problems (the default export should work the same as before), the update is marked as a major to avoid embarrassment.
- Loading branch information
Showing
20 changed files
with
446 additions
and
51 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
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
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,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../scripts/postinstall.js'); |
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,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../scripts/switch-cli.js'); |
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,19 @@ | ||
{ | ||
"name": "vue2-builder", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "vite --config vite-dev.config.js", | ||
"playground": "vite build --config vite-dev.config.js", | ||
"build": "vite build --config vite-lib.config.js" | ||
}, | ||
"devDependencies": { | ||
"@morev/v-bem-transformer": "^0.0.5", | ||
"element-ui": "^2.15.6", | ||
"more-sass": "^1.0.7", | ||
"vite-plugin-vue2": "^1.9.3", | ||
"vue": "^2.6.14", | ||
"vue-template-compiler": "^2.6.14" | ||
} | ||
} |
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
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 @@ | ||
{ | ||
"name": "vue3-builder", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "vite build --config vite-lib.config.js" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^2.3.1", | ||
"vue": "^3.2.31" | ||
} | ||
} |
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,47 @@ | ||
import { defineConfig } from 'vite'; | ||
import vue from '@vitejs/plugin-vue'; | ||
|
||
const transformPlugin = ({ | ||
name: 'vue2-to-vue3-transformer', | ||
transform: (context) => { | ||
return context | ||
.replace( | ||
'...this.$listeners,', | ||
'', | ||
) | ||
.replace( | ||
'// BUILD-TIME: TRANSITIONS IMPORT FOR VUE 3', | ||
`import { Transition, TransitionGroup } from 'vue';`, | ||
) | ||
.replace( | ||
`'transition-group' : 'transition'`, | ||
`TransitionGroup : Transition`, | ||
); | ||
}, | ||
}); | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
transformPlugin, | ||
vue(), | ||
], | ||
build: { | ||
minify: 'terser', | ||
lib: { | ||
entry: '../../src/index.js', | ||
formats: ['es', 'cjs', 'umd'], | ||
name: 'vueTransitions', | ||
fileName: (format) => `vue-transitions.${format}.js`, | ||
}, | ||
cssCodeSplit: true, | ||
rollupOptions: { | ||
external: ['vue'], | ||
output: { | ||
dir: '../../dist/vue3', | ||
globals: { | ||
vue: '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
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 @@ | ||
const { switchVersion, loadModule, ERROR_PREFIX } = require('./utils.js'); | ||
|
||
const Vue = loadModule('vue'); | ||
|
||
if (!Vue || typeof Vue.version !== 'string') { | ||
console.warn(`${ERROR_PREFIX} Vue is not found. Please run "npm install vue" to install.`); | ||
} else if (Vue.version.startsWith('2.')) { | ||
switchVersion(2); | ||
} else if (Vue.version.startsWith('3.')) { | ||
switchVersion(3); | ||
} else { | ||
console.warn(`${ERROR_PREFIX} Vue version v${Vue.version} is not suppported.`); | ||
} |
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 @@ | ||
const fs = require('fs'); | ||
|
||
const packageJsonContents = fs.readFileSync('package.json', { encoding: 'utf8' }); | ||
|
||
fs.writeFileSync( | ||
'package.json', | ||
packageJsonContents.replace('"private": false', '"private": true'), | ||
); |
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,10 @@ | ||
const fs = require('fs'); | ||
|
||
const packageJsonContents = fs.readFileSync('package.json', { encoding: 'utf8' }); | ||
|
||
fs.writeFileSync( | ||
'package.json', | ||
packageJsonContents | ||
.replace('"private": true', '"private": false') | ||
.replace('"scripts": {', '"scripts": {\n\t\t"postinstall": "node ./scripts/postinstall.js",'), | ||
); |
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,14 @@ | ||
const { switchVersion, ERROR_PREFIX } = require('./utils.js'); | ||
|
||
const version = process.argv[2]; | ||
const vueEntry = process.argv[3] || 'vue'; | ||
|
||
if (version === '2') { | ||
switchVersion(2, vueEntry); | ||
console.log(`${ERROR_PREFIX} Switched for Vue 2 (entry: "${vueEntry}")`); | ||
} else if (version === '3') { | ||
switchVersion(3, vueEntry); | ||
console.log(`${ERROR_PREFIX} Switched for Vue 3 (entry: "${vueEntry}")`); | ||
} else { | ||
console.warn(`${ERROR_PREFIX} expecting version "2" or "3" but got "${version}"`); | ||
} |
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,35 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const dir = path.resolve(__dirname); | ||
|
||
const loadModule = (name) => { | ||
try { | ||
return require(name); | ||
} catch { | ||
return undefined; | ||
} | ||
}; | ||
|
||
const copy = (name, version) => { | ||
const src = path.join(dir, '..', 'dist', `vue${version}`, name); | ||
const dest = path.join(dir, '..', 'dist', name); | ||
const content = fs.readFileSync(src, 'utf8'); | ||
// unlink for pnpm, @see https://github.com/vueuse/vue-demi/issues/92 | ||
try { | ||
fs.unlinkSync(dest); | ||
} catch {} | ||
fs.writeFileSync(dest, content, 'utf8'); | ||
}; | ||
|
||
const switchVersion = (version) => { | ||
copy('vue-transitions.cjs.js', version); | ||
copy('vue-transitions.es.js', version); | ||
copy('vue-transitions.umd.js', version); | ||
copy('index.css', version); | ||
}; | ||
|
||
|
||
module.exports.loadModule = loadModule; | ||
module.exports.switchVersion = switchVersion; | ||
module.exports.ERROR_PREFIX = '[@morev/vue-transitions]'; |
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.