Skip to content

Commit

Permalink
fix(build): ship built-in vue-demi to avoid resolution issues (#3680)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Mar 22, 2024
1 parent 05061bd commit 5d3cb96
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions lib/vue-demi.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* vue-demi v0.14.7
* Copyright (c) 2020-present, Anthony Fu
* @license MIT
*/

import * as Vue from 'vue'

var isVue2 = false
var isVue3 = true
var Vue2 = undefined

function install() {}

export function set(target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
return val
}
target[key] = val
return val
}

export function del(target, key) {
if (Array.isArray(target)) {
target.splice(key, 1)
return
}
delete target[key]
}

export * from 'vue'
export { Vue, Vue2, isVue2, isVue3, install }
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"./theme-without-fonts": {
"types": "./theme-without-fonts.d.ts",
"default": "./dist/client/theme-default/without-fonts.js"
},
"./vue-demi": {
"default": "./lib/vue-demi.mjs"
}
},
"bin": {
Expand All @@ -36,7 +39,8 @@
"template",
"client.d.ts",
"theme.d.ts",
"theme-without-fonts.d.ts"
"theme-without-fonts.d.ts",
"lib"
],
"repository": {
"type": "git",
Expand Down
4 changes: 4 additions & 0 deletions src/node/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export function resolveAliases(
{
find: /^vitepress\/theme$/,
replacement: join(DIST_CLIENT_PATH, '/theme-default/index.js')
},
{
find: /^vue-demi$/,
replacement: require.resolve('vitepress/vue-demi')
}
]

Expand Down

0 comments on commit 5d3cb96

Please sign in to comment.