1.0.0
parent
6b2529ce4d
commit
8f5cc1efb1
|
@ -0,0 +1,14 @@
|
|||
dist
|
||||
node_modules
|
||||
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
package-lock.json
|
||||
|
||||
._*
|
||||
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
|
@ -0,0 +1,2 @@
|
|||
src/
|
||||
update.js
|
|
@ -0,0 +1,10 @@
|
|||
jsxBracketSameLine: true
|
||||
jsxSingleQuote: true
|
||||
semi: false
|
||||
singleQuote: true
|
||||
printWidth: 80
|
||||
useTabs: false
|
||||
tabWidth: 2
|
||||
trailingComma: none
|
||||
bracketSpacing: true
|
||||
arrowParens: avoid
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@bytedo/vue-router",
|
||||
"description": "vue-router去除`@vue/devtools-api`依赖版",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node ./update.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bytedo/vue-router.git"
|
||||
},
|
||||
"keywords": [
|
||||
"vue-router",
|
||||
"vue"
|
||||
],
|
||||
"author": "Yutent <yutent.io@gmail.com>"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* {}
|
||||
* @author yutent<yutent.io@gmail.com>
|
||||
* @date 2023/02/15 22:46:25
|
||||
*/
|
||||
|
||||
import Es from 'esbuild'
|
||||
import fs from 'iofs'
|
||||
import { resolve } from 'path'
|
||||
import { exec } from 'child_process'
|
||||
|
||||
const NPM_URL = 'https://registry.npmmirror.com'
|
||||
|
||||
function download(url) {
|
||||
return fetch(url).then(r => r.arrayBuffer())
|
||||
}
|
||||
|
||||
export function execAsync(cmd) {
|
||||
return new Promise((yes, no) => {
|
||||
exec(cmd, { cwd: resolve('./') }, (err, res) => {
|
||||
if (err) {
|
||||
no(err)
|
||||
} else {
|
||||
yes(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
!(async function () {
|
||||
// let { version, url } = await fetch(
|
||||
// 'https://registry.npmmirror.com/vue-router',
|
||||
// {
|
||||
// headers: {
|
||||
// 'content-type': 'application/json',
|
||||
// accept: 'application/json'
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
// .then(r => r.json())
|
||||
// .then(r => {
|
||||
// let v = r['dist-tags'].latest
|
||||
// let url = r.versions[v].dist.tarball
|
||||
// return { version: v, url }
|
||||
// })
|
||||
// let ab = await download(url)
|
||||
|
||||
// fs.echo(Buffer.from(ab), './vue-router.tgz')
|
||||
|
||||
// await execAsync('tar -xzf vue-router.tgz')
|
||||
|
||||
let code = fs.cat('package/dist/vue-router.esm-browser.js').toString()
|
||||
|
||||
fs.echo(
|
||||
code
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace("import { setupDevtoolsPlugin } from '@vue/devtools-api';", '')
|
||||
.replace('let routerId = 0;', '')
|
||||
.replace(
|
||||
/function addDevtools\(app, router, matcher\) \{[\w\W]*?\n\}/,
|
||||
''
|
||||
)
|
||||
.replace('addDevtools(app, router, matcher);', '')
|
||||
.replace(
|
||||
/if \(isBrowser &&\n\s+component\.ref\) \{\n[\w\W]*?\n\s{12}\}/,
|
||||
''
|
||||
)
|
||||
.replace(/\s{4}\/\/ devtools only\n[\w\W]*?\n\s{4}\}/, ''),
|
||||
'src/vue-router.js'
|
||||
)
|
||||
|
||||
Es.build({
|
||||
entryPoints: ['src/vue-router.js'],
|
||||
outdir: 'dist',
|
||||
target: 'es2017',
|
||||
format: 'esm',
|
||||
minify: true
|
||||
})
|
||||
|
||||
fs.rm('./package', true)
|
||||
fs.rm('./vue-router.tgz')
|
||||
})()
|
Loading…
Reference in New Issue